Merge pull request #59448 from crimsonfaith91/collision

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

verify no extra RS was created when re-creating a deployment

**What this PR does / why we need it**:
This PR verifies no extra RS was created when re-creating a deployment to adopt previously orphaned RS by improving existing `testDeploymentsControllerRef` e2e test. This also verifies that collision avoidance mechanism works as expected.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #59213

**Release note**:
```release-note
NONE
```

/sig apps
This commit is contained in:
Kubernetes Submit Queue 2018-02-07 16:43:28 -08:00 committed by GitHub
commit 8992aa0f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -760,11 +760,18 @@ func testDeploymentsControllerRef(f *framework.Framework) {
err = framework.WaitForDeploymentComplete(c, deploy)
Expect(err).NotTo(HaveOccurred())
framework.Logf("Checking its ReplicaSet has the right controllerRef")
framework.Logf("Verifying Deployment %q has only one ReplicaSet", deploymentName)
rsList := listDeploymentReplicaSets(c, ns, podLabels)
Expect(len(rsList.Items)).Should(Equal(1))
framework.Logf("Obtaining the ReplicaSet's UID")
orphanedRSUID := rsList.Items[0].UID
framework.Logf("Checking the ReplicaSet has the right controllerRef")
err = checkDeploymentReplicaSetsControllerRef(c, ns, deploy.UID, podLabels)
Expect(err).NotTo(HaveOccurred())
framework.Logf("Deleting Deployment %q and orphaning its ReplicaSets", deploymentName)
framework.Logf("Deleting Deployment %q and orphaning its ReplicaSet", deploymentName)
err = orphanDeploymentReplicaSets(c, deploy)
Expect(err).NotTo(HaveOccurred())
@ -783,6 +790,13 @@ func testDeploymentsControllerRef(f *framework.Framework) {
framework.Logf("Waiting for the ReplicaSet to have the right controllerRef")
err = checkDeploymentReplicaSetsControllerRef(c, ns, deploy.UID, podLabels)
Expect(err).NotTo(HaveOccurred())
framework.Logf("Verifying no extra ReplicaSet is created (Deployment %q still has only one ReplicaSet after adoption)", deploymentName)
rsList = listDeploymentReplicaSets(c, ns, podLabels)
Expect(len(rsList.Items)).Should(Equal(1))
framework.Logf("Verifying the ReplicaSet has the same UID as the orphaned ReplicaSet")
Expect(rsList.Items[0].UID).Should(Equal(orphanedRSUID))
}
func checkDeploymentReplicaSetsControllerRef(c clientset.Interface, ns string, uid types.UID, label map[string]string) error {