mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Do not reset managedFields in status update strategy
This commit is contained in:
parent
94cb60e0e8
commit
dfe1703ffa
@ -94,7 +94,12 @@ var StatusStrategy = flowSchemaStatusStrategy{Strategy}
|
||||
func (flowSchemaStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newFlowSchema := obj.(*flowcontrol.FlowSchema)
|
||||
oldFlowSchema := old.(*flowcontrol.FlowSchema)
|
||||
|
||||
// managedFields must be preserved since it's been modified to
|
||||
// track changed fields in the status update.
|
||||
managedFields := newFlowSchema.ManagedFields
|
||||
newFlowSchema.ObjectMeta = oldFlowSchema.ObjectMeta
|
||||
newFlowSchema.ManagedFields = managedFields
|
||||
newFlowSchema.Spec = oldFlowSchema.Spec
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,12 @@ var StatusStrategy = priorityLevelConfigurationStatusStrategy{Strategy}
|
||||
func (priorityLevelConfigurationStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newPriorityLevelConfiguration := obj.(*flowcontrol.PriorityLevelConfiguration)
|
||||
oldPriorityLevelConfiguration := old.(*flowcontrol.PriorityLevelConfiguration)
|
||||
|
||||
// managedFields must be preserved since it's been modified to
|
||||
// track changed fields in the status update.
|
||||
managedFields := newPriorityLevelConfiguration.ManagedFields
|
||||
newPriorityLevelConfiguration.ObjectMeta = oldPriorityLevelConfiguration.ObjectMeta
|
||||
newPriorityLevelConfiguration.ManagedFields = managedFields
|
||||
newPriorityLevelConfiguration.Spec = oldPriorityLevelConfiguration.Spec
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,10 @@ func (a statusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.O
|
||||
newCustomResource := newCustomResourceObject.UnstructuredContent()
|
||||
status, ok := newCustomResource["status"]
|
||||
|
||||
// managedFields must be preserved since it's been modified to
|
||||
// track changed fields in the status update.
|
||||
managedFields := newCustomResourceObject.GetManagedFields()
|
||||
|
||||
// copy old object into new object
|
||||
oldCustomResourceObject := old.(*unstructured.Unstructured)
|
||||
// overridding the resourceVersion in metadata is safe here, we have already checked that
|
||||
@ -45,6 +49,7 @@ func (a statusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.O
|
||||
*newCustomResourceObject = *oldCustomResourceObject.DeepCopy()
|
||||
|
||||
// set status
|
||||
newCustomResourceObject.SetManagedFields(managedFields)
|
||||
newCustomResource = newCustomResourceObject.UnstructuredContent()
|
||||
if ok {
|
||||
newCustomResource["status"] = status
|
||||
|
@ -252,7 +252,9 @@ func ResetObjectMetaForStatus(meta, existingMeta Object) {
|
||||
meta.SetAnnotations(existingMeta.GetAnnotations())
|
||||
meta.SetFinalizers(existingMeta.GetFinalizers())
|
||||
meta.SetOwnerReferences(existingMeta.GetOwnerReferences())
|
||||
meta.SetManagedFields(existingMeta.GetManagedFields())
|
||||
// managedFields must be preserved since it's been modified to
|
||||
// track changed fields in the status update.
|
||||
//meta.SetManagedFields(existingMeta.GetManagedFields())
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler
|
||||
|
@ -189,6 +189,7 @@ func TestResetObjectMetaForStatus(t *testing.T) {
|
||||
existingMeta.SetCreationTimestamp(Time{})
|
||||
existingMeta.SetDeletionTimestamp(nil)
|
||||
existingMeta.SetDeletionGracePeriodSeconds(nil)
|
||||
existingMeta.SetManagedFields(nil)
|
||||
|
||||
if !reflect.DeepEqual(meta, existingMeta) {
|
||||
t.Error(diff.ObjectDiff(meta, existingMeta))
|
||||
|
Loading…
Reference in New Issue
Block a user