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

Remove managedFields from gathered resources #460

Merged
merged 7 commits into from
Jul 22, 2021

Conversation

natiiix
Copy link
Contributor

@natiiix natiiix commented Jun 18, 2021

In OCP 4, JSON representations of resources returned by the API contain a metadata field called managedFields, which takes up a considerable amount of space without being of any use to us.

This PR introduces a serialization/marshalling filter, which automatically removes this field from resources stored in the IO archive by using ResourceMarshaller instead of JSONMarshaller for resources that have managedFields. This is performed in a somewhat type-safe way for compile-time transparency.

The result is an archive size reduction, both in the raw and compressed form, by approximately 10%.

Categories

  • Bugfix
  • Enhancement
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

Many sample resource JSONs have been modified, so please see the "Files changed" tab for a complete list.

All resources affected by this change should now be updated in the sample archive. There should be no managedFields present in any of the sample resources.

Documentation

No.

Unit Tests

  • pkg/record/resource_marshaller_test.go
    • Test_ResourceMarshaller_GetExtension
    • Test_ResourceMarshaller_MarshalUnstructured
    • Test_ResourceMarshaller_MarshalPod

Privacy

Yes. There are no sensitive data in the newly collected information.

This PR adds no new data to the archive, only removes the managedFields fields.

Changelog

No.

Breaking Changes

No.

The managedFields fields have been removed, but these should not be used by any of the software that processes the IO archives.

References

Jira Task: https://issues.redhat.com/browse/CCXDEV-4899

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 18, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jun 18, 2021

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 18, 2021
@natiiix natiiix force-pushed the remove-fields branch 2 times, most recently from 69f8b2c to 6b541ef Compare July 1, 2021 15:00
@Serhii1011010
Copy link
Contributor

Haven't tested, but looks great

@natiiix natiiix changed the title WIP: Remove managedFields from gathered resources Remove managedFields from gathered resources Jul 21, 2021
@natiiix natiiix marked this pull request as ready for review July 21, 2021 08:24
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 21, 2021

if len(jsonBytesRM) >= len(jsonBytesDirect) {
t.Fatalf("JSON from ResourceMarshaller is not smaller than directly marshalled JSON (%d >= %d)", len(jsonBytesRM), len(jsonBytesDirect))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The last two tests could be merged into one using two test cases I guess, but it's really a minor detail and this is OK as well.

@tremes
Copy link
Contributor

tremes commented Jul 22, 2021

I didn't check the json files updates. I reviewed the changes in the code and randomly checked some files in the archive (IOW I ran it against cluster-bot cluster). The config/configmaps/kube-system/cluster-config-v1.json (I know it was added recently) still contains the managedFields, but I think it's not a blocker and we can update it in some next PR. Good job! Thank you!
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jul 22, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: natiiix, tremes

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 22d4cf8 into openshift:master Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants