From dcf3c09fe9dc7461347b1a157bb805e71d75942d Mon Sep 17 00:00:00 2001 From: Rohit Aggarwal Date: Fri, 27 Sep 2024 13:31:31 +0530 Subject: [PATCH] Reformating error output Signed-off-by: Rohit Aggarwal --- pkg/kapp/clusterapply/waiting_changes.go | 4 ++-- pkg/kapp/resourcesmisc/apps_v1_deployment.go | 4 ++-- pkg/kapp/resourcesmisc/apps_v1_deployment_test.go | 4 ++-- pkg/kapp/resourcesmisc/core_v1_pod.go | 4 ++-- pkg/kapp/resourcesmisc/custom_waiting_resource.go | 6 +++--- pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app.go | 4 ++-- .../resourcesmisc/kappctrl_k14s_io_v1alpha1_app_test.go | 4 ++-- .../packaging_carvel_dev_v1alpha1_packageinstall.go | 4 ++-- .../packaging_carvel_dev_v1alpha1_packageinstall_test.go | 4 ++-- .../packaging_carvel_dev_v1alpha1_packagerepository.go | 4 ++-- .../packaging_carvel_dev_v1alpha1_packagerepository_test.go | 4 ++-- test/e2e/apply_wait_error_test.go | 4 ++-- test/e2e/wait_timeout_test.go | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pkg/kapp/clusterapply/waiting_changes.go b/pkg/kapp/clusterapply/waiting_changes.go index 1026821e8..c2617857c 100644 --- a/pkg/kapp/clusterapply/waiting_changes.go +++ b/pkg/kapp/clusterapply/waiting_changes.go @@ -116,9 +116,9 @@ func (c *WaitingChanges) WaitForAny() ([]WaitingChange, []string, error) { case state.Done && !state.Successful: msg := "" if len(state.Message) > 0 { - msg += " (" + state.Message + ")" + msg = ": " + state.Message } - err := fmt.Errorf("%s: Finished unsuccessfully%s", desc, msg) + err := fmt.Errorf("%s: Finished waiting unsuccessfully%s", desc, msg) if c.exitOnError { return nil, nil, err } diff --git a/pkg/kapp/resourcesmisc/apps_v1_deployment.go b/pkg/kapp/resourcesmisc/apps_v1_deployment.go index 0910db846..9c86a5d07 100644 --- a/pkg/kapp/resourcesmisc/apps_v1_deployment.go +++ b/pkg/kapp/resourcesmisc/apps_v1_deployment.go @@ -51,13 +51,13 @@ func (s AppsV1Deployment) IsDoneApplying() DoneApplyState { case appsv1.DeploymentProgressing: if cond.Status == corev1.ConditionFalse { return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Deployment is not progressing: %s (message: %s)", cond.Reason, cond.Message)} + "Deployment is not progressing: %s, message: %s", cond.Reason, cond.Message)} } case appsv1.DeploymentReplicaFailure: if cond.Status == corev1.ConditionTrue { return DoneApplyState{Done: false, Successful: false, Message: fmt.Sprintf( - "Deployment has encountered replica failure: %s (message: %s)", cond.Reason, cond.Message)} + "Deployment has encountered replica failure: %s, message: %s", cond.Reason, cond.Message)} } } } diff --git a/pkg/kapp/resourcesmisc/apps_v1_deployment_test.go b/pkg/kapp/resourcesmisc/apps_v1_deployment_test.go index 8a406c4b8..9badaf17f 100644 --- a/pkg/kapp/resourcesmisc/apps_v1_deployment_test.go +++ b/pkg/kapp/resourcesmisc/apps_v1_deployment_test.go @@ -82,7 +82,7 @@ status: expectedState := ctlresm.DoneApplyState{ Done: true, Successful: false, - Message: "Deployment is not progressing: ProgressDeadlineExceeded (message: Progress deadline exceeded)", + Message: "Deployment is not progressing: ProgressDeadlineExceeded, message: Progress deadline exceeded", } require.Equal(t, expectedState, state, "Found incorrect state") @@ -107,7 +107,7 @@ status: expectedState = ctlresm.DoneApplyState{ Done: false, Successful: false, - Message: "Deployment has encountered replica failure: FailedCreate (message: Failed to create pods)", + Message: "Deployment has encountered replica failure: FailedCreate, message: Failed to create pods", } require.Equal(t, expectedState, state, "Found incorrect state") diff --git a/pkg/kapp/resourcesmisc/core_v1_pod.go b/pkg/kapp/resourcesmisc/core_v1_pod.go index 49aec170b..7a7198477 100644 --- a/pkg/kapp/resourcesmisc/core_v1_pod.go +++ b/pkg/kapp/resourcesmisc/core_v1_pod.go @@ -84,7 +84,7 @@ func (s CoreV1Pod) pendingDetailsReason(pod corev1.Pod) string { if st.State.Waiting != nil { msg := st.State.Waiting.Reason if len(st.State.Waiting.Message) > 0 { - msg += fmt.Sprintf(" (message: %s)", st.State.Waiting.Message) + msg += fmt.Sprintf(", message: %s", st.State.Waiting.Message) } return msg } @@ -96,7 +96,7 @@ func (s CoreV1Pod) pendingDetailsReason(pod corev1.Pod) string { if cond.Reason == corev1.PodReasonUnschedulable { msg := cond.Reason if len(cond.Message) > 0 { - msg += fmt.Sprintf(" (message: %s)", cond.Message) + msg += fmt.Sprintf(", message: %s", cond.Message) } return msg } diff --git a/pkg/kapp/resourcesmisc/custom_waiting_resource.go b/pkg/kapp/resourcesmisc/custom_waiting_resource.go index 283a994eb..ccf6d4b97 100644 --- a/pkg/kapp/resourcesmisc/custom_waiting_resource.go +++ b/pkg/kapp/resourcesmisc/custom_waiting_resource.go @@ -106,8 +106,8 @@ func (s CustomWaitingResource) IsDoneApplying() DoneApplyState { isTimeOutConditionPresent = true if s.hasTimeoutOccurred(condMatcher.Timeout, s.resource.Description()) { return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Encountered failure condition %s == %s: %s (message: %s) continuously for %s duration", - cond.Type, condMatcher.Status, cond.Reason, cond.Message, condMatcher.Timeout)} + "Continuously failed for %s with %s: %s, message: %s", + condMatcher.Timeout, cond.Type, cond.Reason, cond.Message)} } return DoneApplyState{Done: false, Message: fmt.Sprintf( "%s: %s (message: %s)", @@ -116,7 +116,7 @@ func (s CustomWaitingResource) IsDoneApplying() DoneApplyState { if condMatcher.Failure { return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Encountered failure condition %s == %s: %s (message: %s)", + "Encountered failure condition %s == %s: %s, message: %s", cond.Type, condMatcher.Status, cond.Reason, cond.Message)} } } diff --git a/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app.go b/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app.go index 9042476fd..e0bf811ce 100644 --- a/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app.go +++ b/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app.go @@ -56,11 +56,11 @@ func (s KappctrlK14sIoV1alpha1App) IsDoneApplying() DoneApplyState { case cond.Type == kcv1alpha1.ReconcileFailed && cond.Status == corev1.ConditionTrue: return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Reconcile failed: %s (message: %s)", cond.Reason, errorMsg)} + "Reconcile failed: message: %s", errorMsg)} case cond.Type == kcv1alpha1.DeleteFailed && cond.Status == corev1.ConditionTrue: return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Delete failed: %s (message: %s)", cond.Reason, errorMsg)} + "Delete failed: message: %s", errorMsg)} } } diff --git a/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app_test.go b/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app_test.go index ad98726cd..89976fcb0 100644 --- a/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app_test.go +++ b/pkg/kapp/resourcesmisc/kappctrl_k14s_io_v1alpha1_app_test.go @@ -36,7 +36,7 @@ status: expectedState := ctlresm.DoneApplyState{ Done: true, Successful: false, - Message: fmt.Sprintf("Reconcile failed: (message: %s)", usefulErrorMessage), + Message: fmt.Sprintf("Reconcile failed: message: %s", usefulErrorMessage), } require.Equal(t, expectedState, state) @@ -46,7 +46,7 @@ status: expectedState = ctlresm.DoneApplyState{ Done: true, Successful: false, - Message: fmt.Sprintf("Reconcile failed: (message: %s)", conditionMessage), + Message: fmt.Sprintf("Reconcile failed: message: %s", conditionMessage), } require.Equal(t, state, expectedState) diff --git a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall.go b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall.go index bf0d1fe2f..95414b843 100644 --- a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall.go +++ b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall.go @@ -57,11 +57,11 @@ func (s PackagingCarvelDevV1alpha1PackageInstall) IsDoneApplying() DoneApplyStat case cond.Type == appv1alpha1.ReconcileFailed && cond.Status == corev1.ConditionTrue: return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Reconcile failed: %s (message: %s)", cond.Reason, errorMsg)} + "Reconcile failed: message: %s", errorMsg)} case cond.Type == appv1alpha1.DeleteFailed && cond.Status == corev1.ConditionTrue: return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Delete failed: %s (message: %s)", cond.Reason, errorMsg)} + "Delete failed: message: %s", errorMsg)} } } diff --git a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall_test.go b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall_test.go index 1c459bc24..2cb5e3bcb 100644 --- a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall_test.go +++ b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packageinstall_test.go @@ -36,7 +36,7 @@ status: expectedState := ctlresm.DoneApplyState{ Done: true, Successful: false, - Message: fmt.Sprintf("Reconcile failed: (message: %s)", usefulErrorMessage), + Message: fmt.Sprintf("Reconcile failed: message: %s", usefulErrorMessage), } require.Equal(t, expectedState, state) @@ -46,7 +46,7 @@ status: expectedState = ctlresm.DoneApplyState{ Done: true, Successful: false, - Message: fmt.Sprintf("Reconcile failed: (message: %s)", conditionMessage), + Message: fmt.Sprintf("Reconcile failed: message: %s", conditionMessage), } require.Equal(t, state, expectedState) diff --git a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository.go b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository.go index 802b1aad3..8972aa179 100644 --- a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository.go +++ b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository.go @@ -57,11 +57,11 @@ func (s PackagingCarvelDevV1alpha1PackageRepo) IsDoneApplying() DoneApplyState { case cond.Type == appv1alpha1.ReconcileFailed && cond.Status == corev1.ConditionTrue: return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Reconcile failed: %s (message: %s)", cond.Reason, errorMsg)} + "Reconcile failed: message: %s", errorMsg)} case cond.Type == appv1alpha1.DeleteFailed && cond.Status == corev1.ConditionTrue: return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( - "Delete failed: %s (message: %s)", cond.Reason, errorMsg)} + "Delete failed: message: %s", errorMsg)} } } diff --git a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository_test.go b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository_test.go index cc89f2dab..5e4fb3cd4 100644 --- a/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository_test.go +++ b/pkg/kapp/resourcesmisc/packaging_carvel_dev_v1alpha1_packagerepository_test.go @@ -36,7 +36,7 @@ status: expectedState := ctlresm.DoneApplyState{ Done: true, Successful: false, - Message: fmt.Sprintf("Reconcile failed: (message: %s)", usefulErrorMessage), + Message: fmt.Sprintf("Reconcile failed: message: %s", usefulErrorMessage), } require.Equal(t, expectedState, state) @@ -46,7 +46,7 @@ status: expectedState = ctlresm.DoneApplyState{ Done: true, Successful: false, - Message: fmt.Sprintf("Reconcile failed: (message: %s)", conditionMessage), + Message: fmt.Sprintf("Reconcile failed: message: %s", conditionMessage), } require.Equal(t, state, expectedState) diff --git a/test/e2e/apply_wait_error_test.go b/test/e2e/apply_wait_error_test.go index 49cb3ea66..6d56c68f0 100644 --- a/test/e2e/apply_wait_error_test.go +++ b/test/e2e/apply_wait_error_test.go @@ -128,8 +128,8 @@ spec: expectedErrs := []string{ `kapp: Error:`, - fmt.Sprintf(`- waiting on reconcile job/my-job-fail-2 (batch/v1) namespace: %s: Finished unsuccessfully (Failed with reason BackoffLimitExceeded: Job has reached the specified backoff limit)`, env.Namespace), - fmt.Sprintf(`- waiting on reconcile job/my-job-fail (batch/v1) namespace: %s: Finished unsuccessfully (Failed with reason BackoffLimitExceeded: Job has reached the specified backoff limit)`, env.Namespace), + fmt.Sprintf(`- waiting on reconcile job/my-job-fail-2 (batch/v1) namespace: %s: Finished waiting unsuccessfully: Failed with reason BackoffLimitExceeded: Job has reached the specified backoff limit`, env.Namespace), + fmt.Sprintf(`- waiting on reconcile job/my-job-fail (batch/v1) namespace: %s: Finished waiting unsuccessfully: Failed with reason BackoffLimitExceeded: Job has reached the specified backoff limit`, env.Namespace), fmt.Sprintf(`- create service/service-fail (v1) namespace: %s: Creating resource service/service-fail (v1) namespace: kapp-test: API server says: Service "service-fail" is invalid: spec.ports: Required value (reason: Invalid)`, env.Namespace), } diff --git a/test/e2e/wait_timeout_test.go b/test/e2e/wait_timeout_test.go index b6b4ccecb..515222791 100644 --- a/test/e2e/wait_timeout_test.go +++ b/test/e2e/wait_timeout_test.go @@ -103,7 +103,7 @@ waitRules: RunOpts{IntoNs: true, AllowError: true, StdinReader: strings.NewReader(fmt.Sprintf(yaml2, "nginx:200"))}) require.Error(t, err) - require.Contains(t, err.Error(), "message: containers with unready status: [nginx]) continuously for 50s duration") + require.Contains(t, err.Error(), "Continuously failed for 50s with") }) cleanUp()