diff --git a/pkg/restore/pod_action.go b/pkg/restore/pod_action.go index 858256631..bcdf299de 100644 --- a/pkg/restore/pod_action.go +++ b/pkg/restore/pod_action.go @@ -50,6 +50,9 @@ func (a *podAction) Execute(obj runtime.Unstructured, restore *api.Restore) (run a.logger.Debug("deleting spec.NodeName") delete(spec, "nodeName") + a.logger.Debug("deleting spec.priority") + delete(spec, "priority") + // if there are no volumes, then there can't be any volume mounts, so we're done. if !collections.Exists(spec, "volumes") { return obj, nil, nil diff --git a/pkg/restore/pod_action_test.go b/pkg/restore/pod_action_test.go index f32d94c42..9c1077df6 100644 --- a/pkg/restore/pod_action_test.go +++ b/pkg/restore/pod_action_test.go @@ -40,12 +40,20 @@ func TestPodActionExecute(t *testing.T) { { name: "nodeName (only) should be deleted from spec", obj: NewTestUnstructured().WithName("pod-1").WithSpec("nodeName", "foo"). - WithSpec("serviceAccountName", "foo"). WithSpecField("containers", []interface{}{}). Unstructured, expectedErr: false, expectedRes: NewTestUnstructured().WithName("pod-1").WithSpec("foo"). - WithSpec("serviceAccountName", "foo"). + WithSpecField("containers", []interface{}{}). + Unstructured, + }, + { + name: "priority (only) should be deleted from spec", + obj: NewTestUnstructured().WithName("pod-1").WithSpec("priority", "foo"). + WithSpecField("containers", []interface{}{}). + Unstructured, + expectedErr: false, + expectedRes: NewTestUnstructured().WithName("pod-1").WithSpec("foo"). WithSpecField("containers", []interface{}{}). Unstructured, }, diff --git a/pkg/restore/restore_test.go b/pkg/restore/restore_test.go index 2e10fdc61..5d35dc2a4 100644 --- a/pkg/restore/restore_test.go +++ b/pkg/restore/restore_test.go @@ -1605,6 +1605,9 @@ func (obj *testUnstructured) WithMetadata(fields ...string) *testUnstructured { } func (obj *testUnstructured) WithSpec(fields ...string) *testUnstructured { + if _, found := obj.Object["spec"]; found { + panic("spec already set - you probably didn't mean to do this twice!") + } return obj.withMap("spec", fields...) }