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
Server-Side Apply status wiping #99661
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import ( | |
"k8s.io/kubernetes/pkg/apis/apps" | ||
"k8s.io/kubernetes/pkg/apis/apps/validation" | ||
"k8s.io/kubernetes/pkg/features" | ||
"sigs.k8s.io/structured-merge-diff/v4/fieldpath" | ||
) | ||
|
||
// daemonSetStrategy implements verification logic for daemon sets. | ||
|
@@ -68,6 +69,18 @@ func (daemonSetStrategy) NamespaceScoped() bool { | |
return true | ||
} | ||
|
||
// GetResetFields returns the set of fields that get reset by the strategy | ||
// and should not be modified by the user. | ||
func (daemonSetStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { | ||
fields := map[fieldpath.APIVersion]*fieldpath.Set{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How many times are these functions called? It would be a shame to construct this map for every request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're called at initialization time, once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For builtin types it gets called by the endpoints installer so it shouldn't be constructed for every request, right? And for CRDs it's built by the scope which is called in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, good point Kevin: "getOrCreateServingInfoFor" is (surprisingly) called for every request! |
||
"apps/v1": fieldpath.NewSet( | ||
fieldpath.MakePathOrDie("status"), | ||
), | ||
} | ||
|
||
return fields | ||
} | ||
|
||
// PrepareForCreate clears the status of a daemon set before creation. | ||
func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { | ||
daemonSet := obj.(*apps.DaemonSet) | ||
|
@@ -202,6 +215,16 @@ type daemonSetStatusStrategy struct { | |
// StatusStrategy is the default logic invoked when updating object status. | ||
var StatusStrategy = daemonSetStatusStrategy{Strategy} | ||
|
||
// GetResetFields returns the set of fields that get reset by the strategy | ||
// and should not be modified by the user. | ||
func (daemonSetStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { | ||
return map[fieldpath.APIVersion]*fieldpath.Set{ | ||
"apps/v1": fieldpath.NewSet( | ||
fieldpath.MakePathOrDie("spec"), | ||
), | ||
} | ||
} | ||
|
||
func (daemonSetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { | ||
newDaemonSet := obj.(*apps.DaemonSet) | ||
oldDaemonSet := old.(*apps.DaemonSet) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function name is not very clear. "Reset" is a verb at least as often as a noun which makes it especially confusing.
What is the difference between "reset" and "disabled" fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case "Reset" is an adjective. A "reset field" is a field that should be cleared from the field managers set of fields that it owns.
We've been looking for a better name for over a year and haven't found one I guess https://github.com/kubernetes/enhancements/pull/1123/files#r356309605
A disabled field is a field on an object used by a feature flag that is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not happy with the naming, I remember we talked about this in the past (like a year ago) but didn't find something better. In SMD it's called ignoredFields right now as it suits the specific context more, but ignoredFields does not really fit here I think.