volcano.sh/apis@v1.8.2/pkg/apis/scheduling/types.go (about) 1 /* 2 Copyright 2019 The Volcano Authors. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 http://www.apache.org/licenses/LICENSE-2.0 7 Unless required by applicable law or agreed to in writing, software 8 distributed under the License is distributed on an "AS IS" BASIS, 9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 See the License for the specific language governing permissions and 11 limitations under the License. 12 */ 13 14 package scheduling 15 16 import ( 17 v1 "k8s.io/api/core/v1" 18 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 19 ) 20 21 // PodGroupPhase is the phase of a pod group at the current time. 22 type PodGroupPhase string 23 24 // QueueState is state type of queue. 25 type QueueState string 26 27 const ( 28 // QueueStateOpen indicate `Open` state of queue 29 QueueStateOpen QueueState = "Open" 30 // QueueStateClosed indicate `Closed` state of queue 31 QueueStateClosed QueueState = "Closed" 32 // QueueStateClosing indicate `Closing` state of queue 33 QueueStateClosing QueueState = "Closing" 34 // QueueStateUnknown indicate `Unknown` state of queue 35 QueueStateUnknown QueueState = "Unknown" 36 ) 37 38 // These are the valid phase of podGroups. 39 const ( 40 // PodGroupPending means the pod group has been accepted by the system, but scheduler can not allocate 41 // enough resources to it. 42 PodGroupPending PodGroupPhase = "Pending" 43 44 // PodGroupRunning means `spec.minMember` pods of PodGroup has been in running phase. 45 PodGroupRunning PodGroupPhase = "Running" 46 47 // PodGroupUnknown means part of `spec.minMember` pods are running but the other part can not 48 // be scheduled, e.g. not enough resource; scheduler will wait for related controller to recover it. 49 PodGroupUnknown PodGroupPhase = "Unknown" 50 51 // PodGroupInqueue means controllers can start to create pods, 52 // is a new state between PodGroupPending and PodGroupRunning 53 PodGroupInqueue PodGroupPhase = "Inqueue" 54 55 // PodGroupCompleted means all the pods of PodGroup are completed 56 PodGroupCompleted PodGroupPhase = "Completed" 57 ) 58 59 type PodGroupConditionType string 60 61 const ( 62 // PodGroupUnschedulableType is Unschedulable event type 63 PodGroupUnschedulableType PodGroupConditionType = "Unschedulable" 64 65 // PodGroupScheduled is scheduled event type 66 PodGroupScheduled PodGroupConditionType = "Scheduled" 67 ) 68 69 type PodGroupConditionDetail string 70 71 const ( 72 // PodGroupReady is that PodGroup has reached scheduling restriction 73 PodGroupReady PodGroupConditionDetail = "pod group is ready" 74 // PodGroupNotReady is that PodGroup has not yet reached the scheduling restriction 75 PodGroupNotReady PodGroupConditionDetail = "pod group is not ready" 76 ) 77 78 // PodGroupCondition contains details for the current state of this pod group. 79 type PodGroupCondition struct { 80 // Type is the type of the condition 81 Type PodGroupConditionType 82 83 // Status is the status of the condition. 84 Status v1.ConditionStatus 85 86 // The ID of condition transition. 87 TransitionID string 88 89 // Last time the phase transitioned from another to current phase. 90 // +optional 91 LastTransitionTime metav1.Time 92 93 // Unique, one-word, CamelCase reason for the phase's last transition. 94 // +optional 95 Reason string 96 97 // Human-readable message indicating details about last transition. 98 // +optional 99 Message string 100 } 101 102 const ( 103 // PodFailedReason is probed if pod of PodGroup failed 104 PodFailedReason string = "PodFailed" 105 106 // PodDeletedReason is probed if pod of PodGroup deleted 107 PodDeletedReason string = "PodDeleted" 108 109 // NotEnoughResourcesReason is probed if there're not enough resources to schedule pods 110 NotEnoughResourcesReason string = "NotEnoughResources" 111 112 // NotEnoughPodsReason is probed if there're not enough tasks compared to `spec.minMember` 113 NotEnoughPodsReason string = "NotEnoughTasks" 114 ) 115 116 // QueueEvent represent the phase of queue. 117 type QueueEvent string 118 119 const ( 120 // QueueOutOfSyncEvent is triggered if PodGroup/Queue were updated 121 QueueOutOfSyncEvent QueueEvent = "OutOfSync" 122 // QueueCommandIssuedEvent is triggered if a command is raised by user 123 QueueCommandIssuedEvent QueueEvent = "CommandIssued" 124 ) 125 126 // QueueAction is the action that queue controller will take according to the event. 127 type QueueAction string 128 129 const ( 130 // SyncQueueAction is the action to sync queue status. 131 SyncQueueAction QueueAction = "SyncQueue" 132 // OpenQueueAction is the action to open queue 133 OpenQueueAction QueueAction = "OpenQueue" 134 // CloseQueueAction is the action to close queue 135 CloseQueueAction QueueAction = "CloseQueue" 136 ) 137 138 // +genclient 139 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 140 141 // PodGroup is a collection of Pod; used for batch workload. 142 // +kubebuilder:printcolumn:name="STATUS",type=string,JSONPath=`.status.phase` 143 // +kubebuilder:printcolumn:name="minMember",type=integer,JSONPath=`.spec.minMember` 144 // +kubebuilder:printcolumn:name="RUNNINGS",type=integer,JSONPath=`.status.running` 145 // +kubebuilder:printcolumn:name="AGE",type=date,JSONPath=`.metadata.creationTimestamp` 146 // +kubebuilder:printcolumn:name="QUEUE",type=string,priority=1,JSONPath=`.spec.queue` 147 type PodGroup struct { 148 metav1.TypeMeta 149 // Standard object's metadata. 150 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata 151 // +optional 152 metav1.ObjectMeta 153 154 // Specification of the desired behavior of the pod group. 155 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status 156 // +optional 157 Spec PodGroupSpec 158 159 // Status represents the current information about a pod group. 160 // This data may not be up to date. 161 // +optional 162 Status PodGroupStatus 163 } 164 165 // PodGroupSpec represents the template of a pod group. 166 type PodGroupSpec struct { 167 // MinMember defines the minimal number of members/tasks to run the pod group; 168 // if there's not enough resources to start all tasks, the scheduler 169 // will not start anyone. 170 MinMember int32 171 172 // MinTaskMember defines the minimal number of pods to run for each task in the pod group; 173 // if there's not enough resources to start each task, the scheduler 174 // will not start anyone. 175 MinTaskMember map[string]int32 176 177 // Queue defines the queue to allocate resource for PodGroup; if queue does not exist, 178 // the PodGroup will not be scheduled. 179 Queue string 180 181 // If specified, indicates the PodGroup's priority. "system-node-critical" and 182 // "system-cluster-critical" are two special keywords which indicate the 183 // highest priorities with the former being the highest priority. Any other 184 // name must be defined by creating a PriorityClass object with that name. 185 // If not specified, the PodGroup priority will be default or zero if there is no 186 // default. 187 // +optional 188 PriorityClassName string 189 190 // MinResources defines the minimal resource of members/tasks to run the pod group; 191 // if there's not enough resources to start all tasks, the scheduler 192 // will not start anyone. 193 MinResources *v1.ResourceList 194 } 195 196 // PodGroupStatus represents the current state of a pod group. 197 type PodGroupStatus struct { 198 // Current phase of PodGroup. 199 Phase PodGroupPhase 200 201 // The conditions of PodGroup. 202 // +optional 203 Conditions []PodGroupCondition 204 205 // The number of actively running pods. 206 // +optional 207 Running int32 208 209 // The number of pods which reached phase Succeeded. 210 // +optional 211 Succeeded int32 212 213 // The number of pods which reached phase Failed. 214 // +optional 215 Failed int32 216 } 217 218 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 219 220 // PodGroupList is a collection of pod groups. 221 type PodGroupList struct { 222 metav1.TypeMeta 223 // Standard list metadata 224 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata 225 // +optional 226 metav1.ListMeta 227 228 // items is the list of PodGroup 229 Items []PodGroup 230 } 231 232 // +genclient 233 // +genclient:nonNamespaced 234 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 235 236 // Queue is a queue of PodGroup. 237 type Queue struct { 238 metav1.TypeMeta 239 // Standard object's metadata. 240 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata 241 // +optional 242 metav1.ObjectMeta 243 244 // Specification of the desired behavior of the queue. 245 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status 246 // +optional 247 Spec QueueSpec 248 249 // The status of queue. 250 // +optional 251 Status QueueStatus 252 } 253 254 // Guarantee represents configuration of queue resource reservation 255 type Guarantee struct { 256 // The amount of cluster resource reserved for queue. Just set either `percentage` or `resource` 257 // +optional 258 Resource v1.ResourceList `json:"resource,omitempty" protobuf:"bytes,3,opt,name=resource"` 259 } 260 261 // Reservation represents current condition about resource reservation 262 type Reservation struct { 263 // Nodes are Locked nodes for queue 264 // +optional 265 Nodes []string `json:"nodes,omitempty" protobuf:"bytes,1,opt,name=nodes"` 266 // Resource is a list of total idle resource in locked nodes. 267 // +optional 268 Resource v1.ResourceList `json:"resource,omitempty" protobuf:"bytes,2,opt,name=resource"` 269 } 270 271 // QueueStatus represents the status of Queue. 272 type QueueStatus struct { 273 // State is status of queue 274 State QueueState 275 276 // The number of 'Unknown' PodGroup in this queue. 277 Unknown int32 278 // The number of 'Pending' PodGroup in this queue. 279 Pending int32 280 // The number of 'Running' PodGroup in this queue. 281 Running int32 282 // The number of `Inqueue` PodGroup in this queue. 283 Inqueue int32 284 // The number of `Completed` PodGroup in this queue. 285 Completed int32 286 287 // Reservation is the profile of resource reservation for queue 288 Reservation Reservation 289 290 // Allocated is allocated resources in queue 291 Allocated v1.ResourceList 292 } 293 294 // CluterSpec represents the template of Cluster 295 type Cluster struct { 296 Name string 297 Weight int32 298 Capacity v1.ResourceList 299 } 300 301 // Affinity is a group of affinity scheduling rules. 302 type Affinity struct { 303 // Describes nodegroup affinity scheduling rules for the queue. 304 // +optional 305 NodeGroupAffinity *NodeGroupAffinity `json:"nodeGroupAffinity,omitempty" protobuf:"bytes,1,opt,name=nodeGroupAffinity"` 306 307 // Describes nodegroup affinity scheduling rules for the queue. 308 // +optional 309 NodeGroupAntiAffinity *NodeGroupAntiAffinity `json:"nodeGroupAntiAffinity,omitempty" protobuf:"bytes,2,opt,name=nodeGroupAntiAffinity"` 310 } 311 312 type NodeGroupAffinity struct { 313 // +optional 314 RequiredDuringSchedulingIgnoredDuringExecution []string `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,1,opt,name=requiredDuringSchedulingIgnoredDuringExecution"` 315 // +optional 316 PreferredDuringSchedulingIgnoredDuringExecution []string `json:"preferredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,2,rep,name=preferredDuringSchedulingIgnoredDuringExecution"` 317 } 318 319 type NodeGroupAntiAffinity struct { 320 // +optional 321 RequiredDuringSchedulingIgnoredDuringExecution []string `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,1,opt,name=requiredDuringSchedulingIgnoredDuringExecution"` 322 // +optional 323 PreferredDuringSchedulingIgnoredDuringExecution []string `json:"preferredDuringSchedulingIgnoredDuringExecution,omitempty" protobuf:"bytes,2,rep,name=preferredDuringSchedulingIgnoredDuringExecution"` 324 } 325 326 // QueueSpec represents the template of Queue. 327 type QueueSpec struct { 328 Weight int32 329 Capability v1.ResourceList 330 331 // Depreicated: replaced by status.State 332 State QueueState 333 // Reclaimable indicate whether the queue can be reclaimed by other queue 334 Reclaimable *bool 335 336 // extendCluster indicate the jobs in this Queue will be dispatched to these clusters. 337 ExtendClusters []Cluster 338 339 // Guarantee indicate configuration about resource reservation 340 Guarantee Guarantee `json:"guarantee,omitempty" protobuf:"bytes,4,opt,name=guarantee"` 341 342 // If specified, the queue's scheduling constraints 343 // +optional 344 Affinity *Affinity `json:"affinity,omitempty" protobuf:"bytes,6,opt,name=affinity"` 345 346 // Type define the type of queue 347 Type string `json:"type,omitempty" protobuf:"bytes,7,opt,name=type"` 348 } 349 350 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 351 352 // QueueList is a collection of queues. 353 type QueueList struct { 354 metav1.TypeMeta 355 // Standard list metadata 356 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata 357 // +optional 358 metav1.ListMeta 359 360 // items is the list of PodGroup 361 Items []Queue 362 }