Skip to content

[run bundle] Install plan generation and approval for subscription#3838

Merged
rashmigottipati merged 1 commit intooperator-framework:masterfrom
rashmigottipati:install-plan-for-run-bundle
Sep 2, 2020
Merged

[run bundle] Install plan generation and approval for subscription#3838
rashmigottipati merged 1 commit intooperator-framework:masterfrom
rashmigottipati:install-plan-for-run-bundle

Conversation

@rashmigottipati
Copy link
Copy Markdown
Member

Description of the change:

  • Change subscription approval to manual
  • Verify install plan generation for the subscription
  • Approve install plan for CSV generation

Motivation for the change:

  • We don't want the subscription approval to be automatic and would want to change the approval to manual and be able to approve the install plan that's generated for that subscription which enables us to install and deploy the operator version we intend to run

/cc @joelanford @jmrodri @estroz @bharathi-tenneti

withPackageChannel(o.PackageName, o.Channel, o.StartingCSV),
withCatalogSource(cs.GetName(), o.cfg.Namespace))
withCatalogSource(cs.GetName(), o.cfg.Namespace),
withInstallPlanApproval(v1alpha1.ApprovalManual))
Copy link
Copy Markdown
Member

@estroz estroz Sep 2, 2020

Choose a reason for hiding this comment

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

I'm not sure if CI will pass because InstallPlans created by run packagemanifests will not be approved. IIRC we discussed that automatic approval is a bug in run packagemanifests since a version is specified but that version might not be the channel head specified in a Subscription, and setting approval to manual is correct for both the index and configmap CatalogCreator's; we would need to approve all Subscriptions manually with this change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After the catalog source is created, the logic should be identical between run packagemanifests and run bundle.

We shouldn't have different implementations of the InstallPlanApprover interface (and we probably don't need that interface at all).

Comment on lines 89 to 91
if approver, ok := o.CatalogCreator.(InstallPlanApprover); ok {
if err = approver.Approve(ctx, o.PackageName); err != nil {
if err = approver.Approve(ctx, subscription); err != nil {
return nil, err
}
}
Copy link
Copy Markdown
Member

@joelanford joelanford Sep 2, 2020

Choose a reason for hiding this comment

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

Why is the CatalogCreator involved with approving install plans?

It doesn't seem like we need different implementations between run packagemanifests and run bundle. In both cases, we should create the subscription with manual approval and then immediately approve the install plan for that CSV.


// Approve approves the install plan for a subscription, which will
// generate a CSV
func (c IndexImageCatalogCreator) Approve(ctx context.Context, sub *v1alpha1.Subscription) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Going along with my other comments, I think this function should be moved to the OperatorInstaller struct and renamed to approveInstallPlan.

The way the catalog source gets created is decoupled from he creation of the subscription and install plans, so we don't need separate approval logic.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated the PR to remove the interface and make approveInstallPlan a method on OperatorInstaller struct, which will be common across both run packagemanifests and run bundle

Thanks so much for the feedback @joelanford @estroz, please review new changes

Copy link
Copy Markdown
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

Just a nit and potential follow-up.

/lgtm

Comment thread internal/olm/operator/registry/olm_resources.go Outdated
return fmt.Errorf("install plan is not available for the subscription %s: %v", sub.Name, err)
}
return nil
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-blocking: In one of these install plan functions, do we need to do a sanity check and ensure the install plan is for the CSV that we created in the subscription.

In the case of an upgrade being available, there can be multiple install plans and I think the subscription may reference the next available.

It may not be strictly necessary based in this case since we would need to approve the initial install plan to do the initial install and let OLM get to the point of doing an upgrade, BUT if it's a simple extra sanity check, it may be a good idea to go ahead and add.

Copy link
Copy Markdown
Member Author

@rashmigottipati rashmigottipati Sep 2, 2020

Choose a reason for hiding this comment

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

Great idea! I guess we can add the below check:

if ip.Status.Plan != nil {
		for _, installPlan := range ip.Status.Plan {
			if installPlan.Resource.Kind == "ClusterServiceVersion" {
				if installPlan.Resolving != sub.Status.CurrentCSV {
					return fmt.Errorf("install plan CSV doesn't match the CSV in the subscription")
				}
			}
		}
	}

I will do this in a follow-up as this is non-blocking.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 2, 2020
@rashmigottipati rashmigottipati force-pushed the install-plan-for-run-bundle branch from 06d7d0b to 912d9ce Compare September 2, 2020 22:18
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 2, 2020
Copy link
Copy Markdown
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 2, 2020
@rashmigottipati rashmigottipati merged commit 312a6dd into operator-framework:master Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants