From 79f45bce19d1d832cc30812b8cf2a192ebe76d97 Mon Sep 17 00:00:00 2001 From: Anish Shah Date: Tue, 29 Oct 2024 21:09:47 +0000 Subject: [PATCH] client-go: rename Resize to UpdateResize --- staging/src/k8s.io/api/core/v1/types.go | 2 +- .../client-go/kubernetes/typed/core/v1/fake/fake_pod.go | 4 ++-- .../src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go | 6 +++--- test/integration/pods/pods_test.go | 6 +++--- test/integration/scheduler/queue_test.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index a551425c910..9f1c3ec6035 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -4911,7 +4911,7 @@ type PodStatusResult struct { // +genclient // +genclient:method=UpdateEphemeralContainers,verb=update,subresource=ephemeralcontainers -// +genclient:method=Resize,verb=update,subresource=resize +// +genclient:method=UpdateResize,verb=update,subresource=resize // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:prerelease-lifecycle-gen:introduced=1.0 diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_pod.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_pod.go index 4d970b35fea..bb3972560a5 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_pod.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_pod.go @@ -208,8 +208,8 @@ func (c *FakePods) UpdateEphemeralContainers(ctx context.Context, podName string return obj.(*v1.Pod), err } -// Resize takes the representation of a pod and updates it. Returns the server's representation of the pod, and an error, if there is any. -func (c *FakePods) Resize(ctx context.Context, podName string, pod *v1.Pod, opts metav1.UpdateOptions) (result *v1.Pod, err error) { +// UpdateResize takes the representation of a pod and updates it. Returns the server's representation of the pod, and an error, if there is any. +func (c *FakePods) UpdateResize(ctx context.Context, podName string, pod *v1.Pod, opts metav1.UpdateOptions) (result *v1.Pod, err error) { emptyResult := &v1.Pod{} obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceActionWithOptions(podsResource, "resize", c.ns, pod, opts), &v1.Pod{}) diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go index 5dc95b5d671..072a559414d 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go @@ -52,7 +52,7 @@ type PodInterface interface { // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). ApplyStatus(ctx context.Context, pod *applyconfigurationscorev1.PodApplyConfiguration, opts metav1.ApplyOptions) (result *corev1.Pod, err error) UpdateEphemeralContainers(ctx context.Context, podName string, pod *corev1.Pod, opts metav1.UpdateOptions) (*corev1.Pod, error) - Resize(ctx context.Context, podName string, pod *corev1.Pod, opts metav1.UpdateOptions) (*corev1.Pod, error) + UpdateResize(ctx context.Context, podName string, pod *corev1.Pod, opts metav1.UpdateOptions) (*corev1.Pod, error) PodExpansion } @@ -93,8 +93,8 @@ func (c *pods) UpdateEphemeralContainers(ctx context.Context, podName string, po return } -// Resize takes the top resource name and the representation of a pod and updates it. Returns the server's representation of the pod, and an error, if there is any. -func (c *pods) Resize(ctx context.Context, podName string, pod *corev1.Pod, opts metav1.UpdateOptions) (result *corev1.Pod, err error) { +// UpdateResize takes the top resource name and the representation of a pod and updates it. Returns the server's representation of the pod, and an error, if there is any. +func (c *pods) UpdateResize(ctx context.Context, podName string, pod *corev1.Pod, opts metav1.UpdateOptions) (result *corev1.Pod, err error) { result = &corev1.Pod{} err = c.GetClient().Put(). UseProtobufAsDefault(). diff --git a/test/integration/pods/pods_test.go b/test/integration/pods/pods_test.go index 0214c5f0ce0..c137a3311cb 100644 --- a/test/integration/pods/pods_test.go +++ b/test/integration/pods/pods_test.go @@ -766,7 +766,7 @@ func TestPodResizeRBAC(t *testing.T) { v1.ResourceEphemeralStorage: resource.MustParse("2Gi"), }, } - _, err = saClient.CoreV1().Pods(ns.Name).Resize(context.TODO(), resp.Name, resp, metav1.UpdateOptions{}) + _, err = saClient.CoreV1().Pods(ns.Name).UpdateResize(context.TODO(), resp.Name, resp, metav1.UpdateOptions{}) if tc.allowResize && err != nil { t.Fatalf("Unexpected pod resize failure: %v", err) integration.DeletePodOrErrorf(t, adminClient, ns.Name, pod.Name) @@ -878,7 +878,7 @@ func TestPodResize(t *testing.T) { integration.DeletePodOrErrorf(t, client, ns.Name, pod.Name) } - resp, err = client.CoreV1().Pods(ns.Name).Resize(context.TODO(), resp.Name, resp, metav1.UpdateOptions{}) + resp, err = client.CoreV1().Pods(ns.Name).UpdateResize(context.TODO(), resp.Name, resp, metav1.UpdateOptions{}) if tc.valid && err != nil { t.Fatalf("Unexpected pod resize failure: %v", err) integration.DeletePodOrErrorf(t, client, ns.Name, pod.Name) @@ -894,7 +894,7 @@ func TestPodResize(t *testing.T) { continue } resp.Spec.Containers[0].Resources = tc.originalRes - _, err = client.CoreV1().Pods(ns.Name).Resize(context.TODO(), resp.Name, resp, metav1.UpdateOptions{}) + _, err = client.CoreV1().Pods(ns.Name).UpdateResize(context.TODO(), resp.Name, resp, metav1.UpdateOptions{}) if tc.valid && err != nil { t.Fatalf("Unexpected pod resize failure: %v", err) integration.DeletePodOrErrorf(t, client, ns.Name, pod.Name) diff --git a/test/integration/scheduler/queue_test.go b/test/integration/scheduler/queue_test.go index 70f21b1ac0a..78df6a7be27 100644 --- a/test/integration/scheduler/queue_test.go +++ b/test/integration/scheduler/queue_test.go @@ -406,7 +406,7 @@ func TestCoreResourceEnqueue(t *testing.T) { triggerFn: func(testCtx *testutils.TestContext) (map[framework.ClusterEvent]uint64, error) { // Trigger a PodUpdate event by reducing cpu requested by pod1. // It makes Pod1 schedulable. - if _, err := testCtx.ClientSet.CoreV1().Pods(testCtx.NS.Name).Resize(testCtx.Ctx, "pod1", st.MakePod().Name("pod1").Req(map[v1.ResourceName]string{v1.ResourceCPU: "2"}).Container("image").Obj(), metav1.UpdateOptions{}); err != nil { + if _, err := testCtx.ClientSet.CoreV1().Pods(testCtx.NS.Name).UpdateResize(testCtx.Ctx, "pod1", st.MakePod().Name("pod1").Req(map[v1.ResourceName]string{v1.ResourceCPU: "2"}).Container("image").Obj(), metav1.UpdateOptions{}); err != nil { return nil, fmt.Errorf("failed to resize the pod: %w", err) } return map[framework.ClusterEvent]uint64{{Resource: unschedulablePod, ActionType: framework.UpdatePodScaleDown}: 1}, nil