Skip to content

Commit

Permalink
fix: errorCountAfterTruncation=0 if not truncated (#1514)
Browse files Browse the repository at this point in the history
- Fix a bug where errorCountAfterTruncation was not being set for
  rendering errors when truncated=false.

b/379720690
  • Loading branch information
karlkfi authored Dec 18, 2024
1 parent 822004a commit 91407f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
10 changes: 6 additions & 4 deletions pkg/parse/root_sync_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
}
Expand Down
15 changes: 6 additions & 9 deletions pkg/parse/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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
Expand Down

0 comments on commit 91407f4

Please sign in to comment.