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 nil ptr for newRS #233

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion rollout/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ func (c *RolloutController) reconcileCanaryReplicaSets(roCtx *canaryContext) (bo
newRS := roCtx.NewRS()
olderRSs := roCtx.OlderRSs()
allRSs := roCtx.AllRSs()
logCtx.Infof("Reconciling new ReplicaSet '%s'", newRS.Name)
scaledNewRS, err := c.reconcileNewReplicaSet(roCtx)
if err != nil {
return false, err
Expand Down
38 changes: 38 additions & 0 deletions rollout/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1097,3 +1097,41 @@ func TestNoResumeAfterPauseDurationIfUserPaused(t *testing.T) {
patch := f.getPatchedRollout(patchIndex)
assert.Equal(t, calculatePatch(r1, OnlyObservedGenerationPatch), patch)
}

func TestHandleNilNewRSOnScaleAndImageChange(t *testing.T) {
f := newFixture(t)
defer f.Close()

steps := []v1alpha1.CanaryStep{
{
SetWeight: pointer.Int32Ptr(10),
},
{
Pause: &v1alpha1.RolloutPause{
Duration: pointer.Int32Ptr(60),
},
},
{
SetWeight: pointer.Int32Ptr(20),
},
}
r1 := newCanaryRollout("foo", 1, nil, steps, pointer.Int32Ptr(1), intstr.FromInt(1), intstr.FromInt(1))
rs1 := newReplicaSetWithStatus(r1, 3, 3)
rs1PodHash := rs1.Labels[v1alpha1.DefaultRolloutUniqueLabelKey]
r2 := bumpVersion(r1)
r2.Spec.Replicas = pointer.Int32Ptr(3)
r2 = updateCanaryRolloutStatus(r2, rs1PodHash, 3, 0, 3, true)
pausedCondition, _ := newProgressingCondition(conditions.PausedRolloutReason, rs1)
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

f.kubeobjects = append(f.kubeobjects, rs1)
f.replicaSetLister = append(f.replicaSetLister, rs1)
f.rolloutLister = append(f.rolloutLister, r2)
f.objects = append(f.objects, r2)

// f.expectUpdateReplicaSetAction(rs1)
patchIndex := f.expectPatchRolloutAction(r2)
f.run(getKey(r2, t))
patch := f.getPatchedRollout(patchIndex)
assert.Equal(t, calculatePatch(r2, OnlyObservedGenerationPatch), patch)
}
4 changes: 4 additions & 0 deletions rollout/replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func (c *RolloutController) getReplicaSetsForRollouts(r *v1alpha1.Rollout) ([]*a
func (c *RolloutController) reconcileNewReplicaSet(roCtx rolloutContext) (bool, error) {
rollout := roCtx.Rollout()
newRS := roCtx.NewRS()
if newRS == nil {
return false, nil
}
roCtx.Log().Infof("Reconciling new ReplicaSet '%s'", newRS.Name)
allRSs := roCtx.AllRSs()
if rollout.Spec.Strategy.BlueGreen != nil {
rolloutReplicas := defaults.GetReplicasOrDefault(rollout.Spec.Replicas)
Expand Down