@@ -32,9 +32,9 @@ func TestGetNodePoolReadyAndMinCountExisting(t *testing.T) {
32
32
min : 35 ,
33
33
},
34
34
}
35
- status := mockClusterAutoscalerStatusPreV130 (t , nodePools )
35
+ status := mockClusterAutoscalerStatus (t , nodePools )
36
36
for _ , nodePool := range nodePools {
37
- ready , min , err := getNodePoolReadyAndMinCount ("v1.25.3 " , status , nodePool .name )
37
+ ready , min , err := getNodePoolReadyAndMinCount ("v1.31.2 " , status , nodePool .name )
38
38
require .NoError (t , err )
39
39
require .Equal (t , nodePool .ready , ready )
40
40
require .Equal (t , nodePool .min , min )
@@ -49,8 +49,8 @@ func TestGetNodePoolReadyAndMinCountNotFound(t *testing.T) {
49
49
min : 22 ,
50
50
},
51
51
}
52
- status := mockClusterAutoscalerStatusPreV130 (t , nodePools )
53
- _ , _ , err := getNodePoolReadyAndMinCount ("v1.25.3 " , status , "bar" )
52
+ status := mockClusterAutoscalerStatus (t , nodePools )
53
+ _ , _ , err := getNodePoolReadyAndMinCount ("v1.31.2 " , status , "bar" )
54
54
require .EqualError (t , err , "could not find status for node pool: bar" )
55
55
}
56
56
@@ -80,13 +80,13 @@ func TestHasScaleDownCapacity(t *testing.T) {
80
80
for _ , tt := range tests {
81
81
t .Run (tt .name , func (t * testing.T ) {
82
82
for _ , cp := range getNodePoolLabelKeys () {
83
- node , nodePoolName := getNodePoolNameAndNode (t , cp , "foobar" )
83
+ node , nodePoolName := getNodePoolNameAndNode (t , "v1.31.2" , cp , "foobar" )
84
84
nodePool := testNodePool {
85
85
name : nodePoolName ,
86
86
ready : tt .ready ,
87
87
min : tt .min ,
88
88
}
89
- status := mockClusterAutoscalerStatusPreV130 (t , []testNodePool {nodePool })
89
+ status := mockClusterAutoscalerStatus (t , []testNodePool {nodePool })
90
90
ok , err := HasScaleDownCapacity (status , node )
91
91
require .NoError (t , err )
92
92
require .Equal (t , tt .isSafe , ok )
@@ -101,44 +101,57 @@ type testNodePool struct {
101
101
min int
102
102
}
103
103
104
- func mockClusterAutoscalerStatusPreV130 (t * testing.T , nodePools []testNodePool ) string {
104
+ func mockClusterAutoscalerStatus (t * testing.T , nodePools []testNodePool ) string {
105
105
t .Helper ()
106
106
107
- status := `Cluster-autoscaler status at 2022-08-11 12:35:11.797051423 +0000 UTC:
108
- Cluster-wide:
109
- Health: Healthy (ready=10 unready=0 notStarted=0 longNotStarted=0 registered=10 longUnregistered=0)
110
- LastProbeTime: 2022-08-11 12:35:11.782449164 +0000 UTC m=+935528.106132475
111
- LastTransitionTime: 2022-08-08 10:28:18.652598604 +0000 UTC m=+668714.976282015
112
- ScaleUp: NoActivity (ready=10 registered=10)
113
- LastProbeTime: 2022-08-11 12:35:11.782449164 +0000 UTC m=+935528.106132475
114
- LastTransitionTime: 2022-08-08 11:57:06.468308057 +0000 UTC m=+674042.791991368
115
- ScaleDown: NoCandidates (candidates=0)
116
- LastProbeTime: 2022-08-11 12:35:11.782449164 +0000 UTC m=+935528.106132475
117
- LastTransitionTime: 2022-08-08 12:03:59.241031335 +0000 UTC m=+674455.564714746
118
-
119
- NodeGroups:`
107
+ status := `time: 2025-04-22 14:29:08.360891242 +0000 UTC
108
+ autoscalerStatus: Running
109
+ clusterWide:
110
+ health:
111
+ status: Healthy
112
+ nodeCounts:
113
+ registered:
114
+ total: 5
115
+ ready: 5
116
+ notStarted: 0
117
+ longUnregistered: 0
118
+ unregistered: 0
119
+ lastProbeTime: "2025-04-22T14:29:08.360891242Z"
120
+ lastTransitionTime: "2025-04-17T23:46:40.655271485Z"
121
+ scaleUp:
122
+ status: NoActivity
123
+ lastProbeTime: "2025-04-22T14:29:08.360891242Z"
124
+ lastTransitionTime: "2025-04-22T00:37:48.447964164Z"
125
+ scaleDown:
126
+ status: NoCandidates
127
+ lastProbeTime: "2025-04-22T14:29:08.360891242Z"
128
+ lastTransitionTime: "2025-04-22T00:48:01.870055554Z"
129
+ nodeGroups:`
120
130
121
131
//nolint:gocritic // ignore
122
132
for _ , nodePool := range nodePools {
123
- //nolint:lll // ignore
124
133
status = fmt .Sprintf (`%[1]s
125
- Name: %[2]s
126
- Health: Healthy (ready=%[3]d unready=0 notStarted=0 longNotStarted=0 registered=%[3]d longUnregistered=0 cloudProviderTarget=%[3]d (minSize=%[4]d, maxSize=0))
127
- LastProbeTime: 2022-08-11 12:35:11.782449164 +0000 UTC m=+935528.106132475
128
- LastTransitionTime: 2022-08-08 10:28:18.652598604 +0000 UTC m=+668714.976282015
129
- ScaleUp: NoActivity (ready=%[3]d cloudProviderTarget=%[3]d)
130
- LastProbeTime: 2022-08-11 12:35:11.782449164 +0000 UTC m=+935528.106132475
131
- LastTransitionTime: 2022-08-08 11:57:06.468308057 +0000 UTC m=+674042.791991368
132
- ScaleDown: NoCandidates (candidates=0)
133
- LastProbeTime: 2022-08-11 12:35:11.782449164 +0000 UTC m=+935528.106132475
134
- LastTransitionTime: 2022-08-08 12:03:59.241031335 +0000 UTC m=+674455.564714746
135
-
136
- ` , status , nodePool .name , nodePool .ready , nodePool .min )
134
+ - name: %[2]s
135
+ health:
136
+ status: Healthy
137
+ nodeCounts:
138
+ registered:
139
+ total: %[3]d
140
+ ready: %[3]d
141
+ notStarted: 0
142
+ longUnregistered: 0
143
+ unregistered: 0
144
+ cloudProviderTarget: %[3]d
145
+ minSize: %[4]d
146
+ maxSize: 10
147
+ lastProbeTime: "2025-04-22T14:29:08.360891242Z"
148
+ lastTransitionTime: "2025-04-17T23:46:40.655271485Z"` , status , nodePool .name , nodePool .ready , nodePool .min )
137
149
}
150
+
138
151
return status
139
152
}
140
153
141
- func getNodePoolNameAndNode (t * testing.T , cp string , name string ) (* corev1.Node , string ) {
154
+ func getNodePoolNameAndNode (t * testing.T , version string , cp string , name string ) (* corev1.Node , string ) {
142
155
t .Helper ()
143
156
144
157
switch cp {
@@ -154,7 +167,7 @@ func getNodePoolNameAndNode(t *testing.T, cp string, name string) (*corev1.Node,
154
167
},
155
168
Status : corev1.NodeStatus {
156
169
NodeInfo : corev1.NodeSystemInfo {
157
- KubeletVersion : "v1.25.3" ,
170
+ KubeletVersion : version ,
158
171
},
159
172
},
160
173
}, nodePoolName
@@ -169,10 +182,10 @@ func getNodePoolNameAndNode(t *testing.T, cp string, name string) (*corev1.Node,
169
182
},
170
183
Status : corev1.NodeStatus {
171
184
NodeInfo : corev1.NodeSystemInfo {
172
- KubeletVersion : "v1.25.3" ,
185
+ KubeletVersion : version ,
173
186
},
174
187
},
175
- }, fmt .Sprintf ("eks-%s-c8c2d2a8-2d51-8764-1776-0b3f58267273 " , eksNodePoolName )
188
+ }, fmt .Sprintf ("eks-%s-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} " , eksNodePoolName )
176
189
case KubemarkNodePoolLabelKey :
177
190
return & corev1.Node {
178
191
ObjectMeta : metav1.ObjectMeta {
@@ -183,7 +196,7 @@ func getNodePoolNameAndNode(t *testing.T, cp string, name string) (*corev1.Node,
183
196
},
184
197
Status : corev1.NodeStatus {
185
198
NodeInfo : corev1.NodeSystemInfo {
186
- KubeletVersion : "v1.25.3" ,
199
+ KubeletVersion : version ,
187
200
},
188
201
},
189
202
}, name
0 commit comments