Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buggy ownership logic for Pods in Deployment awaiter #311

Merged
merged 4 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pkg/await/apps_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package await
import (
"fmt"
"reflect"
"strings"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -459,7 +458,7 @@ func (dia *deploymentInitAwaiter) checkReplicaSetStatus() {
// we would now have fewer replicas than we had requested in the `Deployment` we last submitted
// when we last ran `pulumi up`.
rawSpecReplicas, specReplicasExists := openapi.Pluck(rs.Object, "spec", "replicas")
specReplicas, _ := rawSpecReplicas.(float64)
specReplicas, _ := rawSpecReplicas.(int64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looks like this is actually an *int32? Have we double checked the type with reflect.TypeOf, just to be safe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked and it said int64

if !specReplicasExists {
specReplicas = 1
}
Expand Down Expand Up @@ -505,8 +504,6 @@ func (dia *deploymentInitAwaiter) changeTriggeredRollout() bool {
}

func (dia *deploymentInitAwaiter) processPodEvent(event watch.Event) {
inputDeploymentName := dia.config.currentInputs.GetName()

pod, isUnstructured := event.Object.(*unstructured.Unstructured)
if !isUnstructured {
glog.V(3).Infof("Pod watch received unknown object type '%s'",
Expand All @@ -515,10 +512,11 @@ func (dia *deploymentInitAwaiter) processPodEvent(event watch.Event) {
}

// Check whether this Pod was created by our Deployment.
podName := pod.GetName()
if !strings.HasPrefix(podName+"-", inputDeploymentName) {
currentReplicaSet := dia.replicaSets[dia.currentGeneration]
if !isOwnedBy(pod, currentReplicaSet) {
return
}
podName := pod.GetName()

// If Pod was deleted, remove it from our aggregated checkers.
if event.Type == watch.Deleted {
Expand Down
6 changes: 4 additions & 2 deletions pkg/await/apps_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func Test_Apps_Deployment(t *testing.T) {
// Failed Pod should show up in the errors.
pods <- watchAddedEvent(deployedFailedPod(inputNamespace, readyPodName, replicaSetGeneratedName))

// // Unrelated successful Pod should generate no errors.
// Unrelated successful Pod should generate no errors.
pods <- watchAddedEvent(deployedReadyPod(inputNamespace, readyPodName, "bar"))

// Timeout. Failure.
Expand All @@ -496,6 +496,7 @@ func Test_Apps_Deployment(t *testing.T) {
object: deploymentProgressing(inputNamespace, deploymentInputName, revision1),
subErrors: []string{
"Minimum number of live Pods was not attained",
`1 Pods failed to run because: [ImagePullBackOff] Back-off pulling image "sdkjlsdlkj"`,
}},
},
{
Expand All @@ -511,7 +512,7 @@ func Test_Apps_Deployment(t *testing.T) {
// Failed Pod should show up in the errors.
pods <- watchAddedEvent(deployedFailedPod(inputNamespace, readyPodName, replicaSetGeneratedName))

// // Unrelated successful Pod should generate no errors.
// Unrelated successful Pod should generate no errors.
pods <- watchAddedEvent(deployedReadyPod(inputNamespace, readyPodName, "bar"))

// Timeout. Failure.
Expand All @@ -521,6 +522,7 @@ func Test_Apps_Deployment(t *testing.T) {
object: deploymentProgressing(inputNamespace, deploymentInputName, revision2),
subErrors: []string{
"Minimum number of live Pods was not attained",
`1 Pods failed to run because: [ImagePullBackOff] Back-off pulling image "sdkjlsdlkj"`,
}},
},
{
Expand Down