-
Notifications
You must be signed in to change notification settings - Fork 58
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
controllers: Ensure console plugin creation after CSV verification #511
base: main
Are you sure you want to change the base?
Conversation
err := mgr.Add(manager.RunnableFunc(func(context.Context) error { | ||
clusterVersion, err := util.DetermineOpenShiftVersion(r.Client) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return r.ensureConsolePlugin(clusterVersion) | ||
})) | ||
if err != nil { | ||
return 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.
@bipuladh u remember why this custom runnable was added ?? Removing it seems reasonable, but double checking.
53d1354
to
38ad0b1
Compare
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.
pls recheck if exporting all methods is not necessary.
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
pkg/util/readiness.go
Outdated
for _, csv := range csvList.Items { | ||
if csv.Name == name { | ||
return &csv, 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.
pls query by index, here there is a creation of new var and it creates many not required values escaping the function scope.
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
return ctrl.Result{}, err | ||
} | ||
|
||
if err := util.EnsureCSVsPresent(ctx, r.Client, r.OperatorNamespace, EssentialCSVs...); err != nil { |
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 this is all we want, why to continue to use readiness probe involving a hack?
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 need both of these. The readiness probe will stop the customer from creating the storage cluster. Creating the console plugin later will show the popup once everything is ready.
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.
from creating the storage cluster.
- from CLI? ack.
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 will stop on the UI. We can not stop on the CLI and we are not concerned about the CLI.
|
||
if err := util.EnsureCSVsPresent(ctx, r.Client, r.OperatorNamespace, EssentialCSVs...); err != nil { | ||
logger.Error(err, "Could not ensure CSVs in Succeeded state") | ||
return ctrl.Result{Requeue: true, RequeueAfter: time.Second * 2}, nil |
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.
2 sec is demanding, the observed time was 60s in total and 10s interval will be relaxing. (or) remove the time and add a csv predicate creation event w/ essential CSVs.
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 don't want to add long intervals, Adding a longer interval can delay the creation of the web console, which means a delay in the installation. Also, this will happen only when there is an installation or upgrade. It reminds me to handle the upgrade case.
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 don't want to add long intervals,
- not sure for what qualifies as longer or shorter interval in a reconciliation and so dropping my comment.
|
||
odfDepsSub := GetStorageClusterSubscriptions()[0] | ||
|
||
if odfDepsSub.Spec.Package != OdfDepsSubscriptionPackage { | ||
panic("odfDepsSub variable is expected to contain the 'odf-dependencies' subscription. " + | ||
"Ensure the 'odf-dependencies' subscription indexed at 0.") | ||
} | ||
|
||
return EnsureDesiredSubscription(r.Client, odfDepsSub) | ||
|
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.
pls remove extra lines, all actions seems to be a single unit.
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
@@ -290,6 +291,22 @@ func (r *SubscriptionReconciler) SetupWithManager(mgr ctrl.Manager) error { | |||
}, | |||
) | |||
|
|||
err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error { |
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.
may I know what's the expectation w/ runnablefunc?
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.
This will invoke the function as soon as the manager starts. It means it will create this sub even before reconciles are started.
panic("odfDepsSub variable is expected to contain the 'odf-dependencies' subscription. " + | ||
"Ensure the 'odf-dependencies' subscription indexed at 0.") |
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.
who needs to ensure this? if this is static at build time why not move this to main? may I know what's the requirement? why can't we make an arrangement for caller to explicitly get deps subscription and then the remaining?
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 developer needs to ensure this while coding. I added a panic so that we can catch this while testing. Maybe I can create a unit test to ensure this. This is not a build time. It is introduced at a coding time.
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.
coding time.
- I do mean the same, static at/by build time. Unit test would suffice, ack.
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
Delay the creation of the console plugin until after verifying that the required CSVs are present. This ensures the necessary CRDs are present in the cluster, preventing UI errors like "Model does not exist." Signed-off-by: Nitin Goyal <[email protected]>
creating odf-deps subscription while starting manager will speed up the process. Signed-off-by: Nitin Goyal <[email protected]>
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.
/hold
Unhold if no one else is going to review. Thanks.
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.
Looks good to me.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bipuladh, iamniting, leelavg 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 |
// Check if it is upgrade from 4.17 to 4.18 | ||
// The new CSVs won't exists while upgrading | ||
// They will exists only after new operator has created a new subscription | ||
if !util.AreMultipleOdfOperatorCsvsPresent(csvList) { |
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.
just a general comment/doubt (no need to change the current implementation):
this controller will only run when either OCP is upgraded (i.e., For(&configv1.ClusterVersion{})) or when controller will restart after ODF is upgraded (in which case new CSVs will be existing soon)... we don't really need !util.AreMultipleOdfOperatorCsvsPresent(csvList)
check, right ?? or am I missing any case ??
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.
This check is to make sure that we don't block the reconcile in case of upgrades. For example assume customers has messed up the catalog for some reason in that case only odf will be upgraded and other operators wont be upgraded. So we should not block the console updation in that case right?
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.
So we should not block the console updation in that case right?
make sense.
For example assume customers has messed up the catalog for some reason in that case only odf will be upgraded and other operators wont be upgraded.
If ODF is upgraded and others won't, then we are still blocked right ?? because !util.AreMultipleOdfOperatorCsvsPresent(csvList)
will be true
in that case.
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.
Yes, that's right, It will skip if and only if the odf-operator upgrade is in progress.
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.
actually that was my initial doubt, why would this controller run at all when ODF upgrade is in progress: #511 (comment)
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.
Once the manager is started, The controllers will also get triggered.
I have added this check to keep the behavior as before and that is once the odf-operator is upgraded, I also upgrade the console plugin.
Delay the creation of the console plugin until after verifying that the required CSVs are present. This ensures the necessary CRDs are present in the cluster, preventing UI errors like "Model does not exist."
Signed-off-by: Nitin Goyal [email protected]