Skip to content

Commit 63550c2

Browse files
Merge pull request #72 from jmrodri/set-upgradeable
Bug 1813146: set Upgradeable False when in Managed state
2 parents 72383b5 + 1c8bd73 commit 63550c2

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

pkg/operator/operator.go

+18-9
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,14 @@ func (c ServiceCatalogControllerManagerOperator) sync() error {
111111
}
112112
}
113113

114-
v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{
115-
Type: operatorapiv1.OperatorStatusTypeUpgradeable,
116-
Status: operatorapiv1.ConditionTrue,
117-
Reason: "",
118-
Message: "",
119-
})
120-
121114
switch operatorConfig.Spec.ManagementState {
122115
case operatorapiv1.Managed:
123-
// redundant but it makes reading this switch later more clear
124-
break
116+
v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{
117+
Type: operatorapiv1.OperatorStatusTypeUpgradeable,
118+
Status: operatorapiv1.ConditionFalse,
119+
Reason: "Managed",
120+
Message: "the controller manager is in a managed state, upgrades are not possible.",
121+
})
125122
case operatorapiv1.Unmanaged:
126123
// manage status
127124
originalOperatorConfig := operatorConfig.DeepCopy()
@@ -143,6 +140,12 @@ func (c ServiceCatalogControllerManagerOperator) sync() error {
143140
Reason: "Unmanaged",
144141
Message: "the controller manager is in an unmanaged state, therefore no operator actions are failing.",
145142
})
143+
v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{
144+
Type: operatorapiv1.OperatorStatusTypeUpgradeable,
145+
Status: operatorapiv1.ConditionTrue,
146+
Reason: "Unmanaged",
147+
Message: "the controller manager is in an unmanaged state, upgrades are possible.",
148+
})
146149

147150
if !equality.Semantic.DeepEqual(operatorConfig.Status, originalOperatorConfig.Status) {
148151
if _, err := c.operatorConfigClient.ServiceCatalogControllerManagers().UpdateStatus(operatorConfig); err != nil {
@@ -177,6 +180,12 @@ func (c ServiceCatalogControllerManagerOperator) sync() error {
177180
Reason: "Removed",
178181
Message: "",
179182
})
183+
v1helpers.SetOperatorCondition(&operatorConfig.Status.Conditions, operatorapiv1.OperatorCondition{
184+
Type: operatorapiv1.OperatorStatusTypeUpgradeable,
185+
Status: operatorapiv1.ConditionTrue,
186+
Reason: "Removed",
187+
Message: "the controller manager is in a removed state, upgrades are possible.",
188+
})
180189

181190
// The version must be reported even though the operand is not running
182191
operatorConfig.Status.Version = os.Getenv("RELEASE_VERSION")

0 commit comments

Comments
 (0)