mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
set updated replicas
This commit is contained in:
parent
3dbcd1ddce
commit
beec45b4de
@ -297,7 +297,8 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
||||
if isCreated(pods[i]) && !isTerminating(pods[i]) {
|
||||
if getPodRevision(pods[i]) == currentRevision.Name {
|
||||
status.CurrentReplicas++
|
||||
} else if getPodRevision(pods[i]) == updateRevision.Name {
|
||||
}
|
||||
if getPodRevision(pods[i]) == updateRevision.Name {
|
||||
status.UpdatedReplicas++
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ func TestStatefulSetControl(t *testing.T) {
|
||||
obj func() *apps.StatefulSet
|
||||
}{
|
||||
{CreatesPods, simpleSetFn},
|
||||
{SetsStatusFields, simpleSetFn},
|
||||
{ScalesUp, simpleSetFn},
|
||||
{ScalesDown, simpleSetFn},
|
||||
{ReplacesPods, largeSetFn},
|
||||
@ -130,6 +131,27 @@ func CreatesPods(t *testing.T, set *apps.StatefulSet, invariants invariantFunc)
|
||||
}
|
||||
}
|
||||
|
||||
func SetsStatusFields(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
client := fake.NewSimpleClientset(set)
|
||||
spc, _, ssc, stop := setupController(client)
|
||||
defer close(stop)
|
||||
|
||||
if err := scaleUpStatefulSetControl(set, ssc, spc, invariants); err != nil {
|
||||
t.Errorf("Failed to turn up StatefulSet : %s", err)
|
||||
}
|
||||
var err error
|
||||
set, err = spc.setsLister.StatefulSets(set.Namespace).Get(set.Name)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting updated StatefulSet: %v", err)
|
||||
}
|
||||
if set.Status.ReadyReplicas != 3 {
|
||||
t.Error("Failed to set ReadyReplicas correctly")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 3 {
|
||||
t.Error("Failed to set UpdatedReplicas correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func ScalesUp(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
client := fake.NewSimpleClientset(set)
|
||||
spc, _, ssc, stop := setupController(client)
|
||||
|
Loading…
Reference in New Issue
Block a user