1
1
/*
2
- Copyright 2018 The Kubernetes Authors.
2
+ Copyright 2019 The Kubernetes Authors.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -14,52 +14,54 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- package scheduling
17
+ package v1
18
18
19
19
import (
20
20
"fmt"
21
+ "k8s.io/api/scheduling/v1"
21
22
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23
+ "k8s.io/kubernetes/pkg/apis/scheduling"
22
24
)
23
25
24
26
// SystemPriorityClasses define system priority classes that are auto-created at cluster bootstrapping.
25
27
// Our API validation logic ensures that any priority class that has a system prefix or its value
26
28
// is higher than HighestUserDefinablePriority is equal to one of these SystemPriorityClasses.
27
- var systemPriorityClasses = []* PriorityClass {
29
+ var systemPriorityClasses = []* v1. PriorityClass {
28
30
{
29
31
ObjectMeta : metav1.ObjectMeta {
30
- Name : SystemNodeCritical ,
32
+ Name : scheduling . SystemNodeCritical ,
31
33
},
32
- Value : SystemCriticalPriority + 1000 ,
34
+ Value : scheduling . SystemCriticalPriority + 1000 ,
33
35
Description : "Used for system critical pods that must not be moved from their current node." ,
34
36
},
35
37
{
36
38
ObjectMeta : metav1.ObjectMeta {
37
- Name : SystemClusterCritical ,
39
+ Name : scheduling . SystemClusterCritical ,
38
40
},
39
- Value : SystemCriticalPriority ,
41
+ Value : scheduling . SystemCriticalPriority ,
40
42
Description : "Used for system critical pods that must run in the cluster, but can be moved to another node if necessary." ,
41
43
},
42
44
}
43
45
44
46
// SystemPriorityClasses returns the list of system priority classes.
45
47
// NOTE: be careful not to modify any of elements of the returned array directly.
46
- func SystemPriorityClasses () []* PriorityClass {
48
+ func SystemPriorityClasses () []* v1. PriorityClass {
47
49
return systemPriorityClasses
48
50
}
49
51
50
- // IsKnownSystemPriorityClass checks that "pc" is equal to one of the system PriorityClasses.
51
- // It ignores "description ", labels, annotations, etc. of the PriorityClass .
52
- func IsKnownSystemPriorityClass (pc * PriorityClass ) (bool , error ) {
53
- for _ , spc := range systemPriorityClasses {
54
- if spc .Name == pc . Name {
55
- if spc .Value != pc . Value {
52
+ // IsKnownSystemPriorityClass returns true if there's any of the system priority classes exactly
53
+ // matches "name ", "value", "globalDefault". otherwise it will return an error .
54
+ func IsKnownSystemPriorityClass (name string , value int32 , globalDefault bool ) (bool , error ) {
55
+ for _ , spc := range SystemPriorityClasses () {
56
+ if spc .Name == name {
57
+ if spc .Value != value {
56
58
return false , fmt .Errorf ("value of %v PriorityClass must be %v" , spc .Name , spc .Value )
57
59
}
58
- if spc .GlobalDefault != pc . GlobalDefault {
60
+ if spc .GlobalDefault != globalDefault {
59
61
return false , fmt .Errorf ("globalDefault of %v PriorityClass must be %v" , spc .Name , spc .GlobalDefault )
60
62
}
61
63
return true , nil
62
64
}
63
65
}
64
- return false , fmt .Errorf ("%v is not a known system priority class" , pc . Name )
66
+ return false , fmt .Errorf ("%v is not a known system priority class" , name )
65
67
}
0 commit comments