Closed munnerz closed 1 week ago
My only concern when implementing this so far, is currently markers do not recurse into sub-schemas. Is this intentional, and are there issues in doing this sort of recursive lookup?
An example of a problematic declarative default in a core type: https://github.com/kubernetes/api/blob/5147c1a32f6a0b9b155bb84e59f933e0ff8a3792/core/v1/types.go#L2144
Sounds reasonable to me. No idea, about the recursive lookup.
Not really familiar with the current implementation but maybe some sort of "post-processing" to remove previously added defaults recursively would work? (not sure if that's different to what you suggested)
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/reopen
/remove-lifecycle rotten
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
When generating schemas that reference external types, sometimes it is helpful to be able to avoid setting 'default' markers for fields within the type's schema.
As noted in https://github.com/kubernetes/kubernetes/issues/95587 - it is recommended that defaulting should be skipped for templates of other resources (instead allowing the apiserver to set these defaults with this template is actually submitted to the apiserver).
Without a way to avoid generating these defaults, any controller that relies on hashing of say, a PodTemplate to determine whether an update is needed to the Pod will not be able to know if the object has actually changed and needs an update, or if a new field is introduced.
This is especially problematic when you consider stateful systems, as a change to a CRD that introduces a new default value will trigger a re-creation of all underlying pods.
Many alternatives are discussed in https://github.com/kubernetes/community/pull/6764 to solve this, including having controllers only hash the fields they are interested in. This is problematic because over time as new fields are added, controllers may 'miss' these and therefore not trigger updates when the value is actually changed either.
Proposal
Adding a new marker that can be set on fields, e.g.
//+ kubebuilder:default:skip=true
which will causedefault
values to not be set in the generated sub-schema.