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

patches should accept a patch file with multiple patches #5049

Closed
1 of 2 tasks
iamnoah opened this issue Feb 16, 2023 · 11 comments · Fixed by #5194
Closed
1 of 2 tasks

patches should accept a patch file with multiple patches #5049

iamnoah opened this issue Feb 16, 2023 · 11 comments · Fixed by #5194
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@iamnoah
Copy link

iamnoah commented Feb 16, 2023

Eschewed features

  • This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

patchesStrategicMerge is deprecated but provides a feature that is not currently possible with patches in that multiple strategic merge patches can be combined into a single file.

I should be able to specify that my targets are determined by the GVKNN of the strategic merge patch itself:

patches:
- path: sm-patches-for-multiple-objects.yaml
   target:
     strategicMerge: byName

The exact syntax is unimportant.

Why is this needed?

This is valuable when patch changes are correlated and future changes need to consider multiple targets. Splitting such patches across multiple files is incoherent and error prone.

Can you accomplish the motivating task without this feature, and if so, how?

My first preference would be to simply recognize this is a valuable use case and not deprecated or remove it.

What other solutions have you considered?

Helm? This ability was central to why I started using kustomize years ago, so I am frankly shocked that it is on the chopping block.

Anything else we should know?

Relates to #5040

Feature ownership

  • I am interested in contributing this feature myself! 🎉
@iamnoah iamnoah added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 16, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 16, 2023
@natasha41575
Copy link
Contributor

natasha41575 commented Feb 16, 2023

I should be able to specify that my targets are determined by the GVKNN of the strategic merge patch itself

Maybe this is not documented properly, but you can already do this by not providing a target and it will use the GVKN of the patch to find the target.

Here is an example I tried:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- pod.yaml
patches:
- path: patch.yaml
# pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: bar
# patch.yaml
apiVersion: v1
kind: Pod
metadata:
  annotations:
    foo: bar
  name: bar

Running kustomize build shows that the proper target gets patched, so I don't think we need to add additional syntax to targets for this.

Your second point, that there should be able to be multiple patches in a single file, is valid IMO, and I don't see a strong reason why we shouldn't allow that. @KnVerey do you have any concerns with that?

/triage under-consideration
/retitle patches should accept a patch file with multiple patches

Editing to add a small response:

I am frankly shocked that it is on the chopping block.

Part of the reason for the lengthy deprecation process is so that we can address user concerns like these before removing large features, and I'm optimistic that we can get patches to a place that minimizes user friction when migrating.

@k8s-ci-robot k8s-ci-robot changed the title proper replacement for patchesStrategicMerge patches should accept a patch file with multiple patches Feb 16, 2023
@k8s-ci-robot k8s-ci-robot added triage/under-consideration and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 16, 2023
@lblazewski
Copy link

The feature of supporting multiple patches used the same way as @natasha41575 showed is highly needed for all of the folks relying currently on patchesStrategicMerge since otherwise the migration would be quite a hassle.

@natasha41575
Copy link
Contributor

#3481 is a related issue, but the decision there was made prior to the deprecation of patchesStrategicMerge, so we should reconsider it. We will send an update here once we have decided how we want to handle it.

@natasha41575
Copy link
Contributor

natasha41575 commented Feb 22, 2023

After discussion, we have decided to accept the feature with the following restrictions:

/triage accepted
/help

@k8s-ci-robot
Copy link
Contributor

@natasha41575:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

After discussion, we have decided to accept the feature with the following restrictions:

/triage accepted
/help

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 triage/accepted Indicates an issue or PR is ready to be actively worked on. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Feb 22, 2023
@natasha41575 natasha41575 added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. and removed triage/under-consideration labels Feb 22, 2023
@natasha41575
Copy link
Contributor

@koba1t Are you interested in working on this?

@koba1t
Copy link
Member

koba1t commented Feb 28, 2023

/assign

@pre
Copy link

pre commented May 31, 2023

It would be great to get #5059 merged!

@annasong20
Copy link
Contributor

  • Multiple JSON patch documents are should not be allowed (currently, only the first one is used and the rest are ignored. This should be an error instead.)

To clarify, this comment refers to json6902 patches expressed in yaml documents, not json.

@ashutosh887
Copy link

@natasha41575 Is it resolved?

/assign

@koba1t
Copy link
Member

koba1t commented Sep 1, 2023

@ashutosh887
Thanks for worrying about this issue.
Please check #5194

/unassign @ashutosh887

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging a pull request may close this issue.

8 participants