Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change queue update in cli and e2e test to patch #661

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions pkg/cli/queue/operate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/spf13/cobra"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

const (
Expand Down Expand Up @@ -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 "":
Expand Down
10 changes: 3 additions & 7 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down