-
Notifications
You must be signed in to change notification settings - Fork 294
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
Escape hatch output does not appear in generated YAML #2172
Comments
This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. |
Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. |
I took some time to review this bug again. I've got one more solution idea which I think is promising - I've summarized the changes along with an example in this gist: https://gist.github.com/Chriscbr/8b8b15ffc22c30647cb861e0779e8b1d The core of this fix is to remove the I don't think this is necessarily a breaking change, but it might require some care since the updated k8s imports should not be generated by cdk8s-cli unless a compatible version of cdk8s is being used. Nonetheless, it does further cement the idea that cdk8s does not do any validations on data that is escape-hatched "into" the template. I think is directionally correct for what we want the escape hatching to do - minimize restrictions for the user, even if it means they get less type safety. @iliapolo curious to hear your thoughts. |
The one tricky part of this fix is whether it should be treated as a breaking change, and whether there's a way to make it backwards compatible. The problem is that if someone uses the newly-generated k8s imports with an old version of cdk8s that doesn't have the updated One option I considered was making the cdk8s CLI "version aware" so that it error or warns you if you try running So I think it probably makes more sense to make this change alongside a major version bump of But I'm also actively considering whether there's some way to make this backwards compatible 🤔 |
I agree, this problem makes escape hatches entirely unfriendly for modifications. Either fix it, or rename it to Escape mine field. |
Any news ? I didn't find an easy solution. It's only possible to modify/remove existing key with JSON patch. I can't add or copy a key right now 🤔 It's blocking me, because I really need |
@jagu-sayan You should be able to patch |
Just a note about this statement by @Chriscbr:
On the flip side - wouldn't it be nice if cdk8s could tell you when you escape hatch to a structure that doesn't fit the schema, and might therefore not be deployable? The current state of just ignoring this is definitely wrong, but I wonder if we should provide a choice between including those, or erroring out (maybe a config on the Chart level?) |
This issue has not received any attention in 1 year and will be closed soon. If you want to keep it open, please leave a comment below @mentioning a maintainer. |
Reopening as this has surfaced again: #2163 |
This escape hatch is a bit of a cruel joke. Like an emergency exit window that is just a painting of an emergency exit window~ |
Currently, the
JsonPatch
class can be used to apply overrides / updates to resources that have already been generated. However, sometimes these modifications do not appear in the generated YAML because of type mismatches, especially when newer kubernetes versions expectIntOrString
where they previously only required an int or string.For example, applying this patch to a
KubeDeployment
will producerollingUpdate: {}
:...while applying this patch to a KubeDeployment will produce
rollingUpdate: { maxSurge: 1, maxUnavailable: 0 }
(in YAML):This type of no-op did not occur in older versions of cdk8s, but it does now since cdk8s-team/cdk8s-cli#55, as the
toJson()
method on the generatedKubeDeployment
class callstoJson_KubeDeployment()
, which discards all values that were not expected (including in this case, values of the wrong type). (The patches get applied in the superclass,ApiObject
, beforetoJson_KubeDeployment()
is called).I think this is problematic since
JsonPatch
should be able to add any extra content (including from newer / older kubernetes specs) to theApiObject
, not just those expected by the interface, so that users can patch their constructs for older or newer kubernetes versions. It also has a clunky experience (Why did the JSON Patch values not appear? There's no error message!)Possible solutions:
toJson()
method in KubeDeployment instead callstoJsonUnpatched()
, thentoJson_KubeDeployment()
, and thenJsonPatch.apply(json, ...this.patches)
The text was updated successfully, but these errors were encountered: