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

[address #4717] create template/metadata when using includeTemplates if not present #4751

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

aibarbetta
Copy link
Member

Fix #4717

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 7, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @aibarbetta. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 7, 2022
@k8s-ci-robot k8s-ci-robot requested review from KnVerey and yuwenma August 7, 2022 23:51
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 7, 2022
@aibarbetta aibarbetta changed the title [address #4717] create template/metadata in includeTemplates if not present [address #4717] create template/metadata when using includeTemplates if not present Aug 7, 2022
@aibarbetta
Copy link
Member Author

@KnVerey @natasha41575 can you review?

@KnVerey
Copy link
Contributor

KnVerey commented Aug 10, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 10, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Aug 10, 2022

Fix makes sense and regression test is solid. Thank you!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 10, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aibarbetta, KnVerey

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Aug 10, 2022

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Aug 10, 2022

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2022
@k8s-ci-robot k8s-ci-robot merged commit 91e002a into kubernetes-sigs:master Aug 10, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Aug 10, 2022

Immediately after allowing this to merge I realized a big problem with it: the fieldspec it is updating is not resource-specific, which was only working correctly because of create: false. With this PR, the transformer will add spec.template.metadata.labels to all resources, including ones that don't have that field. For example, if you have a service in the set, you'll get:

kind: Service
metadata:
  labels:
    app: bingo
    owner: alice
    someName: someValue
  name: svc
spec:
  template:
    metadata:
      labels:
        app: bingo
        owner: alice
        someName: someValue

which is invalid. We need to be merging complete, resource-specific fieldspecs. I'm going to revert this PR.

@wolfmah
Copy link

wolfmah commented Aug 10, 2022

Yeah, that's why commonLabels adds them all separately in its field specs definition: api/konfig/builtinpluginconsts/commonlabels.go.

The idea would be take all the spec from commonLabels, that are not relevant to selectors, to the includeTemplates:

List of relevant specs
- path: metadata/labels
  create: true

- path: spec/template/metadata/labels
  create: true
  version: v1
  kind: ReplicationController

- path: spec/template/metadata/labels
  create: true
  kind: Deployment

- path: spec/template/metadata/labels
  create: true
  kind: ReplicaSet

- path: spec/template/metadata/labels
  create: true
  kind: DaemonSet

- path: spec/template/metadata/labels
  create: true
  group: apps
  kind: StatefulSet

- path: spec/volumeClaimTemplates[]/metadata/labels
  create: true
  group: apps
  kind: StatefulSet

- path: spec/template/metadata/labels
  create: true
  group: batch
  kind: Job

- path: spec/jobTemplate/metadata/labels
  create: true
  group: batch
  kind: CronJob

- path: spec/jobTemplate/spec/template/metadata/labels
  create: true
  group: batch
  kind: CronJob

I don't really know what would be the best way to sync those two together, or even how to implement a naive copy/paste version, but IMHO the high level of what needs to be done is that.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

includeTemplates doesn't work
4 participants