Skip to content

Commit

Permalink
controllers: correctly set CurrentRevision for Statefulset
Browse files Browse the repository at this point in the history
it must fix an issue #547
  • Loading branch information
f41gh7 committed Nov 11, 2022
1 parent 5c66fc6 commit fc4abe6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions controllers/factory/k8stools/sts.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ func performRollingUpdateOnSts(ctx context.Context, wasRecreated bool, rclient c
// we check first pod revision label after re-creation
// it must contain valid statefulset revision
// See more at https://github.com/VictoriaMetrics/operator/issues/344
// It's needed for correct update restore process, when it was interrupted for some reason
// we have to check Current and Update revisions.
updatedPodRev := pod.Labels[podRevisionLabel]
var newRev string
// cases:
Expand All @@ -215,6 +217,13 @@ func performRollingUpdateOnSts(ctx context.Context, wasRecreated bool, rclient c
l.Info("pod was updated", "pod", pod.Name)
time.Sleep(time.Second * 1)
}
// another hack for correct update finish.
if sts.Status.UpdateRevision != sts.Status.CurrentRevision {
sts.Status.CurrentRevision = sts.Status.UpdateRevision
if err := rclient.Status().Update(ctx, sts); err != nil {
return fmt.Errorf("cannot update sts current revesion after sts updated finished, err: %w", err)
}
}

return nil

Expand Down

0 comments on commit fc4abe6

Please sign in to comment.