Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Improve reconcile state logs (don't log empty diff) #11013

Merged
merged 1 commit into from
Aug 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,12 @@ func dryRunSSAPatch(ctx context.Context, dryRunCtx *dryRunSSAPatchInput) (bool,
ShouldFilter: ssa.IsPathIgnored([]contract.Path{[]string{"metadata", "managedFields"}}),
})

changes, err = json.Marshal(diff.Object)
if err != nil {
return false, false, nil, errors.Wrapf(err, "failed to marshal diff")
// changes should be empty (not "{}") if diff.Object is empty
if len(diff.Object) != 0 {
changes, err = json.Marshal(diff.Object)
if err != nil {
return false, false, nil, errors.Wrapf(err, "failed to marshal diff")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func TestServerSideApply(t *testing.T) {
g.Expect(err).ToNot(HaveOccurred())
g.Expect(p0.HasChanges()).To(BeTrue())
g.Expect(p0.HasSpecChanges()).To(BeFalse())
g.Expect(p0.Changes()).To(Equal([]byte(`{}`))) // Note: metadata.managedFields have been removed from the diff to reduce log verbosity.
g.Expect(p0.Changes()).To(BeEmpty()) // Note: metadata.managedFields have been removed from the diff to reduce log verbosity.

// Create the object using server side apply
g.Expect(p0.Patch(ctx)).To(Succeed())
Expand Down
Loading