-
Notifications
You must be signed in to change notification settings - Fork 184
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
base: main
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
3a5aad6
to
4950f96
Compare
f228a04
to
e069e9a
Compare
e069e9a
to
be79221
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rewantsoni 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 |
8d7cbb8
to
e250ada
Compare
e250ada
to
c85b0ad
Compare
services/provider/server/server.go
Outdated
@@ -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{}} |
There was a problem hiding this comment.
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
response := &pb.StorageClientsInfoResponse{ClientsInfo: []*pb.ClientInfo{}, Error: []*pb.StorageClientInfoError{}} | |
response := &pb.StorageClientsInfoResponse{} |
services/provider/server/server.go
Outdated
@@ -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{}} |
There was a problem hiding this comment.
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
services/provider/server/server.go
Outdated
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 | ||
} |
There was a problem hiding this comment.
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
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") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
services/provider/server/server.go
Outdated
}, | ||
) | ||
} | ||
continue |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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", | ||
}, | ||
) |
There was a problem hiding this comment.
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)
services/provider/server/server.go
Outdated
} 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]}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- There is no need to have 2 append statements
- You should treat the "good" case as a for loop scoped code
} 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) | |
services/provider/server/server.go
Outdated
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 | ||
} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
f25b323
to
6208c00
Compare
Signed-off-by: Rewant Soni <[email protected]>
Signed-off-by: Rewant Soni <[email protected]> add generated changes Signed-off-by: Rewant Soni <[email protected]>
6208c00
to
5a38c09
Compare
Signed-off-by: Rewant Soni <[email protected]>
5a38c09
to
064fb50
Compare
Add two rpc calls required for setting up mirroring for blockpool and radosnamespace