Added support to join external noobaa system from hosted clusters#1405
Added support to join external noobaa system from hosted clusters#1405liranmauda merged 1 commit intonoobaa:masterfrom
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.
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.
| 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.
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.
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.
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.
since you repeat this code more than once, mayb extract this to a function isRemoteClientNoobaa
pkg/noobaaaccount/reconciler.go
Outdated
| 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.
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.
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.
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.
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
| 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.
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
| 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.
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.
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.
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.
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) |
Signed-off-by: Kaustav Majumder <kaustav.majumder@ibm.com>
|
i've rebased, can we merge? i dont have permissions to merge myself. @dannyzaken |
Explain the changes
Issues: Fixed #xxx / Gap #xxx
Testing Instructions: