Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
  • Loading branch information
pperiyasamy committed Jul 29, 2021
1 parent 0465995 commit 66634f4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/networkservice/common/resourcepool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (i *resourcePoolClient) Request(ctx context.Context, request *networkservic
logger := log.FromContext(ctx).WithField("resourcePoolClient", "Request")

oldPCIAddress := request.GetConnection().GetMechanism().GetParameters()[common.PCIAddressKey]
oldTokenIDKey := request.GetConnection().GetMechanism().GetParameters()[TokenIDKey]
oldTokenID := request.GetConnection().GetMechanism().GetParameters()[TokenIDKey]

conn, err := next.Client(ctx).Request(ctx, request, opts...)
if err != nil {
Expand All @@ -81,7 +81,7 @@ func (i *resourcePoolClient) Request(ctx context.Context, request *networkservic
}

// Don't make second request if PCI address, token id weren't changed
if conn.GetMechanism().GetParameters()[common.PCIAddressKey] == oldPCIAddress && oldTokenIDKey == tokenID {
if conn.GetMechanism().GetParameters()[common.PCIAddressKey] == oldPCIAddress && oldTokenID == tokenID {
return conn, nil
}

Expand All @@ -92,12 +92,9 @@ func (i *resourcePoolClient) Request(ctx context.Context, request *networkservic
if conn, err = next.Client(ctx).Request(ctx, request); err != nil {
// Perform local cleanup in case of second Request failed
_ = i.resourcePool.close(request.Connection)
if _, closeErr := next.Client(ctx).Close(ctx, conn, opts...); closeErr != nil {
logger.Errorf("failed to close failed connection: %s %s", conn.GetId(), closeErr.Error())
}
}

return conn, nil
return conn, err
}

func (i *resourcePoolClient) Close(ctx context.Context, conn *networkservice.Connection, opts ...grpc.CallOption) (*empty.Empty, error) {
Expand Down

0 comments on commit 66634f4

Please sign in to comment.