Skip to content

Commit

Permalink
Merge pull request #191 from jsafrane/add-progressing
Browse files Browse the repository at this point in the history
OCPBUGS-23342: Add dummy Progressing condition on blocked driver install
  • Loading branch information
openshift-merge-bot[bot] committed Nov 28, 2023
2 parents 1a09062 + 4c9c09e commit d18d77f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/operator/vspherecontroller/checks/check_error.go
Expand Up @@ -38,7 +38,7 @@ type CheckAction int
const (
CheckActionPass = iota
CheckActionBlockUpgrade // Only block upgrade
CheckActionBlockUpgradeDriverInstall // Block voth upgrade and driver install
CheckActionBlockUpgradeDriverInstall // Block both upgrade and driver install
CheckActionBlockUpgradeOrDegrade // Degrade if the driver is installed, block upgrade otherwise
CheckActionDegrade
)
Expand Down
28 changes: 26 additions & 2 deletions pkg/operator/vspherecontroller/vspherecontroller.go
Expand Up @@ -444,13 +444,36 @@ func (c *VSphereController) updateConditions(
lastCheckResult checks.ClusterCheckResult,
status *operatorapi.OperatorStatus,
upgradeStatus operatorapi.ConditionStatus) error {

updateFuncs := []v1helpers.UpdateStatusFunc{}

progressingConditionName := name + operatorapi.OperatorStatusTypeProgressing
if lastCheckResult.Action == checks.CheckActionBlockUpgradeDriverInstall {
// Add a dummy Progressing condition. cluster-storage-operator needs at least one *Progressing
// condition to be present in ClusterCSIDriver to compute overall Progressing condition of the driver,
// otherwise it sets Progressing=True forever.
// In case of CheckActionBlockUpgradeDriverInstall, this dummy condition will be the only Progressing
// condition that makes the whole ClusterCSIDriver Progressing=false.
klog.V(4).Infof("Adding %s to mark the whole ClusterCSIDriver as Progressing=False", progressingConditionName)
progressingCond := operatorapi.OperatorCondition{
Type: progressingConditionName,
Status: operatorapi.ConditionFalse,
}
updateFuncs = append(updateFuncs, v1helpers.UpdateConditionFn(progressingCond))
} else {
// Remove the dummy condition, CSIControllerSet will report its own set of progressing conditions.
klog.V(4).Infof("Removing %s", progressingConditionName)
updateFuncs = append(updateFuncs, func(status *operatorapi.OperatorStatus) error {
v1helpers.RemoveOperatorCondition(&status.Conditions, progressingConditionName)
return nil
})
}

availableCnd := operatorapi.OperatorCondition{
Type: name + operatorapi.OperatorStatusTypeAvailable,
Status: operatorapi.ConditionTrue,
}

updateFuncs := []v1helpers.UpdateStatusFunc{}

// we are degrading using a custom name here because, if we use name + Degraded
// library-go will override the condition and mark cluster un-degraded.
// Degrading here with custom name here ensures that - our degrade condition is sticky
Expand Down Expand Up @@ -506,6 +529,7 @@ func (c *VSphereController) updateConditions(
if _, _, updateErr := v1helpers.UpdateStatus(ctx, c.operatorClient, updateFuncs...); updateErr != nil {
return updateErr
}

return nil
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/operator/vspherecontroller/vspherecontroller_test.go
Expand Up @@ -244,6 +244,10 @@ func TestSync(t *testing.T) {
Type: testControllerName + opv1.OperatorStatusTypeUpgradeable,
Status: opv1.ConditionFalse,
},
{
Type: testControllerName + opv1.OperatorStatusTypeProgressing,
Status: opv1.ConditionFalse,
},
},
expectedMetrics: `vsphere_csi_driver_error{condition="install_blocked",failure_reason="existing_driver_found"} 1
vsphere_csi_driver_error{condition="upgrade_blocked",failure_reason="existing_driver_found"} 1`,
Expand All @@ -267,6 +271,10 @@ vsphere_csi_driver_error{condition="upgrade_blocked",failure_reason="existing_dr
Type: testControllerName + opv1.OperatorStatusTypeUpgradeable,
Status: opv1.ConditionFalse,
},
{
Type: testControllerName + opv1.OperatorStatusTypeProgressing,
Status: opv1.ConditionFalse,
},
},
expectedMetrics: `vsphere_csi_driver_error{condition="install_blocked",failure_reason="existing_driver_found"} 1
vsphere_csi_driver_error{condition="upgrade_blocked",failure_reason="existing_driver_found"} 1`,
Expand Down

0 comments on commit d18d77f

Please sign in to comment.