Merge pull request #26792 from janetkuo/deployment-version-skewed-test-fail

Automatic merge from submit-queue

Avoid comparing pod-template-hash when getting a deployment's new/old RSes

Will need to cherry pick to 1.2 also. 

Ref #26724 #26797 @kubernetes/deployment @ihmccreery 

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
This commit is contained in:
k8s-merge-robot
2016-06-08 12:03:31 -07:00
3 changed files with 233 additions and 4 deletions

View File

@@ -62,6 +62,7 @@ import (
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
deploymentutil "k8s.io/kubernetes/pkg/util/deployment"
labelsutil "k8s.io/kubernetes/pkg/util/labels"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
utilyaml "k8s.io/kubernetes/pkg/util/yaml"
@@ -2878,6 +2879,12 @@ func WaitForDeploymentStatus(c clientset.Interface, ns, deploymentName string, d
return false, nil
}
allRSs = append(oldRSs, newRS)
// The old/new ReplicaSets need to contain the pod-template-hash label
for i := range allRSs {
if !labelsutil.SelectorHasLabel(allRSs[i].Spec.Selector, extensions.DefaultDeploymentUniqueLabelKey) {
return false, nil
}
}
totalCreated := deploymentutil.GetReplicaCountForReplicaSets(allRSs)
totalAvailable, err := deploymentutil.GetAvailablePodsForReplicaSets(c, allRSs, minReadySeconds)
if err != nil {
@@ -2963,8 +2970,9 @@ func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName
if err != nil {
return false, err
}
// The new ReplicaSet needs to be non-nil and contain the pod-template-hash label
newRS, err = deploymentutil.GetNewReplicaSet(deployment, c)
if err != nil {
if err != nil || newRS == nil || !labelsutil.SelectorHasLabel(newRS.Spec.Selector, extensions.DefaultDeploymentUniqueLabelKey) {
return false, err
}
// Check revision of this deployment, and of the new replica set of this deployment
@@ -2978,6 +2986,9 @@ func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName
if err == wait.ErrWaitTimeout {
logReplicaSetsOfDeployment(deployment, nil, newRS)
}
if newRS == nil {
return fmt.Errorf("deployment %s failed to create new RS: %v", deploymentName, err)
}
if err != nil {
return fmt.Errorf("error waiting for deployment %s (got %s / %s) and new RS %s (got %s / %s) revision and image to match expectation (expected %s / %s): %v", deploymentName, deployment.Annotations[deploymentutil.RevisionAnnotation], deployment.Spec.Template.Spec.Containers[0].Image, newRS.Name, newRS.Annotations[deploymentutil.RevisionAnnotation], newRS.Spec.Template.Spec.Containers[0].Image, revision, image, err)
}
@@ -3040,7 +3051,11 @@ func logReplicaSetsOfDeployment(deployment *extensions.Deployment, allOldRSs []*
for i := range allOldRSs {
Logf("All old ReplicaSets (%d/%d) of deployment %s: %+v. Selector = %+v", i+1, len(allOldRSs), deployment.Name, *allOldRSs[i], allOldRSs[i].Spec.Selector)
}
Logf("New ReplicaSet of deployment %s: %+v. Selector = %+v", deployment.Name, *newRS, newRS.Spec.Selector)
if newRS != nil {
Logf("New ReplicaSet of deployment %s: %+v. Selector = %+v", deployment.Name, *newRS, newRS.Spec.Selector)
} else {
Logf("New ReplicaSet of deployment %s is nil.", deployment.Name)
}
}
func WaitForObservedDeployment(c *clientset.Clientset, ns, deploymentName string, desiredGeneration int64) error {