Merge pull request #19733 from janetkuo/flaky-deployment-recreate

Fix e2e flake: Sync deployment status when with RecreateDeploymentStrategy
This commit is contained in:
Alex Mohr 2016-01-21 10:23:21 -08:00
commit 8c9aa2af33
2 changed files with 15 additions and 3 deletions

View File

@ -452,7 +452,10 @@ func (dc *DeploymentController) syncRecreateDeployment(deployment extensions.Dep
return dc.updateDeploymentStatus(allRCs, newRC, deployment)
}
return nil
// Sync deployment status
return dc.syncDeploymentStatus(allRCs, newRC, deployment)
// TODO: raise an event, neither scaled up nor down.
}
func (dc *DeploymentController) syncRollingUpdateDeployment(deployment extensions.Deployment) error {
@ -489,13 +492,18 @@ func (dc *DeploymentController) syncRollingUpdateDeployment(deployment extension
}
// Sync deployment status
return dc.syncDeploymentStatus(allRCs, newRC, deployment)
// TODO: raise an event, neither scaled up nor down.
}
// syncDeploymentStatus checks if the status is up-to-date and sync it if necessary
func (dc *DeploymentController) syncDeploymentStatus(allRCs []*api.ReplicationController, newRC *api.ReplicationController, deployment extensions.Deployment) error {
totalReplicas := deploymentutil.GetReplicaCountForRCs(allRCs)
updatedReplicas := deploymentutil.GetReplicaCountForRCs([]*api.ReplicationController{newRC})
if deployment.Status.Replicas != totalReplicas || deployment.Status.UpdatedReplicas != updatedReplicas {
return dc.updateDeploymentStatus(allRCs, newRC, deployment)
}
// TODO: raise an event, neither scaled up nor down.
return nil
}

View File

@ -285,6 +285,10 @@ func testRecreateDeployment(f *Framework) {
}()
err = waitForDeploymentStatus(c, ns, deploymentName, replicas, 0, replicas, 0)
if err != nil {
deployment, _ := c.Deployments(ns).Get(deploymentName)
Logf("deployment = %+v", deployment)
}
Expect(err).NotTo(HaveOccurred())
// Verify that the pods were scaled up and down as expected. We use events to verify that.