@@ -126,19 +126,23 @@ func (r *ReconcilePodOpsLifecycle) Reconcile(ctx context.Context, request reconc
126
126
return reconcile.Result {}, err
127
127
}
128
128
129
- // If all lifecycle is finished, or the is no lifecycle begined
129
+ // All lifecycles are finished, or no lifecycle begined
130
130
if len (idToLabelsMap ) == 0 {
131
131
updated , err := r .addServiceAvailable (pod )
132
- if updated {
133
- r .Recorder .Eventf (pod , corev1 .EventTypeNormal , "ServiceAvailable" , "Label pod as service available, error: %v" , err )
132
+ if err != nil {
134
133
return reconcile.Result {}, err
135
134
}
135
+ if updated {
136
+ return reconcile.Result {}, nil
137
+ }
136
138
137
139
updated , err = r .updateServiceReadiness (ctx , pod , true )
138
- if updated {
139
- r .Recorder .Eventf (pod , corev1 .EventTypeNormal , "ReadinessGate" , "Set service ready readiness gate to true, error: %v" , err )
140
+ if err != nil {
140
141
return reconcile.Result {}, err
141
142
}
143
+ if updated {
144
+ return reconcile.Result {}, nil
145
+ }
142
146
}
143
147
144
148
// Get the state of pod managed by TransitionRule
@@ -181,7 +185,6 @@ func (r *ReconcilePodOpsLifecycle) Reconcile(ctx context.Context, request reconc
181
185
return reconcile.Result {}, err // Only need set once
182
186
}
183
187
if updated {
184
- r .Recorder .Eventf (pod , corev1 .EventTypeNormal , "ReadinessGate" , "Set service ready readiness gate to %v" , v )
185
188
return reconcile.Result {}, nil
186
189
}
187
190
}
@@ -325,6 +328,9 @@ func (r *ReconcilePodOpsLifecycle) updateServiceReadiness(ctx context.Context, p
325
328
326
329
return false , err
327
330
}
331
+
332
+ r .Recorder .Eventf (pod , corev1 .EventTypeNormal , v1alpha1 .ServiceReadyEvent , "Set ReadinessGate service-ready to %v" , isReady )
333
+
328
334
return true , nil
329
335
}
330
336
@@ -436,7 +442,6 @@ func (r *ReconcilePodOpsLifecycle) addLabels(ctx context.Context, pod *corev1.Po
436
442
r .Logger .Error (err , "failed to update pod with labels" , "pod" , utils .ObjectKeyString (pod ), "labels" , labels )
437
443
r .expectation .DeleteExpectations (key )
438
444
}
439
- r .Recorder .Eventf (pod , corev1 .EventTypeNormal , "UpdatePod" , "Succeed to update labels: %v" , labels )
440
445
441
446
return err
442
447
}
0 commit comments