-
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
Reverts deprecated ClusterClaims for odf-info #2686
Conversation
Skipping CI for Draft Pull Request. |
3f248ba
to
b29856a
Compare
client, err := clusterclientv1alpha1.NewForConfig(kubeconfig) | ||
if err != nil { | ||
creator.Logger.Error(err, "Failed to create ClusterClaim client.") | ||
return reconcile.Result{}, 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.
Is there really a need to create a new non-cached client? Why can't we use the client which is already installed on the reconciler object?
As a general note, we should only use non-cached clients in cases where there is underlying reason to do so.
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.
@raaizik Why does the claim need to be removed manually ? Can we not set it to be removed alongside 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.
Can we add another claim which will indicate which clusters are client and provider for the UI ?
@vbnrh This would break the concept of the odf-info CM which is supposed to be a replacement for cluster claims (other than the one that's added here, which I'd classify as the CM's metadata). What is an option is to add this to the CM itself. |
@vbnrh The cluster claims used to be reconciled via storage cluster because they contained information about it. This is no longer the case, plus the cluster claim needs to be coupled with the operator's lifecycle where it is created once and removed manually (since there's no uninstall for OCSInit). |
If the StorageCluster is uninstalled at a later point of time, the CM will still be present on the hub. How are we going to indicate that cluster is not available for RDR on hub ? Are we planning or have we added the StorageCluster's status on the CM ? |
@vbnrh Whenever a StorageCluster is uninstalled, its respective key in the CM gets removed. If that key was the last one to get uninstalled, then the whole CM gets removed. |
@vbnrh The responsibility of the claim is to broadcast (to ACM) the existence of the configmap not the existence of a specific storage cluster. The existence, state, and info of the various storage clusters can be found as part of the config map data (which will be available on the ACM hub) As @raaizik already mentioned, when a storage cluster is deleted the config map is updated to remove all information related to that storage cluster from the config map, and that change will be synced back to the hub So as you know, clients are not standalone entities, and the information about them is specified under the storage cluster that supports them. We don't need to have a separate claim for them. |
/retest |
creator := ClusterClaimCreator{ | ||
Logger: r.Log, | ||
Context: ctx, | ||
Client: r.Client, | ||
OcsInit: instance, | ||
} | ||
|
||
operatorNamespace, err := creator.getOperatorNamespace() | ||
if err != nil { | ||
r.Log.Error(err, "failed to get operator's namespace. retrying again") | ||
return reconcile.Result{}, 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.
No need of this. Simply fetch the operator namespace and proceed. This pattern was used earlier when there were a lot of things to fetch and create.
clusterClaimCrdPredicate := predicate.Funcs{ | ||
CreateFunc: func(e event.TypedCreateEvent[client.Object]) bool { | ||
panic("ClusterClaim CRD was found. Restarting pod to initiate creation") | ||
}, | ||
DeleteFunc: func(e event.TypedDeleteEvent[client.Object]) bool { | ||
panic("ClusterClaim CRD was found. Restarting pod to initiate deletion") | ||
}, | ||
} |
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'd like to avoid setting panic to restart the process as much as possible. There are ways to set watches dynamically, we should try those first.
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.
@umangachapagain They don't work because they do not re-popolate the cache. The only reliable way we found was to panic out.
@raaizik I would not use panic, I will use os.exit
with a specific code. That way we can warp the operator invocation with a small bash command that invokes the operator process if it sees that particular exit code.
Doing it that way will prevent unnecessary pos restarts
@@ -74,6 +77,7 @@ type OCSInitializationReconciler struct { | |||
// +kubebuilder:rbac:groups="monitoring.coreos.com",resources={alertmanagers,prometheuses},verbs=get;list;watch;create;update;patch;delete | |||
// +kubebuilder:rbac:groups="monitoring.coreos.com",resources=servicemonitors,verbs=get;list;watch;update;patch;create;delete | |||
// +kubebuilder:rbac:groups=operators.coreos.com,resources=clusterserviceversions,verbs=get;list;watch;delete;update;patch | |||
// +kubebuilder:rbac:groups=cluster.open-cluster-management.io,resources=clusterclaims,verbs=get;list;watch;create;update;delete |
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 deleting clusterclaims, can we remove the rbac for it?
clusterClaim := &ocsClusterClaim{} | ||
reconcileResult, err := clusterClaim.ensureCreated(r, instance) | ||
if err != nil { | ||
r.Log.Error(err, "Failed to ensure odf-info namespacedname ClusterClaim") | ||
return reconcileResult, 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.
We don't need to use this pattern. We can just create a "ensureClusteClaimExists" function and call it directly.
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 intent is to make sure it exists, we can have an IsClusterClaimExist
function that returns a bool.
Using an error to indicate a valid result (does not exists) is a semantic mistake
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.
IsClusterClaimExist
is a check that returns True
or False
. What we want is to take action to EnsureClusterClaimExists
and return an error if failed. That is semantically correct.
func ensureClusterClaimExists() error {
if IsClusterClaimExist(){
return nil
}
err := create.clusterclaim()
return err
}
1ea2463
to
b6bd338
Compare
/retest |
|
/test ocs-operator-bundle-e2e-aws |
8ca0b49
to
8a0dc2f
Compare
2181505
to
a118a4a
Compare
Signed-off-by: raaizik <[email protected]>
LGTM |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: raaizik, umangachapagain The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
bedc58d
into
red-hat-storage:main
/cherry-pick release-4.17 |
@rewantsoni: new pull request created: #2742 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Changes
ClusterClaim
that stores the NamespacedName of the odf-info CM so that MCO will be able to fetch it.TODO
ClusterClaim
to be reconciled inOCSInitialization