From 52b7626515468b615186ef5a9142f12d33b7a596 Mon Sep 17 00:00:00 2001 From: Todd Short Date: Wed, 17 May 2023 10:48:56 -0400 Subject: [PATCH] Remove TypeReady Condition Fixes #201 Signed-off-by: Todd Short --- api/v1alpha1/operator_types.go | 2 - controllers/operator_controller.go | 82 +-------------- controllers/operator_controller_test.go | 133 ++++-------------------- test/e2e/install_test.go | 9 +- 4 files changed, 23 insertions(+), 203 deletions(-) diff --git a/api/v1alpha1/operator_types.go b/api/v1alpha1/operator_types.go index 6c66a481f..79cfea875 100644 --- a/api/v1alpha1/operator_types.go +++ b/api/v1alpha1/operator_types.go @@ -46,7 +46,6 @@ type OperatorSpec struct { const ( // TODO(user): add more Types, here and into init() - TypeReady = "Ready" TypeResolved = "Resolved" ReasonBundleLookupFailed = "BundleLookupFailed" @@ -62,7 +61,6 @@ const ( func init() { // TODO(user): add Types from above operatorutil.ConditionTypes = append(operatorutil.ConditionTypes, - TypeReady, TypeResolved, ) // TODO(user): add Reasons from above diff --git a/controllers/operator_controller.go b/controllers/operator_controller.go index 25cbddbeb..4b21c40ac 100644 --- a/controllers/operator_controller.go +++ b/controllers/operator_controller.go @@ -106,13 +106,6 @@ func checkForUnexpectedFieldChange(a, b operatorsv1alpha1.Operator) bool { func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha1.Operator) (ctrl.Result, error) { // validate spec if err := validators.ValidateOperatorSpec(op); err != nil { - apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: metav1.ConditionFalse, - Reason: operatorsv1alpha1.ReasonInvalidSpec, - Message: err.Error(), - ObservedGeneration: op.GetGeneration(), - }) // Set the TypeResolved condition to Unknown to indicate that the resolution // hasn't been attempted yet, due to the spec being invalid. op.Status.ResolvedBundleResource = "" @@ -128,13 +121,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha // run resolution solution, err := r.Resolver.Resolve(ctx) if err != nil { - apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: metav1.ConditionFalse, - Reason: operatorsv1alpha1.ReasonResolutionFailed, - Message: err.Error(), - ObservedGeneration: op.GetGeneration(), - }) op.Status.ResolvedBundleResource = "" apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ Type: operatorsv1alpha1.TypeResolved, @@ -150,13 +136,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha // Operator's desired package name. bundleEntity, err := r.getBundleEntityFromSolution(solution, op.Spec.PackageName) if err != nil { - apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: metav1.ConditionFalse, - Reason: operatorsv1alpha1.ReasonBundleLookupFailed, - Message: err.Error(), - ObservedGeneration: op.GetGeneration(), - }) op.Status.ResolvedBundleResource = "" apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ Type: operatorsv1alpha1.TypeResolved, @@ -171,13 +150,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha // Get the bundle image reference for the bundle bundleImage, err := bundleEntity.BundlePath() if err != nil { - apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: metav1.ConditionFalse, - Reason: operatorsv1alpha1.ReasonBundleLookupFailed, - Message: err.Error(), - ObservedGeneration: op.GetGeneration(), - }) op.Status.ResolvedBundleResource = "" apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ Type: operatorsv1alpha1.TypeResolved, @@ -203,31 +175,18 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha // image we just looked up in the solution. dep := r.generateExpectedBundleDeployment(*op, bundleImage) if err := r.ensureBundleDeployment(ctx, dep); err != nil { - apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: metav1.ConditionFalse, - Reason: operatorsv1alpha1.ReasonInstallationFailed, - Message: err.Error(), - ObservedGeneration: op.GetGeneration(), - }) + // originally Reason: operatorsv1alpha1.ReasonInstallationFailed return ctrl.Result{}, err } // convert existing unstructured object into bundleDeployment for easier mapping of status. existingTypedBundleDeployment := &rukpakv1alpha1.BundleDeployment{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(dep.UnstructuredContent(), existingTypedBundleDeployment); err != nil { - apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: metav1.ConditionUnknown, - Reason: operatorsv1alpha1.ReasonInstallationStatusUnknown, - Message: err.Error(), - ObservedGeneration: op.GetGeneration(), - }) + // originally Reason: operatorsv1alpha1.ReasonInstallationStatusUnknown return ctrl.Result{}, err } // set the status of the operator based on the respective bundle deployment status conditions. - apimeta.SetStatusCondition(&op.Status.Conditions, mapBDStatusToReadyCondition(existingTypedBundleDeployment, op.GetGeneration())) return ctrl.Result{}, nil } @@ -359,43 +318,6 @@ func verifyBDStatus(dep *rukpakv1alpha1.BundleDeployment) (metav1.ConditionStatu return metav1.ConditionUnknown, fmt.Sprintf("could not determine the state of BundleDeployment %s", dep.Name) } -// mapBDStatusToReadyCondition returns the operator object's "TypeReady" condition based on the bundle deployment statuses. -func mapBDStatusToReadyCondition(existingBD *rukpakv1alpha1.BundleDeployment, observedGeneration int64) metav1.Condition { - // if BundleDeployment status is stale, return an unknown condition. - if isBundleDepStale(existingBD) { - return metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: metav1.ConditionUnknown, - Reason: operatorsv1alpha1.ReasonInstallationStatusUnknown, - Message: fmt.Sprintf("waiting for BundleDeployment %q status to be updated. BundleDeployment conditions out of date.", existingBD.Name), - ObservedGeneration: observedGeneration, - } - } - // update operator status: - // 1. If the Operator "Ready" status is "Unknown": The status of successful bundleDeployment is unknown, wait till Rukpak updates the BD status. - // 2. If the Operator "Ready" status is "True": Update the "successful resolution" status and return the result. - // 3. If the Operator "Ready" status is "False": There is error observed from Rukpak. Update the status accordingly. - status, message := verifyBDStatus(existingBD) - var reason string - - switch status { - case metav1.ConditionTrue: - reason = operatorsv1alpha1.ReasonInstallationSucceeded - case metav1.ConditionFalse: - reason = operatorsv1alpha1.ReasonInstallationFailed - default: - reason = operatorsv1alpha1.ReasonInstallationStatusUnknown - } - - return metav1.Condition{ - Type: operatorsv1alpha1.TypeReady, - Status: status, - Reason: reason, - Message: message, - ObservedGeneration: observedGeneration, - } -} - // isBundleDepStale returns true if conditions are out of date. func isBundleDepStale(bd *rukpakv1alpha1.BundleDeployment) bool { return bd != nil && bd.Status.ObservedGeneration != bd.GetGeneration() diff --git a/controllers/operator_controller_test.go b/controllers/operator_controller_test.go index 9cabea9e2..9d0f3cdd4 100644 --- a/controllers/operator_controller_test.go +++ b/controllers/operator_controller_test.go @@ -77,12 +77,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' not found", pkgName))) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) @@ -117,12 +112,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName))) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) @@ -165,12 +155,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) }) It("sets the status on operator", func() { - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(ContainSubstring("waiting for BundleDeployment")) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -242,12 +227,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected status conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(Equal(fmt.Sprintf("waiting for BundleDeployment %q status to be updated. BundleDeployment conditions out of date.", bd.Name))) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -289,12 +269,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(op.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(Equal(fmt.Sprintf("could not determine the state of BundleDeployment %s", bd.Name))) - cond = apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -327,12 +302,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(op.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationFailed)) - Expect(cond.Message).To(ContainSubstring(`failed to unpack`)) - cond = apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -365,12 +335,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(op.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationFailed)) - Expect(cond.Message).To(ContainSubstring(`failed to install`)) - cond = apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -403,12 +368,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(op.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionTrue)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationSucceeded)) - Expect(cond.Message).To(ContainSubstring(`install was successful`)) - cond = apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -448,12 +408,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(op.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(Equal(fmt.Sprintf("could not determine the state of BundleDeployment %s", bd.Name))) - cond = apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -486,12 +441,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(op.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(Equal(fmt.Sprintf("could not determine the state of BundleDeployment %s", bd.Name))) - cond = apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -552,12 +502,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) }) It("sets resolution to unknown status", func() { - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(ContainSubstring("waiting for BundleDeployment")) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -589,12 +534,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleLookupFailed)) - Expect(cond.Message).To(ContainSubstring(`error determining bundle path for entity`)) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) @@ -641,12 +581,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(`duplicate identifier "required package prometheus" in input`)) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) @@ -731,12 +666,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(ContainSubstring("waiting for BundleDeployment")) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -784,12 +714,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) - Expect(cond.Message).To(ContainSubstring("waiting for BundleDeployment")) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonSuccess)) @@ -838,12 +763,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) @@ -880,12 +800,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' in channel '%s' not found", pkgName, pkgChan))) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) @@ -925,12 +840,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) @@ -988,12 +898,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(operator.Status.ResolvedBundleResource).To(Equal("")) By("checking the expected conditions") - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) - Expect(cond).NotTo(BeNil()) - Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInvalidSpec)) - Expect(cond.Message).To(Equal("invalid .spec.version: Invalid character(s) found in prerelease \"123abc_def\"")) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeResolved) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionUnknown)) diff --git a/test/e2e/install_test.go b/test/e2e/install_test.go index 1d7673dd9..efb6d3037 100644 --- a/test/e2e/install_test.go +++ b/test/e2e/install_test.go @@ -70,13 +70,8 @@ var _ = Describe("Operator Install", func() { Eventually(func(g Gomega) { err = c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(len(operator.Status.Conditions)).To(Equal(2)) - cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeReady) - g.Expect(cond).ToNot(BeNil()) - g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) - g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonInstallationSucceeded)) - g.Expect(cond.Message).To(Equal("install was successful")) - cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved) + g.Expect(len(operator.Status.Conditions)).To(Equal(1)) + cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved) g.Expect(cond).ToNot(BeNil()) g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))