@@ -25,6 +25,7 @@ import (
25
25
26
26
"github.com/aws/karpenter/pkg/apis/provisioning/v1alpha5"
27
27
"github.com/aws/karpenter/pkg/cloudprovider"
28
+ "github.com/aws/karpenter/pkg/utils/node"
28
29
"github.com/aws/karpenter/pkg/utils/resources"
29
30
)
30
31
@@ -69,19 +70,10 @@ func (r *Initialization) getInstanceType(ctx context.Context, provisioner *v1alp
69
70
// b) all the startup taints have been removed from the node
70
71
// c) all extended resources have been registered
71
72
// This method handles both nil provisioners and nodes without extended resources gracefully.
72
- func (r * Initialization ) isInitialized (node * v1.Node , provisioner * v1alpha5.Provisioner , instanceType cloudprovider.InstanceType ) bool {
73
+ func (r * Initialization ) isInitialized (n * v1.Node , provisioner * v1alpha5.Provisioner , instanceType cloudprovider.InstanceType ) bool {
73
74
// fast checks first
74
- return getCondition (node .Status .Conditions , v1 .NodeReady ).Status == v1 .ConditionTrue &&
75
- isStartupTaintRemoved (node , provisioner ) && isExtendedResourceRegistered (node , instanceType )
76
- }
77
-
78
- func getCondition (conditions []v1.NodeCondition , match v1.NodeConditionType ) v1.NodeCondition {
79
- for _ , condition := range conditions {
80
- if condition .Type == match {
81
- return condition
82
- }
83
- }
84
- return v1.NodeCondition {}
75
+ return node .GetCondition (n , v1 .NodeReady ).Status == v1 .ConditionTrue &&
76
+ isStartupTaintRemoved (n , provisioner ) && isExtendedResourceRegistered (n , instanceType )
85
77
}
86
78
87
79
// isStartupTaintRemoved returns true if there are no startup taints registered for the provisioner, or if all startup
0 commit comments