Skip to content

Commit

Permalink
Changed pod restarts to only happen if we alter passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
evyatarmeged committed Jun 24, 2024
1 parent a3b20e2 commit 55bd4fe
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,17 @@ func (e *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
if err != nil {
return ctrl.Result{}, errors.Wrap(err)
}
}

if hasRestartAnnotation(pod) {
logrus.Debug("Triggering pod restart for newly created secret")
err := e.TriggerPodRestart(ctx, &pod)
if err != nil {
e.recorder.Eventf(&pod, v1.EventTypeWarning,
ReasonRestartingPodAfterSecretRotationFailed, "Failed restarting pod after secret creation: %s", err.Error())
// We only move on to restart if the pod has any database annotations
// Basically, we did not run "alter password" in any databases, we don't need to trigger restarts
if hasRestartAnnotation(pod) {
logrus.Debug("Triggering pod restart for newly created secret")
err := e.TriggerPodRestart(ctx, &pod)
if err != nil {
e.recorder.Eventf(&pod, v1.EventTypeWarning,
ReasonRestartingPodAfterSecretRotationFailed, "Failed restarting pod after secret creation: %s", err.Error())
}
}

}

e.recorder.Event(&pod, v1.EventTypeNormal, ReasonEnsuredPodUserAndPassword, "Ensured user-password credentials in specified secret")
Expand Down

0 comments on commit 55bd4fe

Please sign in to comment.