Skip to content

Code for extension install and delete #228

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

Merged

Conversation

LalatenduMohanty
Copy link
Member

@LalatenduMohanty LalatenduMohanty commented Mar 19, 2025

Here are the commands to test the PR. I used https://github.com/operator-framework/operator-controller/blob/main/config/samples/olm_v1_clusterextension.yaml to create the service-account etc

$ kubectl operator olmv1 install extension argocd --package-name argocd-operator --version 0.6.0 --namespace argocd --service-account argocd-installer
extension "argocd" created
$ kubectl operator olmv1 get extension
NAME    INSTALLED BUNDLE        VERSION  SOURCE TYPE  INSTALLED  PROGRESSING  AGE
argocd  argocd-operator.v0.6.0  0.6.0    Catalog      True       True         65s
$ kubectl operator olmv1 delete extension argocd
deleted extension "argocd"

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 19, 2025
@openshift-ci openshift-ci bot requested review from benluddy and joelanford March 19, 2025 04:03
@LalatenduMohanty LalatenduMohanty force-pushed the install_uninstall branch 2 times, most recently from e5dd128 to b987def Compare March 19, 2025 13:47
@LalatenduMohanty LalatenduMohanty force-pushed the install_uninstall branch 2 times, most recently from 09bb547 to f4a9fed Compare March 28, 2025 13:18
@LalatenduMohanty
Copy link
Member Author

As discussed with @joelanford and @ankitathomas, not adding the code for CatalogSelector in this PR, we can add this as a follow up.

@LalatenduMohanty LalatenduMohanty force-pushed the install_uninstall branch 3 times, most recently from e0e98ef to f73b91f Compare March 28, 2025 17:52
@LalatenduMohanty LalatenduMohanty changed the title [WIP] Code for extension install and delete Code for extension install and delete Mar 31, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 31, 2025
Copy link

@anik120 anik120 left a comment

Choose a reason for hiding this comment

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

Looking good mostly @LalatenduMohanty 🎉

@anik120
Copy link

anik120 commented Mar 31, 2025

As discussed with @joelanford and @ankitathomas, not adding the code for CatalogSelector in this PR, we can add this as a follow up.

By CatalogSelector do you mean source.catalog

Looks like,

  source is a required field which selects the installation source of content
  for this ClusterExtension. Selection is performed by setting the sourceType.

  Catalog is currently the only implemented sourceType, and setting the
  sourcetype to "Catalog" requires the catalog field to also be defined.

will the install command work without this?

Copy link
Contributor

@ankitathomas ankitathomas left a comment

Choose a reason for hiding this comment

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

/lgtm

fs.StringSliceVarP(&i.Channels, "channels", "c", []string{}, "channels which would be to used for getting updates e.g --channels \"stable,dev-preview,preview\"")
fs.StringVarP(&i.Version, "version", "v", "", "version (or version range) from which to resolve bundles")
fs.StringVarP(&i.ServiceAccount, "service-account", "s", "default", "service account name to use for the extension installation")
fs.DurationVarP(&i.CleanupTimeout, "cleanup-timeout", "d", time.Minute, "the amount of time to wait before cancelling cleanup after a failed creation attempt")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a replacement for the global timeout flag?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I continued the catalog create code pattern. Currently the OLMv1 code do not use https://github.com/operator-framework/kubectl-operator/blob/main/internal/cmd/root.go#L36-#L38 global timeout.

for _, extension := range extensionList.Items {
names = append(names, extension.Name)
if _, err := u.deleteExtension(ctx, extension.Name); err != nil {
errs = append(errs, fmt.Errorf("failed deleting extension %q: %w", extension.Name, err))
Copy link
Contributor

Choose a reason for hiding this comment

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

Standard kubectl behavior is to treat deleting non-existent resources as a failed operation, except for delete --all. That being said, I'm fine with this to maintain consistency with the current implementation of catalog delete.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I am fine with either way. The catalog and extension create/install uses the same pattern now.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 31, 2025
@LalatenduMohanty
Copy link
Member Author

By CatalogSelector do you mean source.catalog

Nope, I am talking about Selector *metav1.LabelSelector in https://github.com/operator-framework/operator-controller/blob/main/api/v1/clusterextension_types.go#L304

// selector is an optional field that can be used
	// to filter the set of ClusterCatalogs used in the bundle
	// selection process.
	//
	// When unspecified, all ClusterCatalogs will be used in
	// the bundle selection process.
	//
	// +optional
	Selector *metav1.LabelSelector `json:"selector,omitempty"`
// There are two different styles of label selectors used in versioned types:
// an older style which is represented as just a string in versioned types, and a
// newer style that is structured.  LabelSelector is an internal representation for the
// latter style.
// A label selector is a label query over a set of resources. The result of matchLabels and
// matchExpressions are ANDed. An empty label selector matches all objects. A null
// label selector matches no objects.
// +structType=atomic
type LabelSelector struct {
	// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
	// map is equivalent to 
an element of matchExpressions, whose key field is "key", the
	// operator is "In", and the values array contains only "value". The requirements are ANDed.
	// +optional
	MatchLabels map[string]string `json:"matchLabels,omitempty" protobuf:"bytes,1,rep,name=matchLabels"`
	// matchExpressions is a list of label selector requirements. The requirements are ANDed.
	// +optional
	// +listType=atomic
	MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty" protobuf:"bytes,2,rep,name=matchExpressions"`
}
///

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 3, 2025
Signed-off-by: Lalatendu Mohanty <[email protected]>
Copy link
Contributor

@ankitathomas ankitathomas 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 openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 22, 2025
@ankitathomas ankitathomas added this pull request to the merge queue Apr 22, 2025
Merged via the queue into operator-framework:main with commit ec84fc0 Apr 22, 2025
4 checks passed
@ankitathomas ankitathomas deleted the install_uninstall branch April 22, 2025 05:55
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.

3 participants