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
2 changes: 1 addition & 1 deletion pkg/cvo/cvo.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func New(
// controller that loads and applies content to the cluster. It returns an error if the payload appears to
// be in error rather than continuing.
func (optr *Operator) InitializeFromPayload(restConfig *rest.Config, burstRestConfig *rest.Config) error {
update, err := payload.LoadUpdate(optr.defaultPayloadDir(), optr.releaseImage)
update, err := payload.Load(optr.defaultPayloadDir(), optr.releaseImage)
if err != nil {
return fmt.Errorf("the local release contents are invalid - no current version can be determined from disk: %v", err)
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/cvo/cvo_scenarios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func TestCVO_StartupAndSyncUnverifiedPayload(t *testing.T) {
defer shutdownFn()

// make the image report unverified
payloadErr := &payload.UpdateError{
payloadErr := &payload.Error{
Reason: "ImageVerificationFailed",
Message: fmt.Sprintf("The update cannot be verified: some random error"),
Nested: fmt.Errorf("some random error"),
Expand Down Expand Up @@ -661,7 +661,7 @@ func TestCVO_UpgradeUnverifiedPayload(t *testing.T) {
defer shutdownFn()

// make the image report unverified
payloadErr := &payload.UpdateError{
payloadErr := &payload.Error{
Reason: "ImageVerificationFailed",
Message: fmt.Sprintf("The update cannot be verified: some random error"),
Nested: fmt.Errorf("some random error"),
Expand Down Expand Up @@ -887,7 +887,7 @@ func TestCVO_UpgradeVerifiedPayload(t *testing.T) {
defer shutdownFn()

// make the image report unverified
payloadErr := &payload.UpdateError{
payloadErr := &payload.Error{
Reason: "ImageVerificationFailed",
Message: fmt.Sprintf("The update cannot be verified: some random error"),
Nested: fmt.Errorf("some random error"),
Expand Down Expand Up @@ -1385,10 +1385,10 @@ func TestCVO_ErrorDuringReconcile(t *testing.T) {
Step: "ApplyResources",
Fraction: float32(2) / 3,
VersionHash: "6GC9TkkG9PA=",
Failure: &payload.UpdateError{
Failure: &payload.Error{
Nested: fmt.Errorf("unable to proceed"),
Reason: "UpdatePayloadFailed",
Message: "Could not update test \"file-yml\" (3 of 3)",
Reason: "ApplyManifestError",
Message: "Could not apply test \"file-yml\" (3 of 3): unable to proceed",
Task: &payload.Task{Index: 3, Total: 3, Manifest: &worker.payload.Manifests[2]},
},
Actual: configv1.Update{Version: "1.0.0-abc", Image: "image/image:1"},
Expand Down Expand Up @@ -1423,8 +1423,8 @@ func TestCVO_ErrorDuringReconcile(t *testing.T) {
},
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 1.0.0-abc"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadFailed", Message: "Could not update test \"file-yml\" (3 of 3)"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Reason: "UpdatePayloadFailed", Message: "Error while reconciling 1.0.0-abc: the update could not be applied"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "ApplyManifestError", Message: "Could not apply test \"file-yml\" (3 of 3): unable to proceed"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Reason: "ApplyManifestError", Message: "Error while reconciling 1.0.0-abc: Could not apply test \"file-yml\" (3 of 3): unable to proceed"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
},
Expand All @@ -1440,12 +1440,12 @@ func TestCVO_ParallelError(t *testing.T) {
defer shutdownFn()
worker := o.configSync.(*SyncWorker)
b := &errorResourceBuilder{errors: map[string]error{
"0000_10_a_file.yaml": &payload.UpdateError{
"0000_10_a_file.yaml": &payload.Error{
Reason: "ClusterOperatorNotAvailable",
Name: "operator-1",
},
"0000_20_a_file.yaml": nil,
"0000_20_b_file.yaml": &payload.UpdateError{
"0000_20_b_file.yaml": &payload.Error{
Reason: "ClusterOperatorNotAvailable",
Name: "operator-2",
},
Expand Down Expand Up @@ -1539,7 +1539,7 @@ func TestCVO_ParallelError(t *testing.T) {
continue
}
err := status.Failure
uErr, ok := err.(*payload.UpdateError)
uErr, ok := err.(*payload.Error)
if !ok || uErr.Reason != "ClusterOperatorsNotAvailable" || uErr.Message != "Some cluster operators are still updating: operator-1, operator-2" {
t.Fatalf("unexpected error: %v", err)
}
Expand Down
30 changes: 15 additions & 15 deletions pkg/cvo/cvo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ func TestOperator_sync(t *testing.T) {
Step: "Moving",
Reconciling: false,
Actual: configv1.Update{Version: "0.0.1-abc", Image: "image/image:v4.0.1"},
Failure: &payload.UpdateError{
Reason: "UpdatePayloadIntegrity",
Failure: &payload.Error{
Reason: "LoadManifestsError",
Message: "unable to apply object",
},
},
Expand All @@ -253,7 +253,7 @@ func TestOperator_sync(t *testing.T) {
VersionHash: "",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "unable to apply object"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Message: "Working towards 4.0.1"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
Expand Down Expand Up @@ -284,8 +284,8 @@ func TestOperator_sync(t *testing.T) {
VersionHash: "",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "Unable to apply 0.0.1-abc: the contents of the update are invalid"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "Unable to apply 0.0.1-abc: failed to load manifests from the release image"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
},
Expand All @@ -304,8 +304,8 @@ func TestOperator_sync(t *testing.T) {
Step: "Moving",
Reconciling: true,
Actual: configv1.Update{Version: "0.0.1-abc", Image: "image/image:v4.0.1"},
Failure: &payload.UpdateError{
Reason: "UpdatePayloadIntegrity",
Failure: &payload.Error{
Reason: "LoadManifestsError",
Message: "unable to apply object",
},
},
Expand All @@ -326,7 +326,7 @@ func TestOperator_sync(t *testing.T) {
VersionHash: "",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "unable to apply object"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Message: "Working towards 4.0.1"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
Expand Down Expand Up @@ -357,8 +357,8 @@ func TestOperator_sync(t *testing.T) {
VersionHash: "",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Reason: "UpdatePayloadIntegrity", Message: "Error while reconciling 0.0.1-abc: the contents of the update are invalid"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Reason: "LoadManifestsError", Message: "Error while reconciling 0.0.1-abc: failed to load manifests from the release image"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
},
Expand All @@ -378,8 +378,8 @@ func TestOperator_sync(t *testing.T) {
Reconciling: true,
Completed: 2,
Actual: configv1.Update{Version: "0.0.1-abc", Image: "image/image:v4.0.1"},
Failure: &payload.UpdateError{
Reason: "UpdatePayloadIntegrity",
Failure: &payload.Error{
Reason: "LoadManifestsError",
Message: "unable to apply object",
},
},
Expand All @@ -400,7 +400,7 @@ func TestOperator_sync(t *testing.T) {
VersionHash: "",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "unable to apply object"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Message: "Working towards 4.0.1"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
Expand Down Expand Up @@ -431,8 +431,8 @@ func TestOperator_sync(t *testing.T) {
VersionHash: "",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionTrue, Message: "Done applying 0.0.1-abc"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Reason: "UpdatePayloadIntegrity", Message: "Error while reconciling 0.0.1-abc: the contents of the update are invalid"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse, Reason: "LoadManifestsError", Message: "Error while reconciling 0.0.1-abc: failed to load manifests from the release image"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/cvo/internal/operatorstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
err := wait.PollImmediateUntil(interval, func() (bool, error) {
actual, err := client.Get(expected.Name)
if err != nil {
lastErr = &payload.UpdateError{
lastErr = &payload.Error{
Nested: err,
Reason: "ClusterOperatorNotAvailable",
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", expected.Name),
Expand Down Expand Up @@ -137,7 +137,7 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
sort.Strings(keys)

message := fmt.Sprintf("Cluster operator %s is still updating", actual.Name)
lastErr = &payload.UpdateError{
lastErr = &payload.Error{
Nested: errors.New(lowerFirst(message)),
Reason: "ClusterOperatorNotAvailable",
Message: message,
Expand Down Expand Up @@ -197,7 +197,7 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
if len(condition.Message) > 0 {
message = fmt.Sprintf("Cluster operator %s is reporting a failure: %s", actual.Name, condition.Message)
}
lastErr = &payload.UpdateError{
lastErr = &payload.Error{
Nested: errors.New(lowerFirst(message)),
Reason: "ClusterOperatorDegraded",
Message: message,
Expand All @@ -206,7 +206,7 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
return false, nil
}

lastErr = &payload.UpdateError{
lastErr = &payload.Error{
Nested: fmt.Errorf("cluster operator %s is not done; it is available=%v, progressing=%v, degraded=%v",
actual.Name, available, progressing, degraded,
),
Expand Down
30 changes: 15 additions & 15 deletions pkg/cvo/internal/operatorstatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: apierrors.NewNotFound(schema.GroupResource{"", "clusteroperator"}, "test-co"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co has not yet reported success",
Expand All @@ -61,7 +61,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is still updating"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co is still updating",
Expand All @@ -82,7 +82,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is still updating"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co is still updating",
Expand All @@ -108,7 +108,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is still updating"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co is still updating",
Expand Down Expand Up @@ -136,7 +136,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is still updating"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co is still updating",
Expand Down Expand Up @@ -164,7 +164,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is still updating"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co is still updating",
Expand Down Expand Up @@ -196,7 +196,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is still updating"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co is still updating",
Expand Down Expand Up @@ -228,7 +228,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is still updating"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co is still updating",
Expand Down Expand Up @@ -256,7 +256,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=false, progressing=true, degraded=true"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co has not yet reported success",
Expand Down Expand Up @@ -285,7 +285,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=false, progressing=true, degraded=true"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co has not yet reported success",
Expand Down Expand Up @@ -314,7 +314,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
Reason: "ClusterOperatorDegraded",
Message: "Cluster operator test-co is reporting a failure: random error",
Expand Down Expand Up @@ -343,7 +343,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=true, progressing=true, degraded=true"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co has not yet reported success",
Expand Down Expand Up @@ -372,7 +372,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
Reason: "ClusterOperatorDegraded",
Message: "Cluster operator test-co is reporting a failure: random error",
Expand Down Expand Up @@ -401,7 +401,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
Reason: "ClusterOperatorDegraded",
Message: "Cluster operator test-co is reporting a failure: random error",
Expand Down Expand Up @@ -430,7 +430,7 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
}},
},
},
expErr: &payload.UpdateError{
expErr: &payload.Error{
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=true, progressing=true, degraded=true"),
Reason: "ClusterOperatorNotAvailable",
Message: "Cluster operator test-co has not yet reported success",
Expand Down
6 changes: 3 additions & 3 deletions pkg/cvo/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ func (optr *Operator) syncStatus(original, config *configv1.ClusterVersion, stat
if err := status.Failure; err != nil && !skipFailure {
var reason string
msg := "an error occurred"
if uErr, ok := err.(*payload.UpdateError); ok {
if uErr, ok := err.(*payload.Error); ok {
reason = uErr.Reason
msg = payload.SummaryForReason(reason, uErr.Name)
msg = uErr.Summary()
}

// set the failing condition
Expand Down Expand Up @@ -330,7 +330,7 @@ func convertErrorToProgressing(history []configv1.UpdateHistory, now time.Time,
if now.Sub(status.LastProgress) > 10*time.Minute || now.Sub(history[0].StartedTime.Time) > time.Hour {
return "", "", false
}
uErr, ok := status.Failure.(*payload.UpdateError)
uErr, ok := status.Failure.(*payload.Error)
if !ok {
return "", "", false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cvo/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestOperator_syncFailingStatus(t *testing.T) {
VersionHash: "",
Conditions: []configv1.ClusterOperatorStatusCondition{
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "UpdatePayloadIntegrity", Message: "unable to apply object"},
{Type: ClusterStatusFailing, Status: configv1.ConditionTrue, Reason: "LoadManifestsError", Message: "unable to apply object"},
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Message: "Working towards 4.0.1"},
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/cvo/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func Test_SyncWorker_apply(t *testing.T) {
manifests = append(manifests, m)
}

up := &payload.Update{ReleaseImage: "test", ReleaseVersion: "v0.0.0", Manifests: manifests}
up := &payload.Payload{ReleaseImage: "test", ReleaseVersion: "v0.0.0", Manifests: manifests}
r := &recorder{}
testMapper := resourcebuilder.NewResourceMapper()
testMapper.RegisterGVK(schema.GroupVersionKind{"test.cvo.io", "v1", "TestA"}, newTestBuilder(r, test.reactors))
Expand Down Expand Up @@ -308,7 +308,7 @@ func Test_SyncWorker_apply_generic(t *testing.T) {
dynamicScheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "test.cvo.io", Version: "v1", Kind: "TestB"}, &unstructured.Unstructured{})
dynamicClient := dynamicfake.NewSimpleDynamicClient(dynamicScheme)

up := &payload.Update{ReleaseImage: "test", ReleaseVersion: "v0.0.0", Manifests: manifests}
up := &payload.Payload{ReleaseImage: "test", ReleaseVersion: "v0.0.0", Manifests: manifests}
worker := &SyncWorker{}
worker.backoff.Steps = 1
worker.builder = &testResourceBuilder{
Expand Down
Loading