Skip to content

Commit

Permalink
operator: always update managedosversionchannel last sync time (#772)
Browse files Browse the repository at this point in the history
...also if we have an error on Pod creation.

Fixes commit 5ccde14

Signed-off-by: Francesco Giudici <[email protected]>
  • Loading branch information
fgiudici authored Jun 20, 2024
1 parent 5ccde14 commit 7227947
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions controllers/managedosversionchannel_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ func (r *ManagedOSVersionChannelReconciler) createSyncerPod(ctx context.Context,
},
}

// If we don't update the LastSyncedTime on Pod creation, we will loop
// creating/deleting the Pod after the ManagedOSVersionChannel.spec.syncInterval
// see https://github.com/rancher/elemental-operator/issues/766
now := metav1.Now()
ch.Status.LastSyncedTime = &now

err := r.Create(ctx, pod)
if err != nil {
logger.Error(err, "Failed creating pod", "pod", ch.Name)
Expand All @@ -463,12 +469,6 @@ func (r *ManagedOSVersionChannelReconciler) createSyncerPod(ctx context.Context,
return err
}

// If we don't update the LastSyncedTime on Pod creation, we will loop
// creating/deleting the Pod after the ManagedOSVersionChannel.spec.syncInterval
// see https://github.com/rancher/elemental-operator/issues/766
now := metav1.Now()
ch.Status.LastSyncedTime = &now

meta.SetStatusCondition(&ch.Status.Conditions, metav1.Condition{
Type: elementalv1.ReadyCondition,
Reason: elementalv1.SyncingReason,
Expand Down

0 comments on commit 7227947

Please sign in to comment.