From 597aaf1bb1ecdc56517e8d3a38cc06d44260aa7a Mon Sep 17 00:00:00 2001 From: Zhang Jinghui Date: Tue, 7 Jan 2020 14:43:09 +0800 Subject: [PATCH] change queue update in cli and e2e test to patch --- pkg/cli/queue/operate.go | 12 +++--------- test/e2e/util.go | 10 +++------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/pkg/cli/queue/operate.go b/pkg/cli/queue/operate.go index ac37f979b2..be66adab8f 100644 --- a/pkg/cli/queue/operate.go +++ b/pkg/cli/queue/operate.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/cobra" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" ) const ( @@ -84,14 +84,8 @@ func OperateQueue() error { } queueClient := versioned.NewForConfigOrDie(config) - queue, err := queueClient.SchedulingV1alpha2().Queues().Get(operateQueueFlags.Name, metav1.GetOptions{}) - if err != nil { - return err - } - - queue.Spec.Weight = int32(operateQueueFlags.Weight) - - _, err = queueClient.SchedulingV1alpha2().Queues().Update(queue) + patchBytes := []byte(fmt.Sprintf(`{"spec":{"weight":%d}}`, operateQueueFlags.Weight)) + _, err := queueClient.SchedulingV1alpha2().Queues().Patch(operateQueueFlags.Name, types.MergePatchType, patchBytes) return err case "": diff --git a/test/e2e/util.go b/test/e2e/util.go index ccdbc3dad1..c9aa9313d3 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -229,14 +229,10 @@ func deleteQueues(cxt *context) { foreground := metav1.DeletePropagationForeground for _, q := range cxt.queues { - queue, err := cxt.vcclient.SchedulingV1alpha2().Queues().Get(q, metav1.GetOptions{}) + patchBytes := []byte(fmt.Sprintf(`{"spec":{"state":"%s"}}`, schedulingv1alpha2.QueueStateClosed)) + _, err := cxt.vcclient.SchedulingV1alpha2().Queues().Patch(q, types.MergePatchType, patchBytes) Expect(err).NotTo(HaveOccurred()) - - queue.Spec.State = schedulingv1alpha2.QueueStateClosed - _, err = cxt.vcclient.SchedulingV1alpha2().Queues().Update(queue) - Expect(err).NotTo(HaveOccurred()) - - err = wait.Poll(100*time.Millisecond, oneMinute, queueClosed(cxt, queue.Name)) + err = wait.Poll(100*time.Millisecond, oneMinute, queueClosed(cxt, q)) Expect(err).NotTo(HaveOccurred()) err = cxt.vcclient.SchedulingV1alpha2().Queues().Delete(q, &metav1.DeleteOptions{