Skip to content

[PLAT-129166] fix parallel db update #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -427,7 +428,10 @@ func (c *RolloutController) hasStatefulSetNotReadyPods(sts *v1.StatefulSet) (boo
// We can quickly check the number of ready replicas reported by the StatefulSet.
// If they don't match the total number of replicas, then we're sure there are some
// not ready pods.
if sts.Status.Replicas != sts.Status.ReadyReplicas {
// This is causing issues when enable parallel db update (delete multiple pods at the same time):
// 1. use Spec.Replicas instead of Status.Replicas because of deleting multiple pods at the same time will cause Status.Replicas < Spec.Replicas
// 2. use Status.AvailableReplicas instead of Status.ReadyReplicas because of minReadySeconds > 0 & stability
if *sts.Spec.Replicas != sts.Status.AvailableReplicas {
return true, nil
}

Expand Down Expand Up @@ -626,6 +630,16 @@ func (c *RolloutController) podsNotMatchingUpdateRevision(sts *v1.StatefulSet) (

// Sort pods in order to provide a deterministic behaviour.
util.SortPods(pods)
// Sort pods so not running pods will be updated first.
sort.Slice(pods, func(i, j int) bool {
rank := func(p *corev1.Pod) int {
if p.Status.Phase == corev1.PodRunning {
return 1 // Running pods are ranked higher and will be updated last.
}
return 0 // Running pods are ranked lower and will be updated first.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Non-runnign pods

}
return rank(pods[i]) < rank(pods[j])
})

return pods, nil
}
Expand Down
Loading