Skip to content

Commit 3499d41

Browse files
authored
refetch condition after SetStatusCondition to ensure the time is updated (#14)
1 parent 678c67f commit 3499d41

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,13 @@ const (
229229
func (r *MyReconciler) SetStatusCondition(cr *v1.MyCR, cond metav1.Condition) bool {
230230
changed := meta.SetStatusCondition(&cr.Status.Conditions, cond)
231231
if changed {
232-
r.Recorder.RecordConditionFor(
233-
kind, cr, cond.Type, string(cond.Status), cond.Reason, cond.LastTransitionTime,
234-
)
232+
// refetch the condition to get the updated version
233+
updated := meta.FindStatusCondition(cr.Status.Conditions, cond.Type)
234+
if updated != nil {
235+
r.Recorder.RecordConditionFor(
236+
kind, cr, updated.Type, string(updated.Status), updated.Reason, updated.LastTransitionTime,
237+
)
238+
}
235239
}
236240
return changed
237241
}

0 commit comments

Comments
 (0)