Skip to content

Commit

Permalink
Merge pull request #11013 from sbueringer/pr-improve-logs
Browse files Browse the repository at this point in the history
🌱 Improve reconcile state logs (don't log empty diff)
  • Loading branch information
k8s-ci-robot authored Aug 5, 2024
2 parents 438ad7b + 5f5dad2 commit df6c986
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit df6c986

Please sign in to comment.