@@ -122,7 +122,7 @@ func (r *ImpVMSnapshotReconciler) Reconcile(ctx context.Context, req ctrl.Reques
122122 // Design rule 3 & 4: decide whether to create a new child.
123123 if snap .Spec .Schedule == "" {
124124 // One-shot: create child only if no children exist at all.
125- if len (childList . Items ) == 0 {
125+ if len (children ) == 0 {
126126 if err := r .createChild (ctx , snap ); err != nil {
127127 return ctrl.Result {}, err
128128 }
@@ -147,7 +147,8 @@ func (r *ImpVMSnapshotReconciler) Reconcile(ctx context.Context, req ctrl.Reques
147147 return ctrl.Result {}, err
148148 }
149149 // Requeue after the next scheduled slot.
150- next = sched .Next (time .Now ())
150+ now = time .Now ()
151+ next = sched .Next (now )
151152 untilNext = time .Until (next )
152153 }
153154
@@ -168,7 +169,7 @@ func (r *ImpVMSnapshotReconciler) Reconcile(ctx context.Context, req ctrl.Reques
168169func (r * ImpVMSnapshotReconciler ) createChild (ctx context.Context , parent * impv1alpha1.ImpVMSnapshot ) error {
169170 log := logf .FromContext (ctx )
170171
171- childName := parent .Name + "-" + time .Now ().UTC ().Format ("20060102-1504 " )
172+ childName := parent .Name + "-" + time .Now ().UTC ().Format ("20060102-150405 " )
172173
173174 childSpec := parent .Spec .DeepCopy ()
174175 childSpec .Schedule = "" // clear schedule on child
@@ -207,5 +208,6 @@ func (r *ImpVMSnapshotReconciler) createChild(ctx context.Context, parent *impv1
207208func (r * ImpVMSnapshotReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
208209 return ctrl .NewControllerManagedBy (mgr ).
209210 For (& impv1alpha1.ImpVMSnapshot {}).
211+ Owns (& impv1alpha1.ImpVMSnapshot {}).
210212 Complete (r )
211213}
0 commit comments