Skip to content

Commit c201b33

Browse files
authoredSep 16, 2022
test: Add additional node info to testing (#2521)
1 parent 4f0e003 commit c201b33

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed
 

‎pkg/controllers/node/initialization.go

+4-12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/aws/karpenter/pkg/apis/provisioning/v1alpha5"
2727
"github.com/aws/karpenter/pkg/cloudprovider"
28+
"github.com/aws/karpenter/pkg/utils/node"
2829
"github.com/aws/karpenter/pkg/utils/resources"
2930
)
3031

@@ -69,19 +70,10 @@ func (r *Initialization) getInstanceType(ctx context.Context, provisioner *v1alp
6970
// b) all the startup taints have been removed from the node
7071
// c) all extended resources have been registered
7172
// 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 {
7374
// 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)
8577
}
8678

8779
// isStartupTaintRemoved returns true if there are no startup taints registered for the provisioner, or if all startup

‎pkg/utils/node/node.go

+9
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ func GetNodePods(ctx context.Context, kubeClient client.Client, nodes ...*v1.Nod
4747
}
4848
return pods, nil
4949
}
50+
51+
func GetCondition(n *v1.Node, match v1.NodeConditionType) v1.NodeCondition {
52+
for _, condition := range n.Status.Conditions {
53+
if condition.Type == match {
54+
return condition
55+
}
56+
}
57+
return v1.NodeCondition{}
58+
}

‎test/pkg/environment/expectations.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242

4343
"github.com/aws/karpenter/pkg/apis/awsnodetemplate/v1alpha1"
4444
"github.com/aws/karpenter/pkg/apis/provisioning/v1alpha5"
45+
nodeutils "github.com/aws/karpenter/pkg/utils/node"
4546
"github.com/aws/karpenter/pkg/utils/pod"
4647
)
4748

@@ -94,8 +95,10 @@ func (env *Environment) BeforeEach() {
9495
}
9596

9697
func (env *Environment) dumpNodeInformation(nodes v1.NodeList) {
97-
for _, node := range nodes.Items {
98-
fmt.Printf("node %s taints = %v\n", node.Name, node.Spec.Taints)
98+
for i := range nodes.Items {
99+
node := nodes.Items[i]
100+
pods, _ := nodeutils.GetNodePods(env, env.Client, &node)
101+
fmt.Printf("node %s ready=%s initialized=%s pods=%d taints = %v\n", node.Name, nodeutils.GetCondition(&node, v1.NodeReady).Status, node.Labels[v1alpha5.LabelNodeInitialized], len(pods), node.Spec.Taints)
99102
}
100103
}
101104

‎test/suites/upgrade/pipeline.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ spec:
99
default: $(context.pipelineRun.namespace)-$(context.pipelineRun.name)
1010
description: Uniquely identifies a cluster name for the suite.
1111
- name: from-git-ref
12-
default: v0.15.0
12+
default: v0.16.1
1313
description: Git commit, tag, or branch to check out. Requires a corresponding Karpenter snapshot release.
1414
- name: to-git-ref
1515
default: HEAD

0 commit comments

Comments
 (0)
Please sign in to comment.