Skip to content

Commit

Permalink
restart pods with version mismatch immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Oct 19, 2023
1 parent 13a95df commit 75a517c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions internal/fullnode/pod_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ func (pc PodControl) Reconcile(ctx context.Context, reporter kube.Reporter, crd
}

if len(diffed.Updates()) > 0 {
versionUpdated := false
for _, update := range diffed.Updates() {
for _, p := range pods.Items {
if p.Name == update.Name {
if p.Spec.Containers[0].Image != update.Spec.Containers[0].Image {
// version update, delete pod now.
reporter.Info("Deleting pod for version update", "podName", p.Name)
if err := pc.client.Delete(ctx, &p, client.PropagationPolicy(metav1.DeletePropagationForeground)); client.IgnoreNotFound(err) != nil {
return true, kube.TransientError(fmt.Errorf("update pod %q: %w", p.Name, err))
}
versionUpdated = true
}
}
}
}

if versionUpdated {
// Signal requeue.
return true, nil
}

var (
// This may be a source of confusion by passing currentPods vs. pods from diff.Updates().
// This is a leaky abstraction (which may be fixed in the future) because diff.Updates() pods are built
Expand Down

0 comments on commit 75a517c

Please sign in to comment.