mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Account newly ready replicas as progress
Signed-off-by: Michail Kargakis <mkargaki@redhat.com>
This commit is contained in:
parent
a8bff0ed9a
commit
7910dc3131
@ -841,8 +841,8 @@ func DeploymentComplete(deployment *extensions.Deployment, newStatus *extensions
|
||||
|
||||
// DeploymentProgressing reports progress for a deployment. Progress is estimated by comparing the
|
||||
// current with the new status of the deployment that the controller is observing. More specifically,
|
||||
// when new pods are scaled up or become available, or old pods are scaled down, then we consider the
|
||||
// deployment is progressing.
|
||||
// when new pods are scaled up or become ready or available, or old pods are scaled down, then we
|
||||
// consider the deployment is progressing.
|
||||
func DeploymentProgressing(deployment *extensions.Deployment, newStatus *extensions.DeploymentStatus) bool {
|
||||
oldStatus := deployment.Status
|
||||
|
||||
@ -852,6 +852,7 @@ func DeploymentProgressing(deployment *extensions.Deployment, newStatus *extensi
|
||||
|
||||
return (newStatus.UpdatedReplicas > oldStatus.UpdatedReplicas) ||
|
||||
(newStatusOldReplicas < oldStatusOldReplicas) ||
|
||||
newStatus.ReadyReplicas > deployment.Status.ReadyReplicas ||
|
||||
newStatus.AvailableReplicas > deployment.Status.AvailableReplicas
|
||||
}
|
||||
|
||||
|
@ -1002,18 +1002,22 @@ func TestDeploymentComplete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeploymentProgressing(t *testing.T) {
|
||||
deployment := func(current, updated int32) *extensions.Deployment {
|
||||
deployment := func(current, updated, ready, available int32) *extensions.Deployment {
|
||||
return &extensions.Deployment{
|
||||
Status: extensions.DeploymentStatus{
|
||||
Replicas: current,
|
||||
UpdatedReplicas: updated,
|
||||
Replicas: current,
|
||||
UpdatedReplicas: updated,
|
||||
ReadyReplicas: ready,
|
||||
AvailableReplicas: available,
|
||||
},
|
||||
}
|
||||
}
|
||||
newStatus := func(current, updated int32) extensions.DeploymentStatus {
|
||||
newStatus := func(current, updated, ready, available int32) extensions.DeploymentStatus {
|
||||
return extensions.DeploymentStatus{
|
||||
Replicas: current,
|
||||
UpdatedReplicas: updated,
|
||||
Replicas: current,
|
||||
UpdatedReplicas: updated,
|
||||
ReadyReplicas: ready,
|
||||
AvailableReplicas: available,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1026,52 +1030,60 @@ func TestDeploymentProgressing(t *testing.T) {
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "progressing",
|
||||
name: "progressing: updated pods",
|
||||
|
||||
d: deployment(10, 4),
|
||||
newStatus: newStatus(10, 6),
|
||||
d: deployment(10, 4, 4, 4),
|
||||
newStatus: newStatus(10, 6, 4, 4),
|
||||
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "not progressing",
|
||||
|
||||
d: deployment(10, 4),
|
||||
newStatus: newStatus(10, 4),
|
||||
d: deployment(10, 4, 4, 4),
|
||||
newStatus: newStatus(10, 4, 4, 4),
|
||||
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "progressing #2",
|
||||
name: "progressing: old pods removed",
|
||||
|
||||
d: deployment(10, 4),
|
||||
newStatus: newStatus(8, 4),
|
||||
d: deployment(10, 4, 6, 6),
|
||||
newStatus: newStatus(8, 4, 6, 6),
|
||||
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "not progressing #2",
|
||||
name: "not progressing: less new pods",
|
||||
|
||||
d: deployment(10, 7),
|
||||
newStatus: newStatus(10, 6),
|
||||
d: deployment(10, 7, 3, 3),
|
||||
newStatus: newStatus(10, 6, 3, 3),
|
||||
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "progressing #3",
|
||||
name: "progressing: less overall but more new pods",
|
||||
|
||||
d: deployment(10, 4),
|
||||
newStatus: newStatus(8, 8),
|
||||
d: deployment(10, 4, 7, 7),
|
||||
newStatus: newStatus(8, 8, 5, 5),
|
||||
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "not progressing #2",
|
||||
name: "progressing: more ready pods",
|
||||
|
||||
d: deployment(10, 7),
|
||||
newStatus: newStatus(10, 7),
|
||||
d: deployment(10, 10, 9, 8),
|
||||
newStatus: newStatus(10, 10, 10, 8),
|
||||
|
||||
expected: false,
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "progressing: more available pods",
|
||||
|
||||
d: deployment(10, 10, 10, 9),
|
||||
newStatus: newStatus(10, 10, 10, 10),
|
||||
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user