From 1c8bd736eb486fa858d5c99c16d9af0790685daf Mon Sep 17 00:00:00 2001 From: "jesus m. rodriguez" Date: Fri, 13 Mar 2020 00:17:01 -0400 Subject: [PATCH] Bug 1813146: set Upgradeable False when in Managed state --- pkg/operator/operator.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index 61352fbea..47edc8a38 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -111,17 +111,14 @@ func (c ServiceCatalogControllerManagerOperator) sync() error { } } - v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{ - Type: operatorapiv1.OperatorStatusTypeUpgradeable, - Status: operatorapiv1.ConditionTrue, - Reason: "", - Message: "", - }) - switch operatorConfig.Spec.ManagementState { case operatorapiv1.Managed: - // redundant but it makes reading this switch later more clear - break + v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{ + Type: operatorapiv1.OperatorStatusTypeUpgradeable, + Status: operatorapiv1.ConditionFalse, + Reason: "Managed", + Message: "the controller manager is in a managed state, upgrades are not possible.", + }) case operatorapiv1.Unmanaged: // manage status originalOperatorConfig := operatorConfig.DeepCopy() @@ -143,6 +140,12 @@ func (c ServiceCatalogControllerManagerOperator) sync() error { Reason: "Unmanaged", Message: "the controller manager is in an unmanaged state, therefore no operator actions are failing.", }) + v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{ + Type: operatorapiv1.OperatorStatusTypeUpgradeable, + Status: operatorapiv1.ConditionTrue, + Reason: "Unmanaged", + Message: "the controller manager is in an unmanaged state, upgrades are possible.", + }) if !equality.Semantic.DeepEqual(operatorConfig.Status, originalOperatorConfig.Status) { if _, err := c.operatorConfigClient.ServiceCatalogControllerManagers().UpdateStatus(operatorConfig); err != nil { @@ -177,6 +180,12 @@ func (c ServiceCatalogControllerManagerOperator) sync() error { Reason: "Removed", Message: "", }) + v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{ + Type: operatorapiv1.OperatorStatusTypeUpgradeable, + Status: operatorapiv1.ConditionTrue, + Reason: "Removed", + Message: "the controller manager is in a removed state, upgrades are possible.", + }) // The version must be reported even though the operand is not running operatorConfig.Status.Version = os.Getenv("RELEASE_VERSION")