Skip to content

jsonnet: unify metadata management #1471

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

Merged
merged 5 commits into from
Nov 2, 2021

Conversation

paulfantom
Copy link
Member

@paulfantom paulfantom commented Nov 1, 2021

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to that issue.

To simplify code and reduce duplication this PR introduces hidden field _metadata which is then used to set metadata for all objects in a component.

This PR also cleans jsonnet codebase to first assign objects as value and then add data to that value. This way object won't be overriding explicit settings. Example: https://github.com/prometheus-operator/kube-prometheus/pull/1471/files#diff-9ada6ed45123a448cead005447e28c3d11af80858521ef7d85a7e0ea57e168daR153-R155

I am also starting to establish relations between objects in this PR as can be seen in serviceAccountName fields. This should further reduce code duplication and allow a better understanding of the codebase.

Type of change

What type of changes does your code introduce to the kube-prometheus? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Changelog entry

Please put a one-line changelog entry below. Later this will be copied to the changelog file.

Make metadata consistent across objects in the same component

@ArthurSens
Copy link
Member

I like the approach of making explicit relationships in label selectors! Ping when you want to get a review here :)

@paulfantom
Copy link
Member Author

@ArthurSens I fixed formatting issues and this should be ready as-is. I'll slowly introduce more relationships in future PRs.

@paulfantom paulfantom requested a review from ArthurSens November 1, 2021 19:08
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

LGTM!

@ArthurSens
Copy link
Member

I've noticed that a lot of resources were lacking metadata. Do you think it makes sense to add unit tests if we want to keep this consistent?

I've developed some tests downstream, e.g. one that makes sure every alert has severity label

@paulfantom
Copy link
Member Author

Yes, it would be awesome to add such tests! Do you want to add them? :)

@paulfantom paulfantom merged commit 33b58ae into prometheus-operator:main Nov 2, 2021
@paulfantom paulfantom deleted the metadata-management branch November 2, 2021 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants