Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: add new rpc call for mirroring #2875

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rewantsoni
Copy link
Member

Add two rpc calls required for setting up mirroring for blockpool and radosnamespace

  1. GetBlockPoolsInfo
  2. GetClientInfo

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 4, 2024
Copy link
Contributor

openshift-ci bot commented Nov 4, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@rewantsoni rewantsoni force-pushed the mirroring-rpc branch 3 times, most recently from 3a5aad6 to 4950f96 Compare November 6, 2024 06:38
@rewantsoni rewantsoni marked this pull request as ready for review November 6, 2024 06:39
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 6, 2024
@rewantsoni rewantsoni force-pushed the mirroring-rpc branch 7 times, most recently from f228a04 to e069e9a Compare November 11, 2024 16:09
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 11, 2024
services/provider/api/client/client.go Outdated Show resolved Hide resolved
services/provider/api/client/client.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
Copy link
Contributor

openshift-ci bot commented Nov 11, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rewantsoni
Once this PR has been reviewed and has the lgtm label, please ask for approval from nb-ohad. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 11, 2024
@rewantsoni rewantsoni force-pushed the mirroring-rpc branch 2 times, most recently from 8d7cbb8 to e250ada Compare November 12, 2024 10:23
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Outdated Show resolved Hide resolved
services/provider/server/server.go Show resolved Hide resolved
@@ -1042,3 +1043,130 @@ func (s *OCSProviderServer) PeerStorageCluster(ctx context.Context, req *pb.Peer

return &pb.PeerStorageClusterResponse{}, nil
}

func (s *OCSProviderServer) GetStorageClientsInfo(ctx context.Context, req *pb.StorageClientsInfoRequest) (*pb.StorageClientsInfoResponse, error) {
response := &pb.StorageClientsInfoResponse{ClientsInfo: []*pb.ClientInfo{}, Error: []*pb.StorageClientInfoError{}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client info is an array of pointers not a pointer of arrays, it will get allocated (at size 0) automatically

Suggested change
response := &pb.StorageClientsInfoResponse{ClientsInfo: []*pb.ClientInfo{}, Error: []*pb.StorageClientInfoError{}}
response := &pb.StorageClientsInfoResponse{}

@@ -1042,3 +1043,130 @@ func (s *OCSProviderServer) PeerStorageCluster(ctx context.Context, req *pb.Peer

return &pb.PeerStorageClusterResponse{}, nil
}

func (s *OCSProviderServer) GetStorageClientsInfo(ctx context.Context, req *pb.StorageClientsInfoRequest) (*pb.StorageClientsInfoResponse, error) {
response := &pb.StorageClientsInfoResponse{ClientsInfo: []*pb.ClientInfo{}, Error: []*pb.StorageClientInfoError{}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of Error is a list it should be called Errors

Comment on lines 1052 to 1153
if err != nil {
if !kerrors.IsNotFound(err) {
klog.Errorf("failed to get consumer with id %v: %v", req.ClientIDs[i], err)
response.Error = append(response.Error,
&pb.StorageClientInfoError{
ClientID: req.ClientIDs[i],
Code: pb.ErrorCode_Internal,
Message: err.Error(),
},
)
}
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to nest

Suggested change
if err != nil {
if !kerrors.IsNotFound(err) {
klog.Errorf("failed to get consumer with id %v: %v", req.ClientIDs[i], err)
response.Error = append(response.Error,
&pb.StorageClientInfoError{
ClientID: req.ClientIDs[i],
Code: pb.ErrorCode_Internal,
Message: err.Error(),
},
)
}
continue
}
if kerror.IsNotFound(err) {
continue
} else if err != nil {
klog.Errorf("failed to get consumer with id %v: %v", req.ClientIDs[i], err)
response.Error = append(response.Error,
&pb.StorageClientInfoError{
ClientID: req.ClientIDs[i],
Code: pb.ErrorCode_Internal,
Message: err.Error(),
},
)
}

continue
}
owner := util.FindOwnerRefByKind(consumer, "StorageCluster")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

},
)
}
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case we skip, it will be helpful to have a log message capturing it

response.Error = append(response.Error,
&pb.StorageClientInfoError{
ClientID: req.ClientIDs[i],
Code: pb.ErrorCode_Internal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use specific error codes and not generic ones

Code: pb.ErrorCode_Internal,
Message: "invalid number of radosnamespace found for the Client",
},
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a continue here (with a log message)

Comment on lines 1110 to 1203
} else if len(rnsList.Items) == 1 {
response.ClientsInfo = append(response.ClientsInfo, &pb.ClientInfo{ClientID: req.ClientIDs[i], RadosNamespace: rnsList.Items[0].Name})
} else {
response.ClientsInfo = append(response.ClientsInfo, &pb.ClientInfo{ClientID: req.ClientIDs[i]})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. There is no need to have 2 append statements
  2. You should treat the "good" case as a for loop scoped code
Suggested change
} else if len(rnsList.Items) == 1 {
response.ClientsInfo = append(response.ClientsInfo, &pb.ClientInfo{ClientID: req.ClientIDs[i], RadosNamespace: rnsList.Items[0].Name})
} else {
response.ClientsInfo = append(response.ClientsInfo, &pb.ClientInfo{ClientID: req.ClientIDs[i]})
}
}
clientInfo := pb.ClientInfo{ClientID: req.ClientIDs[i]
if len(len(rnsList.Items) != 0 {
clientInfo.RadosNamesapce = rnsList[0].Name
}
response.ClientsInfo = append(response.ClientsInfo, &clientInfo)

Comment on lines 1128 to 1230
if err != nil {
if !kerrors.IsNotFound(err) {
response.Error = append(response.Error,
&pb.BlockPoolInfoError{
BlockPoolName: cephBlockPool.Name,
Code: pb.ErrorCode_Internal,
Message: err.Error(),
},
)
}
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for nesting and please log a message into the log for a continue

cephBlockPool.Name,
err,
)
klog.Error(errMsg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not finding the secret should not be treated as an error from the perspective of the RPC call. It might be an error for a controller but not for the server

@rewantsoni rewantsoni force-pushed the mirroring-rpc branch 4 times, most recently from 6208c00 to 5a38c09 Compare November 13, 2024 17:59
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2024
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2024
@rewantsoni
Copy link
Member Author

/retest-required

1 similar comment
@rewantsoni
Copy link
Member Author

/retest-required

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2024
Signed-off-by: Rewant Soni <[email protected]>

add generated changes

Signed-off-by: Rewant Soni <[email protected]>
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants