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

CloneSet refresh pod states before skipping update when paused #893

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
8 changes: 4 additions & 4 deletions pkg/controller/cloneset/sync/cloneset_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ func (c *realControl) Update(cs *appsv1alpha1.CloneSet,
requeueDuration := requeueduration.Duration{}
coreControl := clonesetcore.New(cs)

if cs.Spec.UpdateStrategy.Paused {
return requeueDuration.Get(), nil
}

// 1. refresh states for all pods
var modified bool
for _, pod := range pods {
Expand All @@ -69,6 +65,10 @@ func (c *realControl) Update(cs *appsv1alpha1.CloneSet,
return requeueDuration.Get(), nil
}

if cs.Spec.UpdateStrategy.Paused {
return requeueDuration.Get(), nil
}

// 2. calculate update diff and the revision to update
diffRes := calculateDiffsWithExpectation(cs, pods, currentRevision.Name, updateRevision.Name)
if diffRes.updateNum == 0 {
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/apps/cloneset.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,29 @@ var _ = SIGDescribe("CloneSet", func() {
gomega.Expect(pods[i].CreationTimestamp.Sub(lastPodCondition.LastTransitionTime.Time) <= time.Duration(cs.Spec.MinReadySeconds)*time.Second+allowFluctuation).To(gomega.BeTrue())
}
})

ginkgo.It("pods should be ready when paused=true", func() {
cs := tester.NewCloneSet("clone-"+randStr, 3, appsv1alpha1.CloneSetUpdateStrategy{
Type: appsv1alpha1.RecreateCloneSetUpdateStrategyType,
Paused: true,
})
cs, err = tester.CreateCloneSet(cs)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By("Wait for replicas satisfied")
gomega.Eventually(func() int32 {
cs, err = tester.GetCloneSet(cs.Name)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
return cs.Status.Replicas
}, 3*time.Second, time.Second).Should(gomega.Equal(int32(3)))

ginkgo.By("Wait for all pods ready")
gomega.Eventually(func() int32 {
cs, err = tester.GetCloneSet(cs.Name)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
return cs.Status.ReadyReplicas
}, 120*time.Second, 3*time.Second).Should(gomega.Equal(int32(3)))
})
})

framework.KruiseDescribe("CloneSet Updating", func() {
Expand Down