Log deployment, RSes and pods on waitForDeploymentStatus timeout / condition mismatch
This commit is contained in:
		@@ -366,11 +366,7 @@ func testRecreateDeployment(f *Framework) {
 | 
			
		||||
	Expect(err).NotTo(HaveOccurred())
 | 
			
		||||
	defer stopDeployment(c, f.Client, ns, deploymentName)
 | 
			
		||||
 | 
			
		||||
	err = waitForDeploymentStatus(c, ns, deploymentName, replicas, 0, replicas, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		deployment, _ := c.Extensions().Deployments(ns).Get(deploymentName)
 | 
			
		||||
		Logf("deployment = %+v", deployment)
 | 
			
		||||
	}
 | 
			
		||||
	waitForDeploymentStatus(c, ns, deploymentName, replicas, 0, replicas, 0)
 | 
			
		||||
	Expect(err).NotTo(HaveOccurred())
 | 
			
		||||
 | 
			
		||||
	// Verify that the pods were scaled up and down as expected. We use events to verify that.
 | 
			
		||||
 
 | 
			
		||||
@@ -2098,17 +2098,21 @@ func waitForReplicaSetPodsGone(c *client.Client, rs *extensions.ReplicaSet) erro
 | 
			
		||||
// Waits for the deployment to reach desired state.
 | 
			
		||||
// Returns an error if minAvailable or maxCreated is broken at any times.
 | 
			
		||||
func waitForDeploymentStatus(c clientset.Interface, ns, deploymentName string, desiredUpdatedReplicas, minAvailable, maxCreated, minReadySeconds int) error {
 | 
			
		||||
	return wait.Poll(poll, 5*time.Minute, func() (bool, error) {
 | 
			
		||||
	var oldRSs, allRSs []*extensions.ReplicaSet
 | 
			
		||||
	var newRS *extensions.ReplicaSet
 | 
			
		||||
	var deployment *extensions.Deployment
 | 
			
		||||
	err := wait.Poll(poll, 5*time.Minute, func() (bool, error) {
 | 
			
		||||
 | 
			
		||||
		deployment, err := c.Extensions().Deployments(ns).Get(deploymentName)
 | 
			
		||||
		var err error
 | 
			
		||||
		deployment, err = c.Extensions().Deployments(ns).Get(deploymentName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
		oldRSs, _, err := deploymentutil.GetOldReplicaSets(*deployment, c)
 | 
			
		||||
		oldRSs, _, err = deploymentutil.GetOldReplicaSets(*deployment, c)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
		newRS, err := deploymentutil.GetNewReplicaSet(*deployment, c)
 | 
			
		||||
		newRS, err = deploymentutil.GetNewReplicaSet(*deployment, c)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
@@ -2116,19 +2120,19 @@ func waitForDeploymentStatus(c clientset.Interface, ns, deploymentName string, d
 | 
			
		||||
			// New RC hasn't been created yet.
 | 
			
		||||
			return false, nil
 | 
			
		||||
		}
 | 
			
		||||
		allRSs := append(oldRSs, newRS)
 | 
			
		||||
		allRSs = append(oldRSs, newRS)
 | 
			
		||||
		totalCreated := deploymentutil.GetReplicaCountForReplicaSets(allRSs)
 | 
			
		||||
		totalAvailable, err := deploymentutil.GetAvailablePodsForReplicaSets(c, allRSs, minReadySeconds)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
		if totalCreated > maxCreated {
 | 
			
		||||
			logReplicaSetsOfDeployment(deploymentName, oldRSs, newRS)
 | 
			
		||||
			logReplicaSetsOfDeployment(deployment, oldRSs, newRS)
 | 
			
		||||
			logPodsOfReplicaSets(c, allRSs, minReadySeconds)
 | 
			
		||||
			return false, fmt.Errorf("total pods created: %d, more than the max allowed: %d", totalCreated, maxCreated)
 | 
			
		||||
		}
 | 
			
		||||
		if totalAvailable < minAvailable {
 | 
			
		||||
			logReplicaSetsOfDeployment(deploymentName, oldRSs, newRS)
 | 
			
		||||
			logReplicaSetsOfDeployment(deployment, oldRSs, newRS)
 | 
			
		||||
			logPodsOfReplicaSets(c, allRSs, minReadySeconds)
 | 
			
		||||
			return false, fmt.Errorf("total pods available: %d, less than the min required: %d", totalAvailable, minAvailable)
 | 
			
		||||
		}
 | 
			
		||||
@@ -2142,6 +2146,12 @@ func waitForDeploymentStatus(c clientset.Interface, ns, deploymentName string, d
 | 
			
		||||
		}
 | 
			
		||||
		return false, nil
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	if err == wait.ErrWaitTimeout {
 | 
			
		||||
		logReplicaSetsOfDeployment(deployment, oldRSs, newRS)
 | 
			
		||||
		logPodsOfReplicaSets(c, allRSs, minReadySeconds)
 | 
			
		||||
	}
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Waits for the deployment to clean up old rcs.
 | 
			
		||||
@@ -2159,11 +2169,12 @@ func waitForDeploymentOldRSsNum(c *clientset.Clientset, ns, deploymentName strin
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func logReplicaSetsOfDeployment(deploymentName string, oldRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet) {
 | 
			
		||||
func logReplicaSetsOfDeployment(deployment *extensions.Deployment, oldRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet) {
 | 
			
		||||
	Logf("Deployment = %+v", deployment)
 | 
			
		||||
	for i := range oldRSs {
 | 
			
		||||
		Logf("Old ReplicaSets (%d/%d) of deployment %s: %+v", i+1, len(oldRSs), deploymentName, oldRSs[i])
 | 
			
		||||
		Logf("Old ReplicaSets (%d/%d) of deployment %s: %+v", i+1, len(oldRSs), deployment.Name, oldRSs[i])
 | 
			
		||||
	}
 | 
			
		||||
	Logf("New ReplicaSet of deployment %s: %+v", deploymentName, newRS)
 | 
			
		||||
	Logf("New ReplicaSet of deployment %s: %+v", deployment.Name, newRS)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func logPodsOfReplicaSets(c clientset.Interface, rss []*extensions.ReplicaSet, minReadySeconds int) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user