Skip to content

Commit

Permalink
remove unnecessary steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Pothulapati committed Oct 18, 2023
1 parent 39588ba commit 0c24186
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions internal/controller/dragonfly_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,32 +265,9 @@ func (r *DragonflyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
}

log.Info("Updated resources for object")

// perform a rollout only if the pod spec has changed
if err := r.Get(ctx, client.ObjectKey{Namespace: df.Namespace, Name: df.Name}, &statefulSet); err != nil {
log.Error(err, "could not get statefulset")
return ctrl.Result{}, err
}

// Check if the pod spec has changed
if statefulSet.Status.UpdatedReplicas != statefulSet.Status.Replicas {
log.Info("Pod spec has changed, performing a rollout")
r.EventRecorder.Event(&df, corev1.EventTypeNormal, "Rollout", "Starting a rollout")

// Start rollout and update status
// update status so that we can track progress
df.Status.IsRollingUpdate = true
if err := r.Status().Update(ctx, &df); err != nil {
log.Error(err, "could not update the Dragonfly object")
return ctrl.Result{Requeue: true}, err
}

// requeue so that the rollout is processed
return ctrl.Result{RequeueAfter: 5 * time.Second}, nil
}
r.EventRecorder.Event(&df, corev1.EventTypeNormal, "Resources", "Updated resources")
return ctrl.Result{Requeue: true}, nil
}
return ctrl.Result{}, nil
}

// SetupWithManager sets up the controller with the Manager.
Expand Down

0 comments on commit 0c24186

Please sign in to comment.