-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 throw error on missing targets #4379
Comments
Partially responsible for roboll/helmfile#2031 |
I think this issue deserves more attention; |
The ability to detect/fail on missing targets would greatly benefit CI/CD Kubeval pipeline jobs, was shocked to see that this doesn't happen currently. |
/triage accepted We discussed this during the bug scrub, and have arrived at the decision that |
/assign |
@natasha41575 @KnVerey - I started working on this issue, and I was able to re-create the issue. In the current scenario, it is not applying the I tried |
fix for |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale #4715 is still in review, so let's keep this issue open. |
While I agree there is definitely a reason to want Kustomize to fail if it does not make an intended patch, I believe this should be behavior that is configurable rather than a hard requirement. The behavior of not failing if a patch is not applied is a feature of the Remove this functionality entirely would force my Kustomize code to be much less DRY |
Considering that section 4 of https://www.rfc-editor.org/rfc/rfc6902 states that nonexitent target object MUST be an error but section 5 states:
It might be a good tradeoff to make this configurable and set the default to fail. SN: I concede it makes your code less Dry to state every affected object OTOH it also makes it less explicit and prone to overmatching. |
@Arabus When I read RFC 6902, I interpreted the spec as conditional on the assumption that there is a "target JSON document" to apply it to. For example, I interpreted the multiple of occurrences of "The target location MUST exist for the operation to be successful." to mean - only throw an error if there exists a "target JSON document" and within the document, the "target location" does not exist. Based on this interpretation, I don't think the RFC dictates whether we should throw an error for this issue, given that this issue debates how we should handle not finding a target document that satisfies our specified |
After further discussion with @KnVerey @natasha41575, in light of use cases like #4379 (comment) and @Arabus' suggestion #4379 (comment), we've decided to make the error-throwing upon finding no matching For For the deprecated |
Any news on this topic? Would be nice have this option in the near future. |
@hjannasch - I started looking into it and will update my PR #4715 soon. |
Update - Modified PR and it is in discussion with @annasong20 |
Describe the bug
If
kustomize build
is run with a patchesJson6902 section specifying a nonexistant target it still reports success and outputs its resources as if it workedFiles that can reproduce the issue
kustomization.yaml (note the 'v2' in the version field)
manifests/servicemonitor.yaml
jsonpatches/patch.0.yaml
Expected output
Some kind of error e.g, "WARNING: patchesJson6902[0] target not found for $target - please check kustomized resources for correctness" or "ERROR: patchesJson6902[0] target not found for $target! Bailing out."
An exit code > 0 to signal that something went wrong
Some suggestions of partial matches e.g., "Found $similartarget, did you mean $targetdiff?"
Actual output
Kustomize version
Platform
The text was updated successfully, but these errors were encountered: