volcano.sh/volcano@v1.9.0/pkg/controllers/queue/state/closed.go (about) 1 /* 2 Copyright 2019 The Volcano Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package state 18 19 import ( 20 "volcano.sh/apis/pkg/apis/bus/v1alpha1" 21 "volcano.sh/apis/pkg/apis/scheduling/v1beta1" 22 ) 23 24 type closedState struct { 25 queue *v1beta1.Queue 26 } 27 28 func (cs *closedState) Execute(action v1alpha1.Action) error { 29 switch action { 30 case v1alpha1.OpenQueueAction: 31 return OpenQueue(cs.queue, func(status *v1beta1.QueueStatus, podGroupList []string) { 32 status.State = v1beta1.QueueStateOpen 33 }) 34 case v1alpha1.CloseQueueAction: 35 return SyncQueue(cs.queue, func(status *v1beta1.QueueStatus, podGroupList []string) { 36 status.State = v1beta1.QueueStateClosed 37 }) 38 default: 39 return SyncQueue(cs.queue, func(status *v1beta1.QueueStatus, podGroupList []string) { 40 specState := cs.queue.Status.State 41 if specState == v1beta1.QueueStateOpen { 42 status.State = v1beta1.QueueStateOpen 43 return 44 } 45 46 if specState == v1beta1.QueueStateClosed { 47 status.State = v1beta1.QueueStateClosed 48 return 49 } 50 51 status.State = v1beta1.QueueStateUnknown 52 }) 53 } 54 }