Skip to content

Commit

Permalink
cvo: Update to use ObservedGeneration after API bump
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Jan 28, 2019
1 parent f35e3f8 commit a703c2e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
46 changes: 23 additions & 23 deletions pkg/cvo/cvo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,8 @@ func TestOperator_sync(t *testing.T) {
Version: "0.0.1-abc",
Image: "image/image:v4.0.1",
},
VersionHash: "xyz",
Generation: 2,
VersionHash: "xyz",
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: configv1.OperatorFailing, Status: configv1.ConditionFalse},
Expand Down Expand Up @@ -1151,7 +1151,7 @@ func TestOperator_sync(t *testing.T) {
Channel: "fast",
},
Status: configv1.ClusterVersionStatus{
Generation: 2,
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Message: "Cluster version is 0.0.1-abc"},
Expand Down Expand Up @@ -1186,8 +1186,8 @@ func TestOperator_sync(t *testing.T) {
History: []configv1.UpdateHistory{
{State: configv1.CompletedUpdate, Version: "0.0.1-abc", Image: "image/image:v4.0.1", StartedTime: defaultStartedTime, CompletionTime: &defaultCompletionTime},
},
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "0.0.1-abc"},
Generation: 2,
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "0.0.1-abc"},
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Message: "Cluster version is 0.0.1-abc"},
Expand Down Expand Up @@ -1234,7 +1234,7 @@ func TestOperator_sync(t *testing.T) {
Channel: "fast",
},
Status: configv1.ClusterVersionStatus{
Generation: 2,
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Message: "Cluster version is 0.0.1-abc"},
Expand Down Expand Up @@ -1269,8 +1269,8 @@ func TestOperator_sync(t *testing.T) {
History: []configv1.UpdateHistory{
{State: configv1.CompletedUpdate, Version: "0.0.1-abc", Image: "image/image:v4.0.1", StartedTime: defaultStartedTime, CompletionTime: &defaultCompletionTime},
},
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "0.0.1-abc"},
Generation: 2,
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "0.0.1-abc"},
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Message: "Cluster version is 0.0.1-abc"},
Expand Down Expand Up @@ -1316,7 +1316,7 @@ func TestOperator_sync(t *testing.T) {
Channel: "",
},
Status: configv1.ClusterVersionStatus{
Generation: 2,
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Message: "Cluster version is 0.0.1-abc"},
Expand Down Expand Up @@ -1347,8 +1347,8 @@ func TestOperator_sync(t *testing.T) {
History: []configv1.UpdateHistory{
{State: configv1.CompletedUpdate, Version: "0.0.1-abc", Image: "image/image:v4.0.1", StartedTime: defaultStartedTime, CompletionTime: &defaultCompletionTime},
},
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "0.0.1-abc"},
Generation: 2,
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "0.0.1-abc"},
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Message: "Cluster version is 0.0.1-abc"},
Expand Down Expand Up @@ -1409,8 +1409,8 @@ func TestOperator_sync(t *testing.T) {
History: []configv1.UpdateHistory{
{State: configv1.CompletedUpdate, Version: "4.0.1", Image: "image/image:v4.0.1", StartedTime: defaultStartedTime, CompletionTime: &defaultCompletionTime},
},
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "4.0.1"},
Generation: 2,
Desired: configv1.Update{Image: "image/image:v4.0.1", Version: "4.0.1"},
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 4.0.1"},
{Type: configv1.OperatorFailing, Status: configv1.ConditionFalse},
Expand Down Expand Up @@ -1482,7 +1482,7 @@ func TestOperator_sync(t *testing.T) {
{Version: "4.0.2", Image: "test/image:1"},
{Version: "4.0.3", Image: "test/image:2"},
},
Generation: 2,
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: ClusterVersionInvalid, Status: configv1.ConditionTrue, Reason: "InvalidClusterVersion", Message: "The cluster version is invalid: spec.desiredUpdate.version: Invalid value: \"4.0.4\": when image is empty the update must be a previous version or an available update"},
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 4.0.1"},
Expand Down Expand Up @@ -1548,7 +1548,7 @@ func TestOperator_sync(t *testing.T) {
// },
},
Status: configv1.ClusterVersionStatus{
Generation: 2,
ObservedGeneration: 2,
History: []configv1.UpdateHistory{
{State: configv1.CompletedUpdate, Version: "4.0.1", Image: "image/image:v4.0.1", StartedTime: defaultStartedTime, CompletionTime: &defaultCompletionTime},
},
Expand Down Expand Up @@ -1608,8 +1608,8 @@ func TestOperator_sync(t *testing.T) {
Version: "0.0.1-abc",
Image: "image/image:v4.0.1",
},
VersionHash: "y_Kc5IQiIyU=",
Generation: 2,
VersionHash: "y_Kc5IQiIyU=",
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: configv1.OperatorFailing, Status: configv1.ConditionFalse},
Expand Down Expand Up @@ -1668,8 +1668,8 @@ func TestOperator_sync(t *testing.T) {
Version: "0.0.1-abc",
Image: "image/image:v4.0.1",
},
VersionHash: "unknown_hash",
Generation: 2,
VersionHash: "unknown_hash",
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: configv1.OperatorFailing, Status: configv1.ConditionFalse},
Expand Down Expand Up @@ -1706,9 +1706,9 @@ func TestOperator_sync(t *testing.T) {
StartedTime: metav1.Time{time.Unix(0, 0)},
},
},
Desired: configv1.Update{Version: "0.0.1-abc", Image: "image/image:v4.0.1"},
Generation: 2,
VersionHash: "y_Kc5IQiIyU=",
Desired: configv1.Update{Version: "0.0.1-abc", Image: "image/image:v4.0.1"},
ObservedGeneration: 2,
VersionHash: "y_Kc5IQiIyU=",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: configv1.OperatorFailing, Status: configv1.ConditionFalse},
Expand Down Expand Up @@ -2173,7 +2173,7 @@ func TestOperator_availableUpdatesSync(t *testing.T) {
History: []configv1.UpdateHistory{
{Image: "image/image:v4.0.1"},
},
Generation: 2,
ObservedGeneration: 2,
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying image/image:v4.0.1"},
{Type: configv1.OperatorFailing, Status: configv1.ConditionFalse},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cvo/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (optr *Operator) syncStatus(original, config *configv1.ClusterVersion, stat
original = config.DeepCopy()
}

config.Status.Generation = status.Generation
config.Status.ObservedGeneration = status.Generation
if len(status.VersionHash) > 0 {
config.Status.VersionHash = status.VersionHash
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/start/start_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func waitForUpdateAvailable(t *testing.T, client clientset.Interface, ns string,
}
lastCV = cv

if cv.Status.Generation > cv.Generation {
if cv.Status.ObservedGeneration > cv.Generation {
return false, fmt.Errorf("status generation should never be newer than metadata generation")
}

Expand All @@ -586,7 +586,7 @@ func waitForUpdateAvailable(t *testing.T, client clientset.Interface, ns string,

if len(versions) == 1 {
// we should not observe status.generation == metadata.generation without also observing a status history entry
if cv.Status.Generation == cv.Generation {
if cv.Status.ObservedGeneration == cv.Generation {
if len(cv.Status.History) == 0 || cv.Status.History[0].Version != versions[0] {
return false, fmt.Errorf("initializing operator should set history and generation at the same time")
}
Expand Down Expand Up @@ -614,7 +614,7 @@ func waitForUpdateAvailable(t *testing.T, client clientset.Interface, ns string,
}

// we should not observe status.generation == metadata.generation without also observing a status history entry
if cv.Status.Generation == cv.Generation {
if cv.Status.ObservedGeneration == cv.Generation {
target := versions[len(versions)-1]
if cv.Status.Desired.Version != target {
return false, fmt.Errorf("upgrading operator should always have desired version when spec version is set")
Expand Down Expand Up @@ -674,7 +674,7 @@ func waitUntilUpgradeFails(t *testing.T, client clientset.Interface, ns string,
}
lastCV = cv

if cv.Status.Generation > cv.Generation {
if cv.Status.ObservedGeneration > cv.Generation {
return false, fmt.Errorf("status generation should never be newer than metadata generation")
}

Expand Down Expand Up @@ -717,7 +717,7 @@ func waitUntilUpgradeFails(t *testing.T, client clientset.Interface, ns string,
}

// we should not observe status.generation == metadata.generation without also observing a status history entry
if cv.Status.Generation == cv.Generation {
if cv.Status.ObservedGeneration == cv.Generation {
target := versions[len(versions)-1]
if cv.Status.Desired.Version != target {
return false, fmt.Errorf("upgrading operator should always have desired version when spec version is set")
Expand Down Expand Up @@ -803,8 +803,8 @@ func verifyClusterVersionHistory(t *testing.T, cv *configv1.ClusterVersion) {

func verifyClusterVersionStatus(t *testing.T, cv *configv1.ClusterVersion, expectedUpdate configv1.Update, expectHistory int) {
t.Helper()
if cv.Status.Generation != cv.Generation {
t.Fatalf("unexpected: %d instead of %d", cv.Status.Generation, cv.Generation)
if cv.Status.ObservedGeneration != cv.Generation {
t.Fatalf("unexpected: %d instead of %d", cv.Status.ObservedGeneration, cv.Generation)
}
if cv.Status.Desired != expectedUpdate {
t.Fatalf("unexpected: %#v", cv.Status.Desired)
Expand All @@ -829,8 +829,8 @@ func verifyClusterVersionStatus(t *testing.T, cv *configv1.ClusterVersion, expec
if len(cv.Status.VersionHash) == 0 {
t.Fatalf("unexpected version hash: %#v", cv.Status.VersionHash)
}
if cv.Status.Generation != cv.Generation {
t.Fatalf("unexpected generation: %#v", cv.Status.Generation)
if cv.Status.ObservedGeneration != cv.Generation {
t.Fatalf("unexpected generation: %#v", cv.Status.ObservedGeneration)
}
}

Expand Down

0 comments on commit a703c2e

Please sign in to comment.