diff --git a/test/e2e_node/dra_test.go b/test/e2e_node/dra_test.go index 3bf1111984d..e2db6e7a047 100644 --- a/test/e2e_node/dra_test.go +++ b/test/e2e_node/dra_test.go @@ -26,6 +26,7 @@ package e2enode import ( "context" + "encoding/json" "errors" "fmt" "net" @@ -47,6 +48,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + apitypes "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/client-go/kubernetes" "k8s.io/component-base/metrics/testutil" @@ -1736,14 +1738,17 @@ func createHealthTestPodAndClaim(ctx context.Context, f *framework.Framework, dr e2epod.DeletePodOrFail(ctx, f.ClientSet, createdPod.Namespace, createdPod.Name) }) - // Update the Pod's status to include the ResourceClaimStatuses, mimicking the scheduler. - podToUpdate, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(ctx, createdPod.Name, metav1.GetOptions{}) - framework.ExpectNoError(err) - podToUpdate.Status.ResourceClaimStatuses = []v1.PodResourceClaimStatus{ - {Name: claimName, ResourceClaimName: &claimName}, - } - _, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).UpdateStatus(ctx, podToUpdate, metav1.UpdateOptions{}) - framework.ExpectNoError(err, "failed to update Pod status with ResourceClaimStatuses") + // Patch the Pod's status to include the ResourceClaimStatuses, mimicking the scheduler. + patch, err := json.Marshal(v1.Pod{ + Status: v1.PodStatus{ + ResourceClaimStatuses: []v1.PodResourceClaimStatus{ + {Name: claimName, ResourceClaimName: &claimName}, + }, + }, + }) + framework.ExpectNoError(err, "failed to marshal patch for Pod status") + _, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Patch(ctx, createdPod.Name, apitypes.StrategicMergePatchType, patch, metav1.PatchOptions{}, "status") + framework.ExpectNoError(err, "failed to patch Pod status with ResourceClaimStatuses") ginkgo.By(fmt.Sprintf("Allocating claim %q to pod %q with its real UID", claimName, podName)) // Get the created claim to ensure the latest version before updating.