Preserve UID/ResourceVersion in the BindingREST endpoint

Change-Id: If4023da10c455963a320fdb9fc2a73c099bea3db
This commit is contained in:
Aldo Culquicondor
2023-03-16 16:35:39 -04:00
parent d1dfa89953
commit 62889f416c
3 changed files with 22 additions and 2 deletions

View File

@@ -163,6 +163,7 @@ func (r *BindingREST) Destroy() {
}
var _ = rest.NamedCreater(&BindingREST{})
var _ = rest.SubresourceObjectMetaPreserver(&BindingREST{})
// Create ensures a pod is bound to a specific host.
func (r *BindingREST) Create(ctx context.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (out runtime.Object, err error) {
@@ -191,6 +192,13 @@ func (r *BindingREST) Create(ctx context.Context, name string, obj runtime.Objec
return
}
// PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate indicates to a
// handler that this endpoint requires the UID and ResourceVersion to use as
// preconditions. Other fields, such as timestamp, are ignored.
func (r *BindingREST) PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate() bool {
return true
}
// setPodHostAndAnnotations sets the given pod's host to 'machine' if and only if
// the pod is unassigned and merges the provided annotations with those of the pod.
// Returns the current state of the pod, or an error.