Skip to content

Commit

Permalink
Remove State from QueueSpec in v1beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
thandayuthapani committed Feb 8, 2020
1 parent d5cb25a commit 2296dc3
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 22 deletions.
3 changes: 0 additions & 3 deletions pkg/apis/scheduling/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,6 @@ type QueueSpec struct {
Weight int32 `json:"weight,omitempty" protobuf:"bytes,1,opt,name=weight"`
Capability v1.ResourceList `json:"capability,omitempty" protobuf:"bytes,2,opt,name=capability"`

// State controller the status of queue
State QueueState `json:"state,omitempty" protobuf:"bytes,3,opt,name=state"`

// Reclaimable indicate whether the queue can be reclaimed by other queue
Reclaimable *bool `json:"reclaimable,omitempty" protobuf:"bytes,3,opt,name=reclaimable"`
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/scheduling/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pkg/cli/queue/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ func CreateQueue() error {
},
Spec: schedulingv1beta1.QueueSpec{
Weight: int32(createQueueFlags.Weight),
State: schedulingv1beta1.QueueState(createQueueFlags.State),
},
Status: schedulingv1beta1.QueueStatus{
State: schedulingv1beta1.QueueState(createQueueFlags.State),
},
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/queue/queue_controller_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func (c *Controller) openQueue(queue *schedulingv1beta1.Queue, updateStateFn sta
klog.V(4).Infof("Begin to open queue %s.", queue.Name)

newQueue := queue.DeepCopy()
newQueue.Spec.State = schedulingv1beta1.QueueStateOpen
newQueue.Status.State = schedulingv1beta1.QueueStateOpen

if queue.Spec.State != newQueue.Spec.State {
if queue.Status.State != newQueue.Status.State {
if _, err := c.vcClient.SchedulingV1beta1().Queues().Update(newQueue); err != nil {
c.recorder.Event(newQueue, v1.EventTypeWarning, string(v1alpha1.OpenQueueAction),
fmt.Sprintf("Open queue failed for %v", err))
Expand Down Expand Up @@ -126,9 +126,9 @@ func (c *Controller) closeQueue(queue *schedulingv1beta1.Queue, updateStateFn st
klog.V(4).Infof("Begin to close queue %s.", queue.Name)

newQueue := queue.DeepCopy()
newQueue.Spec.State = schedulingv1beta1.QueueStateClosed
newQueue.Status.State = schedulingv1beta1.QueueStateClosed

if queue.Spec.State != newQueue.Spec.State {
if queue.Status.State != newQueue.Status.State {
if _, err := c.vcClient.SchedulingV1beta1().Queues().Update(newQueue); err != nil {
c.recorder.Event(newQueue, v1.EventTypeWarning, string(v1alpha1.CloseQueueAction),
fmt.Sprintf("Close queue failed for %v", err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/queue/state/closed.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (cs *closedState) Execute(action v1alpha1.Action) error {
})
default:
return SyncQueue(cs.queue, func(status *v1beta1.QueueStatus, podGroupList []string) {
specState := cs.queue.Spec.State
specState := cs.queue.Status.State
if specState == v1beta1.QueueStateOpen {
status.State = v1beta1.QueueStateOpen
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/queue/state/closing.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (cs *closingState) Execute(action v1alpha1.Action) error {
})
default:
return SyncQueue(cs.queue, func(status *v1beta1.QueueStatus, podGroupList []string) {
specState := cs.queue.Spec.State
specState := cs.queue.Status.State
if specState == v1beta1.QueueStateOpen {
status.State = v1beta1.QueueStateOpen
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/queue/state/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (os *openState) Execute(action v1alpha1.Action) error {
})
default:
return SyncQueue(os.queue, func(status *v1beta1.QueueStatus, podGroupList []string) {
specState := os.queue.Spec.State
specState := os.queue.Status.State
if len(specState) == 0 || specState == v1beta1.QueueStateOpen {
status.State = v1beta1.QueueStateOpen
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/queue/state/unknown.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (us *unknownState) Execute(action v1alpha1.Action) error {
})
default:
return SyncQueue(us.queue, func(status *v1beta1.QueueStatus, podGroupList []string) {
specState := us.queue.Spec.State
specState := us.queue.Status.State
if specState == v1beta1.QueueStateOpen {
status.State = v1beta1.QueueStateOpen
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhooks/admission/jobs/validate/admit_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func validateJob(job *v1alpha1.Job, reviewResponse *v1beta1.AdmissionResponse) s
} else {
if queue.Status.State != schedulingv1beta1.QueueStateOpen {
msg = msg + fmt.Sprintf("can only submit job to queue with state `Open`, "+
"queue `%s` status is `%s`", queue.Name, queue.Spec.State)
"queue `%s` status is `%s`", queue.Name, queue.Status.State)
}
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/webhooks/admission/queues/mutate/mutate_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ func TestMutateQueues(t *testing.T) {
},
Spec: schedulingv1beta1.QueueSpec{
Weight: 1,
State: schedulingv1beta1.QueueStateOpen,
Reclaimable: &trueValue,
},
Status: schedulingv1beta1.QueueStatus{
State: schedulingv1beta1.QueueStateOpen,
},
}

openStateJSON, err := json.Marshal(openStateReclaimableSet)
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhooks/admission/queues/validate/validate_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func validateQueue(queue *schedulingv1beta1.Queue) error {
errs := field.ErrorList{}
resourcePath := field.NewPath("requestBody")

errs = append(errs, validateStateOfQueue(queue.Spec.State, resourcePath.Child("spec").Child("state"))...)
errs = append(errs, validateStateOfQueue(queue.Status.State, resourcePath.Child("spec").Child("state"))...)

if len(errs) > 0 {
return errs.ToAggregate()
Expand Down
14 changes: 9 additions & 5 deletions pkg/webhooks/admission/queues/validate/validate_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func TestAdmitQueues(t *testing.T) {
},
Spec: schedulingv1beta1.QueueSpec{
Weight: 1,
State: schedulingv1beta1.QueueStateOpen,
},
Status: schedulingv1beta1.QueueStatus{
State: schedulingv1beta1.QueueStateOpen,
},
}

Expand All @@ -69,7 +71,9 @@ func TestAdmitQueues(t *testing.T) {
},
Spec: schedulingv1beta1.QueueSpec{
Weight: 1,
State: schedulingv1beta1.QueueStateClosed,
},
Status: schedulingv1beta1.QueueStatus{
State: schedulingv1beta1.QueueStateClosed,
},
}

Expand All @@ -84,7 +88,9 @@ func TestAdmitQueues(t *testing.T) {
},
Spec: schedulingv1beta1.QueueSpec{
Weight: 1,
State: "wrong",
},
Status: schedulingv1beta1.QueueStatus{
State: "wrong",
},
}

Expand All @@ -99,7 +105,6 @@ func TestAdmitQueues(t *testing.T) {
},
Spec: schedulingv1beta1.QueueSpec{
Weight: 1,
State: schedulingv1beta1.QueueStateOpen,
},
Status: schedulingv1beta1.QueueStatus{
State: schedulingv1beta1.QueueStateOpen,
Expand All @@ -117,7 +122,6 @@ func TestAdmitQueues(t *testing.T) {
},
Spec: schedulingv1beta1.QueueSpec{
Weight: 1,
State: schedulingv1beta1.QueueStateClosed,
},
Status: schedulingv1beta1.QueueStatus{
State: schedulingv1beta1.QueueStateClosed,
Expand Down

0 comments on commit 2296dc3

Please sign in to comment.