Skip to content

Preserve pod metadata in custom resources - #3043

Merged
brancz merged 1 commit into
prometheus-operator:masterfrom
pgier:fix-crd-pod-metadata
Feb 28, 2020
Merged

brancz merged 1 commit into
prometheus-operator:masterfrom
pgier:fix-crd-pod-metadata

Conversation

@pgier

@pgier pgier commented Feb 25, 2020 •

Copy link
Copy Markdown
Contributor

This applies a patch (kubernetes-sigs/controller-tools#395) the controller-gen binary to generate validation for PodMetadata and fix #3041. Since this is not merged yet into upstream controller-tools, I'm not sure if we want to merge it here. So for now this PR is just for testing.

@coderanger

Copy link
Copy Markdown
Contributor

Built and deployed, and it seems happy now :) Thanks! If you don't want to go with a pre-release patch to c-t, another option would be to just make our own struct there instead of directly using ObjectMeta. Which might help anyway since only a few fields from ObjectMeta really make sense there?

@pgier

pgier commented Feb 26, 2020

Copy link
Copy Markdown
Contributor Author

another option would be to just make our own struct there instead of directly using ObjectMeta.

@coderanger That sounds like it could work, and it's similar to some of the comments in controller-tools about how they are planning to handle ObjectMeta, so hopefully somewhat in-line with their future changes.

@pgier
pgier force-pushed the fix-crd-pod-metadata branch from 5772f3a to 76a5f8a Compare February 27, 2020 22:47
Recent updates to the CRD generation caused pod labels and annotations
to be lost due to no longer recursing into the ObjectMeta type to gather
all the fields.  This change allows labels and annotations to be preserved in
the custom Promtheus, Alertmanager, and ThanosRuler custom resources.

Fixes prometheus-operator#3041
@pgier
pgier force-pushed the fix-crd-pod-metadata branch from 76a5f8a to 9d2d9e7 Compare February 27, 2020 22:49
@pgier pgier changed the title [WIP] Fix crd pod metadata Preserve pod metadata in custom resources Feb 27, 2020
@pgier

pgier commented Feb 27, 2020

Copy link
Copy Markdown
Contributor Author

@coderanger It seems we are only using the Labels and Annotations from the ObjectMeta type. The rest is just ignored anyway. So I changed the type of PodMetadata to a new custom type PodMeta which includes only Labels and Annotations. WDYT?

@coderanger

Copy link
Copy Markdown
Contributor

@pgier Heh, was just finishing up a patch to do the same to try and save you the trouble, but 👍 from me. I don't think any other fields make sense to be use controlled. In some galaxy brain mode technically you could allow for non-controller owner refs but I think the use case there is too wonky.

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.

podMetadata feature no longer functional

3 participants