Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/operator/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ func (optr *Operator) syncAvailableStatus() error {

optrVersion, _ := optr.vStore.Get("operator")
failing := cov1helpers.IsStatusConditionTrue(co.Status.Conditions, configv1.OperatorFailing)
progressing := cov1helpers.IsStatusConditionTrue(co.Status.Conditions, configv1.OperatorProgressing)
message := fmt.Sprintf("Cluster has deployed %s", optrVersion)

available := configv1.ConditionTrue

if failing {
if (failing && !progressing) || (failing && optr.inClusterBringup) {
available = configv1.ConditionFalse
message = fmt.Sprintf("Cluster not available for %s", optrVersion)
}
Expand Down
32 changes: 28 additions & 4 deletions pkg/operator/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ func TestOperatorSyncStatus(t *testing.T) {
},
},
},
// 3. test that if progressing fails, we report available=false because state of the operator
// might have changed in the various sync calls
// 3. test that if progressing fails, we report available=true for the current version
{
syncs: []syncCase{
{
Expand Down Expand Up @@ -390,7 +389,7 @@ func TestOperatorSyncStatus(t *testing.T) {
},
{
Type: configv1.OperatorAvailable,
Status: configv1.ConditionFalse,
Status: configv1.ConditionTrue,
},
{
Type: configv1.OperatorFailing,
Expand All @@ -405,6 +404,31 @@ func TestOperatorSyncStatus(t *testing.T) {
},
},
},
{
// we mock the fact that we are at operator=test-version-2 after the previous sync
// so we don't provide any operatorVersions to mock that situation but in reality
// we are back at operator=test-version (we'll find a way to better do this...)
cond: []configv1.ClusterOperatorStatusCondition{
{
Type: configv1.OperatorProgressing,
Status: configv1.ConditionFalse,
},
{
Type: configv1.OperatorAvailable,
Status: configv1.ConditionTrue,
},
{
Type: configv1.OperatorFailing,
Status: configv1.ConditionFalse,
},
},
syncFuncs: []syncFunc{
{
name: "fn1",
fn: func(config renderConfig) error { return nil },
},
},
},
},
},
// 4. test that if progressing fails during bringup, we still report failing and not available
Expand Down Expand Up @@ -601,4 +625,4 @@ func TestInClusterBringUpStayOnErr(t *testing.T) {
assert.Nil(t, err, "expected syncAll to pass")

assert.False(t, optr.inClusterBringup)
}
}