enable strict JSON spec unmarshalling#2202
Conversation
c83563c to
6e84dfd
Compare
f79c746 to
a984354
Compare
|
I think this would break invalid Prometheus CRs:
Another issue - during upgrade we apply new CRDs when old operator is running:
until operator is upgraded. In existing mode it would just be silently skipped. I'm not convinced we should change existing behaviour, however a good documentation around this choice would be useful |
|
I wonder if we can limit strict parsing to new objects only - perhaps in a webhook? |
|
anyway in a linked issue I've described workaround, created this PR just in case |
seems like expected behavior when webhooks are enabled. currenty webhooks reject CRs with specs that have fields with invalid data type or value and mark resource as failed and allow to apply it when webhooks are disabled. with this change the same behaviour is added for unsupported fields.
we keep noop CR properties for a long time, so this concern should be covered as well |
This is critical though - the change would apply to existing objects, however I think its safer to apply this to new objects only |
Not sure, user may have a valid spec applied, but then he may try to upgrade it to one with unsupported fields. Should operator tolerate it? |
|
Its indistinguishable from "operator removed a field and now whatever user has set previously now unsupported" - I think we should allow that, giving users time to migrate instead of failing immediately. |
okay, seems like you mean it to be a temporary step before prohibiting unknown fields completely |
|
Oh yes, that is the intention - however I think we should take it slow and not break users - ideally even if they ignore deprecation warnings if possible |
a984354 to
8bd43ae
Compare
|
updated PR, please take a look |
related issue VictoriaMetrics/helm-charts#2882
Summary by cubic
Enable strict JSON unmarshalling for all Operator CR specs. Creates now fail fast on unknown fields, while updates that only include unknown fields to this operator version are allowed to support safe downgrades.
Bug Fixes
UnmarshalSpecStrict(lenient pass +DisallowUnknownFields) and routed all CRUnmarshalJSON(v1,v1alpha1,v1beta1) through it, settingParsingSpecErroron failure.HasUnknownFieldsand updated webhooks to reject on create, but allow updates when the error is only "unknown field".VMAlertmanagerConfigtests/fixtures to valid fields (msteams_configs, propercustom_fields).Migration
Written for commit 8bd43ae. Summary will update on new commits. Review in cubic