Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

iamniting
Copy link
Member

@iamniting iamniting commented Nov 21, 2024

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]

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 21, 2024
Comment on lines 71 to 82
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
}

Copy link
Contributor

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.

@iamniting iamniting force-pushed the ui branch 3 times, most recently from 53d1354 to 38ad0b1 Compare November 27, 2024 14:20
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 98 to 82
for _, csv := range csvList.Items {
if csv.Name == name {
return &csv, true
}
}
Copy link
Contributor

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.

Copy link
Member Author

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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

@iamniting iamniting Dec 4, 2024

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
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Comment on lines 295 to 304

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)

Copy link
Contributor

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.

Copy link
Member Author

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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Comment on lines 299 to 300
panic("odfDepsSub variable is expected to contain the 'odf-dependencies' subscription. " +
"Ensure the 'odf-dependencies' subscription indexed at 0.")
Copy link
Contributor

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?

Copy link
Member Author

@iamniting iamniting Nov 28, 2024

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.

Copy link
Contributor

@leelavg leelavg Nov 28, 2024

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.

Copy link
Member Author

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]>
Copy link
Contributor

@leelavg leelavg left a 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.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2024
Copy link
Contributor

@bipuladh bipuladh left a 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.

Copy link
Contributor

openshift-ci bot commented Dec 9, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Comment on lines +74 to +77
// 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) {
Copy link
Contributor

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 ??

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

@iamniting iamniting Dec 9, 2024

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.

Copy link
Contributor

@SanjalKatiyar SanjalKatiyar Dec 9, 2024

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)

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants