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

Elide uninteresting fields in object diffs. #498

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Elide uninteresting fields in object diffs. #498

merged 2 commits into from
Feb 1, 2024

Conversation

porridge
Copy link
Member

@porridge porridge commented Nov 15, 2023

What this PR does / why we need it:

Makes diffs on large objects much less verbose but not any less useful, by omitting these fields in the object which are not specified in the assertion and are at least moderately long when serialized.

This way, asserting on status.availableReplicas of a Deployment (which is missing if zero replicas are available) will still show the status.unavailableReplicas for example, but will omit spec completely unless the assertion also mentions it.

This saves hundreds to thousands of lines of logs to scroll when debugging failures of my operator tests. See the test for an example output. Before this change, the diff would contain the entirety of the "actual" resource from a cluster.

Fixes #497
Fixes #370

Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very welcomed! nice work. I left some suggestions but nothing blocking. It's worth adding that elided is an uncommon word... that said, it seems appropriate.

really like the end result and see lots of value to it! great stuff!

pkg/test/utils/kubernetes.go Outdated Show resolved Hide resolved
pkg/test/utils/kubernetes.go Show resolved Hide resolved
pkg/test/utils/kubernetes.go Show resolved Hide resolved
@kensipe
Copy link
Member

kensipe commented Jan 31, 2024

re-reading the PR desc... the first paragraph or sentence would make a perfect godoc for the prune func

Signed-off-by: Marcin Owsiany <[email protected]>
@porridge porridge merged commit c735bec into main Feb 1, 2024
4 checks passed
@porridge porridge deleted the elide branch February 1, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suppress uninteresting parts of long object diffs Filter metadata.managedFields from yaml diff output
3 participants