-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Do not allow extra fields when validating CRDs #297
Comments
We renamed `inputSourceBindings` (and `outputSourceBindings`) to `resources` in tektoncd#148 where we also moved the specification of these bindings into the `PipelineRun` - now the `resources` section in the `Pipeline` itself exists just to specify dependencies between resources. But we missed one in the example! Also created tektoncd#297 to follow up on catching this in validation.
We renamed `inputSourceBindings` (and `outputSourceBindings`) to `resources` in #148 where we also moved the specification of these bindings into the `PipelineRun` - now the `resources` section in the `Pipeline` itself exists just to specify dependencies between resources. But we missed one in the example! Also created #297 to follow up on catching this in validation.
For this to be fixed we'd need pruning to be enabled in kubernetes -- it is not implemented yet. |
Thanks for the links @hoegaarden !! Question about pruning @hoegaarden - if we prune away the extra fields, does that imply we're ignoring them? I think we definitely want to tell the user they provided some incorrect fields? In the meantime, maybe we could create our own hacky sort of solution, e.g. inspect the fields somehow before or after deserializing? Maybe we can make openapi validation help us? |
@bobcatfish I have a prototype that uses the content of the This is basically the json form of the resource that the kubctl cli puts here. wdyt? |
(whoops @dgageot sorry this took so long to reply to!) That's an interesting idea - in that case, would we only realize there were extra fields after the resource is created? I'd be interested in seeing the prototype! |
@bobcatfish see #422 |
@jonjohnsonjr mentioned we might want to leave these here to make schema upgrades easier. Is that still the case? |
It doesn't make schema upgrades easier, but it does make downgrades possible. If you don't allow unknown fields and you ever plan to add a new field, your users won't be able to downgrade build-pipeline, because the new field will be unrecognized by the old build-pipeline. You can get around this by staging new fields for 1 release (but disallowing them) and only allowing n-1 downgrades, but it's a bit delicate. |
Expected Behavior
If I typo a field in an optional field in a CRD (i.e. provide an extra field), the validation webhook (or worst case, runtime check) should tell me the CRD is invalid.
Actual Behavior
"Extra" fields are ignored, for example in the demo pipeline, there was a bug where one of the instances of
inputSourceBindings
was not renamed toresources
:https://github.com/knative/build-pipeline/blob/c9341e7f0e5dae53a4c5b1638401b4d65401f1b3/examples/pipeline.yaml#L24-L44
This was ignored (and everything still worked b/c at that time the Pipeline executed in the order it was declared in).
Steps to Reproduce the Problem
helloIDoNotBelong: foo
:The text was updated successfully, but these errors were encountered: