From 91407f43b2bdd6e47f0f80245ec1391924c400c4 Mon Sep 17 00:00:00 2001 From: Karl Isenberg Date: Wed, 18 Dec 2024 15:29:11 -0800 Subject: [PATCH] fix: errorCountAfterTruncation=0 if not truncated (#1514) - Fix a bug where errorCountAfterTruncation was not being set for rendering errors when truncated=false. b/379720690 --- pkg/parse/root_sync_client.go | 10 ++++++---- pkg/parse/run_test.go | 15 ++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/parse/root_sync_client.go b/pkg/parse/root_sync_client.go index ad0565de3..c11bda72e 100644 --- a/pkg/parse/root_sync_client.go +++ b/pkg/parse/root_sync_client.go @@ -325,8 +325,9 @@ func setRenderingStatusFields(rendering *v1beta1.RenderingStatus, newStatus *Ren } rendering.Message = newStatus.Message errorSummary := &v1beta1.ErrorSummary{ - TotalCount: len(cse), - Truncated: denominator != 1, + TotalCount: len(cse), + Truncated: denominator != 1, + ErrorCountAfterTruncation: len(cse) / denominator, } rendering.Errors = cse[0 : len(cse)/denominator] rendering.ErrorSummary = errorSummary @@ -549,8 +550,9 @@ func setSyncStatusFields(syncStatus *v1beta1.Status, newStatus *SyncStatus, deno func setSyncStatusErrors(syncStatus *v1beta1.Status, cse []v1beta1.ConfigSyncError, denominator int) { syncStatus.Sync.ErrorSummary = &v1beta1.ErrorSummary{ - TotalCount: len(cse), - Truncated: denominator != 1, + TotalCount: len(cse), + Truncated: denominator != 1, + ErrorCountAfterTruncation: len(cse) / denominator, } syncStatus.Sync.Errors = cse[0 : len(cse)/denominator] } diff --git a/pkg/parse/run_test.go b/pkg/parse/run_test.go index 60dc7c556..82c545cea 100644 --- a/pkg/parse/run_test.go +++ b/pkg/parse/run_test.go @@ -520,8 +520,7 @@ func TestReconciler_Reconcile(t *testing.T) { Errors: status.ToCSE( status.HydrationError(status.ActionableHydrationErrorCode, fmt.Errorf("rendering error")), ), - // TODO: Fix bug with rendering status not setting ErrorCountAfterTruncation = 1 (b/379720690) - ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 0}, + ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 1}, LastUpdate: fakeMetaTime, } rs.Status.Conditions = []v1beta1.RootSyncCondition{ @@ -534,7 +533,7 @@ func TestReconciler_Reconcile(t *testing.T) { Message: RenderingFailed, Commit: sourceCommit, ErrorSourceRefs: []v1beta1.ErrorSource{v1beta1.RenderingError}, - ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 0}, + ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 1}, }, } return rs @@ -879,8 +878,7 @@ func TestReconciler_Reconcile(t *testing.T) { Errors: status.ToCSE( status.HydrationError(status.TransientErrorCode, fmt.Errorf("sync source contains only wet configs and hydration-controller is running")), ), - // TODO: Fix bug with rendering status not setting ErrorCountAfterTruncation = 1 - ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 0}, + ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 1}, LastUpdate: fakeMetaTime, } rs.Status.Conditions = []v1beta1.RootSyncCondition{ @@ -893,7 +891,7 @@ func TestReconciler_Reconcile(t *testing.T) { Message: RenderingNotRequired, Commit: sourceCommit, ErrorSourceRefs: []v1beta1.ErrorSource{v1beta1.RenderingError}, - ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 0}, + ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 1}, }, } return rs @@ -934,8 +932,7 @@ func TestReconciler_Reconcile(t *testing.T) { Errors: status.ToCSE( status.HydrationError(status.TransientErrorCode, fmt.Errorf("sync source contains dry configs and hydration-controller is not running")), ), - // TODO: Fix bug with rendering status not setting ErrorCountAfterTruncation = 1 - ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 0}, + ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 1}, LastUpdate: fakeMetaTime, } rs.Status.Conditions = []v1beta1.RootSyncCondition{ @@ -948,7 +945,7 @@ func TestReconciler_Reconcile(t *testing.T) { Message: RenderingRequired, Commit: sourceCommit, ErrorSourceRefs: []v1beta1.ErrorSource{v1beta1.RenderingError}, - ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 0}, + ErrorSummary: &v1beta1.ErrorSummary{TotalCount: 1, ErrorCountAfterTruncation: 1}, }, } return rs