diff --git a/pkg/apis/scheduling/v1beta1/types.go b/pkg/apis/scheduling/v1beta1/types.go index 67e12e5a6e3..9cb0def4df2 100644 --- a/pkg/apis/scheduling/v1beta1/types.go +++ b/pkg/apis/scheduling/v1beta1/types.go @@ -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"` } diff --git a/pkg/apis/scheduling/v1beta1/zz_generated.conversion.go b/pkg/apis/scheduling/v1beta1/zz_generated.conversion.go index 9f5c29b2fd0..caa68bea175 100644 --- a/pkg/apis/scheduling/v1beta1/zz_generated.conversion.go +++ b/pkg/apis/scheduling/v1beta1/zz_generated.conversion.go @@ -349,7 +349,6 @@ func Convert_scheduling_QueueList_To_v1beta1_QueueList(in *scheduling.QueueList, func autoConvert_v1beta1_QueueSpec_To_scheduling_QueueSpec(in *QueueSpec, out *scheduling.QueueSpec, s conversion.Scope) error { out.Weight = in.Weight out.Capability = *(*v1.ResourceList)(unsafe.Pointer(&in.Capability)) - out.State = scheduling.QueueState(in.State) out.Reclaimable = (*bool)(unsafe.Pointer(in.Reclaimable)) return nil } @@ -362,7 +361,7 @@ func Convert_v1beta1_QueueSpec_To_scheduling_QueueSpec(in *QueueSpec, out *sched func autoConvert_scheduling_QueueSpec_To_v1beta1_QueueSpec(in *scheduling.QueueSpec, out *QueueSpec, s conversion.Scope) error { out.Weight = in.Weight out.Capability = *(*v1.ResourceList)(unsafe.Pointer(&in.Capability)) - out.State = QueueState(in.State) + // WARNING: in.State requires manual conversion: does not exist in peer-type out.Reclaimable = (*bool)(unsafe.Pointer(in.Reclaimable)) return nil } diff --git a/pkg/cli/queue/create.go b/pkg/cli/queue/create.go index cea436fd1b5..2ff74a17c39 100644 --- a/pkg/cli/queue/create.go +++ b/pkg/cli/queue/create.go @@ -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), }, } diff --git a/pkg/controllers/queue/queue_controller_action.go b/pkg/controllers/queue/queue_controller_action.go index 664294cc7d2..7cae18a30d6 100644 --- a/pkg/controllers/queue/queue_controller_action.go +++ b/pkg/controllers/queue/queue_controller_action.go @@ -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)) @@ -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)) diff --git a/pkg/controllers/queue/state/closed.go b/pkg/controllers/queue/state/closed.go index 9bfecc4a840..76e5490f8d1 100644 --- a/pkg/controllers/queue/state/closed.go +++ b/pkg/controllers/queue/state/closed.go @@ -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 diff --git a/pkg/controllers/queue/state/closing.go b/pkg/controllers/queue/state/closing.go index 0faa5b623fa..fba06d68197 100644 --- a/pkg/controllers/queue/state/closing.go +++ b/pkg/controllers/queue/state/closing.go @@ -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 diff --git a/pkg/controllers/queue/state/open.go b/pkg/controllers/queue/state/open.go index 0defe1d744a..22d54c760c1 100644 --- a/pkg/controllers/queue/state/open.go +++ b/pkg/controllers/queue/state/open.go @@ -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 diff --git a/pkg/controllers/queue/state/unknown.go b/pkg/controllers/queue/state/unknown.go index e176fd84c68..467fda0b627 100644 --- a/pkg/controllers/queue/state/unknown.go +++ b/pkg/controllers/queue/state/unknown.go @@ -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 diff --git a/pkg/webhooks/admission/jobs/validate/admit_job.go b/pkg/webhooks/admission/jobs/validate/admit_job.go index b9f38baa2a3..533789fddcc 100644 --- a/pkg/webhooks/admission/jobs/validate/admit_job.go +++ b/pkg/webhooks/admission/jobs/validate/admit_job.go @@ -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) } } diff --git a/pkg/webhooks/admission/queues/mutate/mutate_queue_test.go b/pkg/webhooks/admission/queues/mutate/mutate_queue_test.go index 42ba8cb82d1..741fdd87fea 100644 --- a/pkg/webhooks/admission/queues/mutate/mutate_queue_test.go +++ b/pkg/webhooks/admission/queues/mutate/mutate_queue_test.go @@ -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) diff --git a/pkg/webhooks/admission/queues/validate/validate_queue.go b/pkg/webhooks/admission/queues/validate/validate_queue.go index d775377dc80..56d1aca1303 100644 --- a/pkg/webhooks/admission/queues/validate/validate_queue.go +++ b/pkg/webhooks/admission/queues/validate/validate_queue.go @@ -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() diff --git a/pkg/webhooks/admission/queues/validate/validate_queue_test.go b/pkg/webhooks/admission/queues/validate/validate_queue_test.go index 3d0eaad445a..3e03da99bef 100644 --- a/pkg/webhooks/admission/queues/validate/validate_queue_test.go +++ b/pkg/webhooks/admission/queues/validate/validate_queue_test.go @@ -54,7 +54,9 @@ func TestAdmitQueues(t *testing.T) { }, Spec: schedulingv1beta1.QueueSpec{ Weight: 1, - State: schedulingv1beta1.QueueStateOpen, + }, + Status: schedulingv1beta1.QueueStatus{ + State: schedulingv1beta1.QueueStateOpen, }, } @@ -69,7 +71,9 @@ func TestAdmitQueues(t *testing.T) { }, Spec: schedulingv1beta1.QueueSpec{ Weight: 1, - State: schedulingv1beta1.QueueStateClosed, + }, + Status: schedulingv1beta1.QueueStatus{ + State: schedulingv1beta1.QueueStateClosed, }, } @@ -84,7 +88,9 @@ func TestAdmitQueues(t *testing.T) { }, Spec: schedulingv1beta1.QueueSpec{ Weight: 1, - State: "wrong", + }, + Status: schedulingv1beta1.QueueStatus{ + State: "wrong", }, } @@ -99,7 +105,6 @@ func TestAdmitQueues(t *testing.T) { }, Spec: schedulingv1beta1.QueueSpec{ Weight: 1, - State: schedulingv1beta1.QueueStateOpen, }, Status: schedulingv1beta1.QueueStatus{ State: schedulingv1beta1.QueueStateOpen, @@ -117,7 +122,6 @@ func TestAdmitQueues(t *testing.T) { }, Spec: schedulingv1beta1.QueueSpec{ Weight: 1, - State: schedulingv1beta1.QueueStateClosed, }, Status: schedulingv1beta1.QueueStatus{ State: schedulingv1beta1.QueueStateClosed,