Do not add managed fields if a scale entry doesn't own replicas
This happens when a request changes the .status.replicas but not .spec.replicas Kubernetes-commit: 8e4b5c849b67b3a12dbd63391a4e75234382ba2c
This commit is contained in:
parent
8c0975e184
commit
9c3786c066
|
@ -135,6 +135,9 @@ func (h *ScaleHandler) ToParent(scaleEntries []metav1.ManagedFieldsEntry) ([]met
|
|||
}
|
||||
|
||||
for manager, versionedSet := range scaleFields {
|
||||
if !versionedSet.Set().Has(replicasPathInScale) {
|
||||
continue
|
||||
}
|
||||
newVersionedSet := fieldpath.NewVersionedSet(
|
||||
fieldpath.NewSet(h.mappings[h.groupVersion.String()]),
|
||||
fieldpath.APIVersion(h.groupVersion.String()),
|
||||
|
|
|
@ -463,7 +463,7 @@ func TestTransformingManagedFieldsToParent(t *testing.T) {
|
|||
Operation: metav1.ManagedFieldsOperationApply,
|
||||
APIVersion: "apps/v1",
|
||||
FieldsType: "FieldsV1",
|
||||
FieldsV1: &metav1.FieldsV1{Raw: []byte(`{"f:spec":{"f:replicas":{},"f:selector":{}}}`)},
|
||||
FieldsV1: &metav1.FieldsV1{Raw: []byte(`{"f:spec":{"f:selector":{}}}`)},
|
||||
},
|
||||
},
|
||||
subresource: []metav1.ManagedFieldsEntry{
|
||||
|
@ -472,7 +472,7 @@ func TestTransformingManagedFieldsToParent(t *testing.T) {
|
|||
Operation: metav1.ManagedFieldsOperationUpdate,
|
||||
APIVersion: "autoscaling/v1",
|
||||
FieldsType: "FieldsV1",
|
||||
FieldsV1: &metav1.FieldsV1{Raw: []byte(`{"f:spec":{"f:another":{}}}`)},
|
||||
FieldsV1: &metav1.FieldsV1{Raw: []byte(`{"f:status":{"f:replicas":{}}}`)},
|
||||
Subresource: "scale",
|
||||
},
|
||||
},
|
||||
|
@ -484,14 +484,6 @@ func TestTransformingManagedFieldsToParent(t *testing.T) {
|
|||
FieldsType: "FieldsV1",
|
||||
FieldsV1: &metav1.FieldsV1{Raw: []byte(`{"f:spec":{"f:selector":{}}}`)},
|
||||
},
|
||||
{
|
||||
Manager: "scale",
|
||||
Operation: metav1.ManagedFieldsOperationUpdate,
|
||||
APIVersion: "apps/v1",
|
||||
FieldsType: "FieldsV1",
|
||||
FieldsV1: &metav1.FieldsV1{Raw: []byte(`{"f:spec":{"f:replicas":{}}}`)},
|
||||
Subresource: "scale",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue