@@ -19,6 +19,7 @@ import (
1919
2020 "github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
2121 . "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants" //nolint:revive,stylecheck
22+ "github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
2223 "github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
2324)
2425
@@ -213,49 +214,40 @@ func (r *Reconciler) waitForStatefulSetToScale(
213214 r .Recorder .Event (
214215 storageNodeSet ,
215216 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 ),
218219 )
219220 return Stop , ctrl.Result {RequeueAfter : DefaultRequeueDelay }, err
220221 }
221222 r .Recorder .Event (
222223 storageNodeSet ,
223224 corev1 .EventTypeWarning ,
224- "Syncing " ,
225- fmt .Sprintf ("Failed to get StatefulSets : %s" , err ),
225+ "ControllerError " ,
226+ fmt .Sprintf ("Failed to get StatefulSet : %s" , err ),
226227 )
227228 return Stop , ctrl.Result {RequeueAfter : DefaultRequeueDelay }, err
228229 }
229230
230- matchingLabels := client.MatchingLabels {}
231- for k , v := range storageNodeSet .Labels {
232- matchingLabels [k ] = v
233- }
234-
235231 podList := & corev1.PodList {}
236232 opts := []client.ListOption {
237233 client .InNamespace (storageNodeSet .Namespace ),
238- matchingLabels ,
234+ client. MatchingLabels { labels . StatefulsetComponent : storageNodeSet . Name } ,
239235 }
240- if err = r .List (ctx , podList , opts ... ); err != nil {
236+
237+ err = r .List (ctx , podList , opts ... )
238+ if err != nil {
241239 r .Recorder .Event (
242240 storageNodeSet ,
243241 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 ),
246244 )
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- })
253245 return Stop , ctrl.Result {RequeueAfter : DefaultRequeueDelay }, err
254246 }
255247
256248 runningPods := 0
257249 for _ , e := range podList .Items {
258- if e . Status . Phase == "Running" {
250+ if resources . PodIsReady ( e ) {
259251 runningPods ++
260252 }
261253 }
@@ -265,7 +257,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
265257 storageNodeSet ,
266258 corev1 .EventTypeNormal ,
267259 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 ),
269261 )
270262 meta .SetStatusCondition (& storageNodeSet .Status .Conditions , metav1.Condition {
271263 Type : NodeSetProvisionedCondition ,
@@ -281,7 +273,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
281273 Type : NodeSetProvisionedCondition ,
282274 Status : metav1 .ConditionTrue ,
283275 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 ),
285277 })
286278 return r .updateStatus (ctx , storageNodeSet , StatusUpdateRequeueDelay )
287279 }
0 commit comments