-
Notifications
You must be signed in to change notification settings - Fork 185
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
onboard a client onto already created storageconsumer based on token #3075
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Leela Venkaiah G <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: leelavg 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 |
Signed-off-by: Leela Venkaiah G <[email protected]>
// get the consumer corresponding to this ticket | ||
storageConsumerList := &ocsv1alpha1.StorageConsumerList{} | ||
if err := s.client.List(ctx, storageConsumerList, client.InNamespace(s.namespace)); err != nil { | ||
klog.Errorf("failed to get storageconsumers in the namespace: %v", err) | ||
return nil, status.Errorf(codes.Internal, "failed to get storageconsumers. %v", err) | ||
} else if len(storageConsumerList.Items) < 1 { | ||
return nil, status.Errorf(codes.FailedPrecondition, "no storageconsumers exist in the namespace") | ||
} | ||
|
||
consumerName := "" | ||
for idx := range storageConsumerList.Items { |
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.
Instead of fetching each consumer, getting the secret attached and comparing the onboarding ticket in the secret, why not add the consumer name to the onboarding ticket struct?
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.
we could do that after a small discussion as it implies the token will be applicable only to the specific storageconsumer.
@@ -135,11 +139,50 @@ func (r *StorageConsumerReconciler) initReconciler(request reconcile.Request) { | |||
|
|||
func (r *StorageConsumerReconciler) reconcilePhases() (reconcile.Result, error) { | |||
|
|||
secret := &corev1.Secret{} | |||
secret.Name = r.storageConsumer.Name |
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.
Should we add an annotation to storageConsumer that points to the onboarding ticket secret for that conusmer?
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.
the intention was to have the same name for consumer & secret, didn't get your suggestion.
err = fmt.Errorf("storageconsumers.ocs.openshift.io %s already exists", storageConsumer.Name) | ||
return nil, status.Errorf(codes.AlreadyExists, "failed to onboard on storageConsumer resources. %v", err) |
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.
Since we are not creating the consumer anymore in this rpc, could we update the err message to be something more meaningful like "storageconsumer already has a client attached to it"?
storageconsumer controllers creates a secret for user to be mentioned in storageclient for onboarding onto that specific storageconsumer. Until the storageconsumer is enabled, deletion of secret is considered as rotation of token.
Onboarding adds the supplied ticket to the storageconsumer as annotation as the linking b/n the storageclient to storageconsumer.