-
Notifications
You must be signed in to change notification settings - Fork 101
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
Added support to join external noobaa system from hosted clusters #1405
Conversation
pkg/noobaaaccount/reconciler.go
Outdated
nbremoteAuthToken := &corev1.Secret{} | ||
nbremoteAuthToken.Name = r.NooBaaAccount.Name | ||
nbremoteAuthToken.Namespace = r.NooBaaAccount.Namespace | ||
err = r.Client.Delete(r.Ctx, r.Secret) |
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.
If I'm not mistaken, R.Secret is deleted automtically, since it's owned by the noobaaAccount CR. I don't think that anything is changed in this PR with respect to deletion. Can you please verify it?
pkg/noobaaaccount/reconciler.go
Outdated
// create join secret conatining auth token for remote noobaa account | ||
annotationValue, exists := util.GetAnnotationValue(r.NooBaa.GetAnnotations(), "remote-operator") | ||
if exists { | ||
if strings.ToLower(annotationValue) != strconv.FormatBool(false) { |
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.
if strings.ToLower(annotationValue) != strconv.FormatBool(false) { | |
if strings.ToLower(annotationValue) == "true" { |
pkg/noobaaaccount/reconciler.go
Outdated
if err != nil { | ||
return fmt.Errorf("cannot create an auth token for remote operator, error: %v", err) | ||
} | ||
if res.Token == "" { |
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.
Is an empty token somthing that can be returned by noobaa-core in case there is no error? did you encounter this?
pkg/system/phase1_verifying.go
Outdated
annotationValue, exists := util.GetAnnotationValue(r.NooBaa.GetAnnotations(), "remote-client-noobaa") | ||
annotationBoolVal := true |
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.
I suggest giving clearer names to the variables. annotationVal
and annotationBoolVal
are too generic
pkg/system/phase1_verifying.go
Outdated
annotationValue, exists := util.GetAnnotationValue(r.NooBaa.GetAnnotations(), "remote-client-noobaa") | ||
annotationBoolVal := true | ||
if exists { | ||
annotationBoolVal = strings.ToLower(annotationValue) == strconv.FormatBool(true) |
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.
Again, unless I'm missing somthing, I don't see a reason to use strconv.FormatBool(true)
and not "true"
pkg/system/phase4_configuring.go
Outdated
annotationValue, exists := util.GetAnnotationValue(r.NooBaa.GetAnnotations(), "remote-client-noobaa") | ||
annotationBoolVal := true | ||
if exists { | ||
annotationBoolVal = strings.ToLower(annotationValue) == strconv.FormatBool(true) | ||
} | ||
if !exists || !annotationBoolVal { |
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 you repeat this code more than once, mayb extract this to a function isRemoteClientNoobaa
pkg/noobaaaccount/reconciler.go
Outdated
@@ -373,6 +388,33 @@ func (r *Reconciler) CreateNooBaaAccount() error { | |||
r.Logger.Errorf("got error on NooBaaAccount creation. error: %v", err) | |||
return err | |||
} | |||
// create join secret conatining auth token for remote noobaa account | |||
annotationValue, exists := util.GetAnnotationValue(r.NooBaa.GetAnnotations(), "remote-operator") |
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.
If the remote-operator
annotation exist, do you need to also create access keys (r.Secret
)?
Maybe just reuse the same r.Secret
and populate it with the relevant values according to the annotatioin?
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.
it's a valid point but since it was Kaustav's decision to use a new secret, i'm not sure what led to him creating a new secret.
Lets leave the new secret in place and when Kaustav returns from his leave we can change this. i'll open an issue for it as well (since changing it will most likely cause changes to code in other repos such as ocs-operator which uses this secret)
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.
I prefer to make the code simpler and not to create 2 secrets for a single noobaa account. I suggest that for now add an "auth_token"
key on r.Secret
. If there is a reason to create a separate secret than we can make this change later
pkg/noobaaaccount/reconciler.go
Outdated
nbremoteAuthToken.StringData["auth_token"] = res.Token | ||
r.Own(nbremoteAuthToken) | ||
|
||
err = r.Client.Create(r.Ctx, r.Secret) |
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.
did you mean to create nbremoteAuthToken
?
err = r.Client.Create(r.Ctx, r.Secret) | |
err = r.Client.Create(r.Ctx, nbremoteAuthToken) |
pkg/noobaaaccount/reconciler.go
Outdated
@@ -373,6 +388,33 @@ func (r *Reconciler) CreateNooBaaAccount() error { | |||
r.Logger.Errorf("got error on NooBaaAccount creation. error: %v", err) | |||
return err | |||
} | |||
// create join secret conatining auth token for remote noobaa account | |||
annotationValue, exists := util.GetAnnotationValue(r.NooBaa.GetAnnotations(), "remote-operator") |
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.
I prefer to make the code simpler and not to create 2 secrets for a single noobaa account. I suggest that for now add an "auth_token"
key on r.Secret
. If there is a reason to create a separate secret than we can make this change later
pkg/noobaaaccount/reconciler.go
Outdated
@@ -373,6 +375,30 @@ func (r *Reconciler) CreateNooBaaAccount() error { | |||
r.Logger.Errorf("got error on NooBaaAccount creation. error: %v", err) | |||
return err | |||
} | |||
// create join secret conatining auth token for remote noobaa account | |||
annotationValue, exists := util.GetAnnotationValue(r.NooBaa.GetAnnotations(), "remote-operator") |
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.
I see now that the annotation is on the noobaa CR and not the noobaaAccount CR. In that case, what's the difference between remote-operator
and MulticloudObjectGatewayProviderMode
?
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 remote-operator
is an annotation which is being added to the account CR by the ocs-operator while we are on the provider side in order to indicate when we onboard a new consumer and therefore need a new auth token to be added to the account. The MulticloudObjectGatewayProviderMode
annotation is being added to the Noobaa CR while we are running remotely and need to indicate that we only wish to deploy the operator and connect to a remote cluster.
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.
But here you check the annotaion on the noobaa CR and not the account CR (r.NooBaa.GetAnnotations()
)
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 are correct it's a mistake, will fix.
c3e5779
to
e02bf8c
Compare
@dannyzaken everything is done and tested can you please re-review |
pkg/util/util.go
Outdated
annotationValue, exists := GetAnnotationValue(annotations, "remote-client-noobaa") | ||
annotationBoolVal := false | ||
if exists { | ||
annotationBoolVal = strings.ToLower(annotationValue) == strconv.FormatBool(true) |
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.
trueStr
instead of strconv
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.
done
Signed-off-by: Kaustav Majumder <[email protected]>
i've rebased, can we merge? i dont have permissions to merge myself. @dannyzaken |
Explain the changes
Issues: Fixed #xxx / Gap #xxx
Testing Instructions: