@@ -19,6 +19,7 @@ import (
19
19
20
20
"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
21
21
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants" //nolint:revive,stylecheck
22
+ "github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
22
23
"github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
23
24
)
24
25
@@ -213,49 +214,40 @@ func (r *Reconciler) waitForStatefulSetToScale(
213
214
r .Recorder .Event (
214
215
storageNodeSet ,
215
216
corev1 .EventTypeWarning ,
216
- "Syncing " ,
217
- fmt .Sprintf ("Failed to found StatefulSet : %s" , err ),
217
+ "ProvisioningFailed " ,
218
+ fmt .Sprintf ("StatefulSet with name %s was not found : %s" , storageNodeSet . Name , err ),
218
219
)
219
220
return Stop , ctrl.Result {RequeueAfter : DefaultRequeueDelay }, err
220
221
}
221
222
r .Recorder .Event (
222
223
storageNodeSet ,
223
224
corev1 .EventTypeWarning ,
224
- "Syncing " ,
225
- fmt .Sprintf ("Failed to get StatefulSets : %s" , err ),
225
+ "ControllerError " ,
226
+ fmt .Sprintf ("Failed to get StatefulSet : %s" , err ),
226
227
)
227
228
return Stop , ctrl.Result {RequeueAfter : DefaultRequeueDelay }, err
228
229
}
229
230
230
- matchingLabels := client.MatchingLabels {}
231
- for k , v := range storageNodeSet .Labels {
232
- matchingLabels [k ] = v
233
- }
234
-
235
231
podList := & corev1.PodList {}
236
232
opts := []client.ListOption {
237
233
client .InNamespace (storageNodeSet .Namespace ),
238
- matchingLabels ,
234
+ client. MatchingLabels { labels . StatefulsetComponent : storageNodeSet . Name } ,
239
235
}
240
- if err = r .List (ctx , podList , opts ... ); err != nil {
236
+
237
+ err = r .List (ctx , podList , opts ... )
238
+ if err != nil {
241
239
r .Recorder .Event (
242
240
storageNodeSet ,
243
241
corev1 .EventTypeWarning ,
244
- "Syncing " ,
245
- fmt .Sprintf ("Failed to list storageNodeSet pods: %s" , err ),
242
+ "ControllerError " ,
243
+ fmt .Sprintf ("Failed to list StatefulSet pods: %s" , err ),
246
244
)
247
- meta .SetStatusCondition (& storageNodeSet .Status .Conditions , metav1.Condition {
248
- Type : NodeSetProvisionedCondition ,
249
- Status : metav1 .ConditionFalse ,
250
- Reason : ReasonInProgress ,
251
- Message : "Failed to check Pods .status.phase" ,
252
- })
253
245
return Stop , ctrl.Result {RequeueAfter : DefaultRequeueDelay }, err
254
246
}
255
247
256
248
runningPods := 0
257
249
for _ , e := range podList .Items {
258
- if e . Status . Phase == "Running" {
250
+ if resources . PodIsReady ( e ) {
259
251
runningPods ++
260
252
}
261
253
}
@@ -265,7 +257,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
265
257
storageNodeSet ,
266
258
corev1 .EventTypeNormal ,
267
259
string (StorageNodeSetProvisioning ),
268
- fmt .Sprintf ("Waiting for number of running storageNodeSet pods to match expected: %d != %d" , runningPods , storageNodeSet .Spec .Nodes ),
260
+ fmt .Sprintf ("Waiting for number of running nodes to match expected: %d != %d" , runningPods , storageNodeSet .Spec .Nodes ),
269
261
)
270
262
meta .SetStatusCondition (& storageNodeSet .Status .Conditions , metav1.Condition {
271
263
Type : NodeSetProvisionedCondition ,
@@ -281,7 +273,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
281
273
Type : NodeSetProvisionedCondition ,
282
274
Status : metav1 .ConditionTrue ,
283
275
Reason : ReasonCompleted ,
284
- Message : fmt .Sprintf ("Scaled StorageNodeSet to %d successfully " , storageNodeSet .Spec .Nodes ),
276
+ Message : fmt .Sprintf ("Successfully scaled to desired number of nodes: %d " , storageNodeSet .Spec .Nodes ),
285
277
})
286
278
return r .updateStatus (ctx , storageNodeSet , StatusUpdateRequeueDelay )
287
279
}
0 commit comments