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