Bug 1883422
| Summary: | operator-sdk cleanup fail after installing operator with "run bundle" without installmode and og with ownnamespace | ||
|---|---|---|---|
| Product: | OpenShift Container Platform | Reporter: | kuiwang |
| Component: | Operator SDK | Assignee: | Jesus M. Rodriguez <jesusr> |
| Status: | CLOSED ERRATA | QA Contact: | Fan Jia <jfan> |
| Severity: | low | Docs Contact: | |
| Priority: | medium | ||
| Version: | 4.6 | CC: | aos-bugs, bandrade, chuo, jesusr, jfan, jiazha, scolange, tbuskey |
| Target Milestone: | --- | ||
| Target Release: | 4.7.0 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: |
Cause:
`operator-sdk cleanup` command could not properly cleanup operators deployed with `operator-sdk run bundle`.
Consequence:
User would see an error message and operator would not be cleaned up. FATA[0000] Uninstall operator: delete customresourcedefinition "": resource name may not be empty
Fix:
Refactored operator-sdk cleanup code
Result:
Operators deployed with `run bundle` can now be properly cleaned up using `cleanup` command.
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-02-24 15:21:16 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
run bundle has been enabled in Operator SDK v1.1.0, please retest. Moving back to ON_QA tried v1.1.0, and still same issue.
So, change it back to ASSIGNED. Thanks to check it.
--
[root@preserve-olm-env operator-sdk-v11]# operator-sdk version
operator-sdk version: "v1.1.0-3-ge311086", commit: "e3110860a8b8681cb78ddb520f53c3eed104b28a", kubernetes version: "v1.18.8", go version: "go1.14 linux/amd64", GOOS: "linux", GOARCH: "amd64"
[root@preserve-olm-env operator-sdk-v11]# mkdir tmp
[root@preserve-olm-env operator-sdk-v11]# docker create quay.io/kuiwang/example-operator-bundle:0.2.0 bash
d178409606345df66e1dc544b8530a9130242801dd6b62c69cbc48be62f91fd2
[root@preserve-olm-env operator-sdk-v11]# ocker cp d178409606345df66e1dc544b8530a9130242801dd6b62c69cbc48be62f91fd2:/ ./tmp
-bash: ocker: command not found
[root@preserve-olm-env operator-sdk-v11]# docker cp d178409606345df66e1dc544b8530a9130242801dd6b62c69cbc48be62f91fd2:/ ./tmp
[root@preserve-olm-env operator-sdk-v11]# grep -A8 -i installmodes tmp/manifests/example-operator.clusterserviceversion.yaml
installModes:
- supported: true
type: OwnNamespace
- supported: true
type: SingleNamespace
- supported: false
type: MultiNamespace
- supported: false
type: AllNamespaces
[root@preserve-olm-env operator-sdk-v11]# oc get og
No resources found in default namespace.
[root@preserve-olm-env operator-sdk-v11]# operator-sdk run bundle quay.io/kuiwang/example-operator-bundle:0.2.0
INFO[0010] Successfully created registry pod: quay-io-kuiwang-example-operator-bundle-0-2-0
INFO[0010] Created CatalogSource: example-operator-catalog
INFO[0010] OperatorGroup "operator-sdk-og" created
INFO[0010] Created Subscription: example-operator-v0-1-0-sub
INFO[0015] Approved InstallPlan install-bq5pw for the Subscription: example-operator-v0-1-0-sub
INFO[0015] Waiting for ClusterServiceVersion "default/example-operator.v0.1.0" to reach 'Succeeded' phase
INFO[0016] Waiting for ClusterServiceVersion "default/example-operator.v0.1.0" to appear
INFO[0051] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Installing
INFO[0059] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Succeeded
INFO[0059] OLM has successfully installed "example-operator.v0.1.0"
[root@preserve-olm-env operator-sdk-v11]# docker rm d178409606345df66e1dc544b8530a9130242801dd6b62c69cbc48be62f91fd2
d178409606345df66e1dc544b8530a9130242801dd6b62c69cbc48be62f91fd2
[root@preserve-olm-env operator-sdk-v11]# operator-sdk cleanup example-operator
INFO[0000] subscription "example-operator-v0-1-0-sub" deleted
FATA[0000] Uninstall operator: delete customresourcedefinition "": resource name may not be empty
[root@preserve-olm-env operator-sdk-v11]# oc get crd apps.example.com -o yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
creationTimestamp: "2020-10-20T01:25:26Z"
generation: 1
labels:
operators.coreos.com/example-operator.default: ""
managedFields:
- apiVersion: apiextensions.k8s.io/v1beta1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:conversion:
.: {}
f:strategy: {}
f:group: {}
f:names:
f:kind: {}
f:listKind: {}
f:plural: {}
f:singular: {}
f:preserveUnknownFields: {}
f:scope: {}
f:subresources:
.: {}
f:status: {}
f:validation:
.: {}
f:openAPIV3Schema:
.: {}
f:description: {}
f:properties:
.: {}
f:apiVersion:
.: {}
f:description: {}
f:type: {}
f:kind:
.: {}
f:description: {}
f:type: {}
f:metadata:
.: {}
f:type: {}
f:spec:
.: {}
f:description: {}
f:type: {}
f:status:
.: {}
f:description: {}
f:type: {}
f:type: {}
f:version: {}
f:versions: {}
f:status:
f:storedVersions: {}
manager: catalog
operation: Update
time: "2020-10-20T01:25:26Z"
- apiVersion: apiextensions.k8s.io/v1
fieldsType: FieldsV1
fieldsV1:
f:status:
f:acceptedNames:
f:kind: {}
f:listKind: {}
f:plural: {}
f:singular: {}
f:conditions: {}
manager: kube-apiserver
operation: Update
time: "2020-10-20T01:25:26Z"
- apiVersion: apiextensions.k8s.io/v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:labels:
.: {}
f:operators.coreos.com/example-operator.default: {}
manager: olm
operation: Update
time: "2020-10-20T01:25:28Z"
name: apps.example.com
resourceVersion: "67022"
selfLink: /apis/apiextensions.k8s.io/v1/customresourcedefinitions/apps.example.com
uid: 587bb8f2-559b-4ea6-8afb-84994fdd037a
spec:
conversion:
strategy: None
group: example.com
names:
kind: App
listKind: AppList
plural: apps
singular: app
preserveUnknownFields: true
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: App is the Schema for the apps API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: AppSpec defines the desired state of App
type: object
status:
description: AppStatus defines the observed state of App
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: App
listKind: AppList
plural: apps
singular: app
conditions:
- lastTransitionTime: "2020-10-20T01:25:26Z"
message: no conflicts found
reason: NoConflicts
status: "True"
type: NamesAccepted
- lastTransitionTime: "2020-10-20T01:25:26Z"
message: the initial names have been accepted
reason: InitialNamesAccepted
status: "True"
type: Established
storedVersions:
- v1
[root@preserve-olm-env operator-sdk-v11]# oc get clusterversion
NAME VERSION AVAILABLE PROGRESSING SINCE STATUS
version 4.6.0-0.nightly-2020-10-17-040148 True False 113m Cluster version is 4.6.0-0.nightly-2020-10-17-040148
--
Fixed in operator-sdk:master. PR https://github.com/operator-framework/operator-sdk/pull/4233 test env: operator-sdk version:operator-sdk version: "v1.2.0-20-g7e490b45", commit: "7e490b45c4c3def36a00c3d96e4cfc57d4e3b378", kubernetes version: "v1.18.8", go version: "go1.15.5", GOOS: "linux", GOARCH: "amd64" cluster:4.7.0-0.nightly-2020-11-30-172451 test result: #operator-sdk run bundle quay.io/kuiwang/example-operator-bundle:0.2.0 INFO[0055] Successfully created registry pod: quay-io-kuiwang-example-operator-bundle-0-2-0 INFO[0056] Created CatalogSource: example-operator-catalog INFO[0056] OperatorGroup "operator-sdk-og" created INFO[0058] Created Subscription: example-operator-v0-1-0-sub INFO[0060] Approved InstallPlan install-bjpqs for the Subscription: example-operator-v0-1-0-sub INFO[0063] Waiting for ClusterServiceVersion "default/example-operator.v0.1.0" to reach 'Succeeded' phase INFO[0063] Waiting for ClusterServiceVersion "default/example-operator.v0.1.0" to appear INFO[0100] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Pending INFO[0101] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Installing INFO[0114] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Succeeded INFO[0114] OLM has successfully installed "example-operator.v0.1.0" # operator-sdk cleanup example-operator INFO[0004] subscription "example-operator-v0-1-0-sub" deleted INFO[0004] customresourcedefinition "apps.example.com" deleted INFO[0005] clusterserviceversion "example-operator.v0.1.0" deleted INFO[0006] "example-operator-catalog" deleted INFO[0007] operatorgroup "operator-sdk-og" deleted INFO[0007] Operator "example-operator" uninstalled the operator can be installed and cleaned success Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: OpenShift Container Platform 4.7.0 security, bug fix, and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2020:5633 |
Description of problem: without WA, we build operator-sdk to support "run bundle". here is the WA: modify cmd.go and build it -- [root@preserve-olm-env operator-sdk]# git diff diff --git a/internal/cmd/operator-sdk/run/cmd.go b/internal/cmd/operator-sdk/run/cmd.go index 5fb87cd..bc629a3 100644 --- a/internal/cmd/operator-sdk/run/cmd.go +++ b/internal/cmd/operator-sdk/run/cmd.go @@ -17,6 +17,7 @@ package run import ( "github.com/spf13/cobra" + "github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/run/bundle" "github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/run/packagemanifests" "github.com/operator-framework/operator-sdk/internal/olm/operator" ) @@ -34,7 +35,7 @@ Currently only the package manifests format is supported via the 'packagemanifes cmd.AddCommand( // TODO(joelanford): enable bundle command when implementation is complete - // bundle.NewCmd(cfg), + bundle.NewCmd(cfg), packagemanifests.NewCmd(cfg), ) -- we install operator via "run bundle" without og existing and without install mode, and the bundle only support singlenamespace and ownnamespace. the install succeed. but cleanup fail. -- [root@preserve-olm-env OCP-35443]# operator-sdk cleanup example-operator INFO[0000] subscription "example-operator-v0-1-0-sub" deleted FATA[0000] Uninstall operator: delete customresourcedefinition "": resource name may not be empty -- Version-Release number of selected component (if applicable): [root@preserve-olm-env OCP-35443]# operator-sdk version operator-sdk version: "v1.0.0-98-g5754121-dirty", commit: "575412115cd60452f0ee4d2abd04eab76f46741e", kubernetes version: "v1.18.2", go version: "go1.14 linux/amd64", GOOS: "linux", GOARCH: "amd64" How reproducible: always Steps to Reproduce: -- [root@preserve-olm-env OCP-35443]# mkdir tmp [root@preserve-olm-env OCP-35443]# docker create quay.io/kuiwang/example-operator-bundle:0.2.0 bash c65e9c66af38bbc6db47a2d596dcc5f34318081d33bd63ee3b6e97a783757e7b [root@preserve-olm-env OCP-35443]# docker cp c65e9c66af38bbc6db47a2d596dcc5f34318081d33bd63ee3b6e97a783757e7b:/ ./tmp [root@preserve-olm-env OCP-35443]# grep -A8 -i installmodes tmp/manifests/example-operator.clusterserviceversion.yaml installModes: - supported: true type: OwnNamespace - supported: true type: SingleNamespace - supported: false type: MultiNamespace - supported: false type: AllNamespaces [root@preserve-olm-env OCP-35443]# oc get og No resources found in default namespace. [root@preserve-olm-env OCP-35443]# operator-sdk run bundle quay.io/kuiwang/example-operator-bundle:0.2.0 INFO[0005] Successfully created registry pod: quay-io-kuiwang-example-operator-bundle-0-2-0 INFO[0005] Created CatalogSource: example-operator-catalog INFO[0005] OperatorGroup "operator-sdk-og" created INFO[0005] Created Subscription: example-operator-v0-1-0-sub INFO[0008] Approved InstallPlan install-nstld for the Subscription: example-operator-v0-1-0-sub INFO[0008] Waiting for ClusterServiceVersion "default/example-operator.v0.1.0" to reach 'Succeeded' phase INFO[0008] Waiting for ClusterServiceVersion "default/example-operator.v0.1.0" to appear INFO[0015] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Pending INFO[0016] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Installing INFO[0020] Found ClusterServiceVersion "default/example-operator.v0.1.0" phase: Succeeded INFO[0020] OLM has successfully installed "example-operator.v0.1.0" [root@preserve-olm-env OCP-35443]# operator-sdk cleanup example-operator INFO[0000] subscription "example-operator-v0-1-0-sub" deleted FATA[0000] Uninstall operator: delete customresourcedefinition "": resource name may not be empty [root@preserve-olm-env OCP-35443]# oc get crd apps.example.com -o yaml apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: creationTimestamp: "2020-09-29T06:41:26Z" generation: 1 labels: operators.coreos.com/example-operator.default: "" ... spec: conversion: strategy: None group: example.com names: kind: App listKind: AppList plural: apps singular: app preserveUnknownFields: true scope: Namespaced versions: - name: v1 schema: openAPIV3Schema: description: App is the Schema for the apps API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: description: AppSpec defines the desired state of App type: object status: description: AppStatus defines the observed state of App type: object type: object served: true storage: true subresources: status: {} status: acceptedNames: kind: App listKind: AppList plural: apps singular: app conditions: - lastTransitionTime: "2020-09-29T06:41:26Z" message: no conflicts found reason: NoConflicts status: "True" type: NamesAccepted - lastTransitionTime: "2020-09-29T06:41:26Z" message: the initial names have been accepted reason: InitialNamesAccepted status: "True" type: Established storedVersions: - v1 -- Actual results: donot cleanup succeesfully Expected results: can cleanup successfully Additional info: