Skip to content

Commit

Permalink
CloneSet refresh pod states before skipping update when paused (openk…
Browse files Browse the repository at this point in the history
  • Loading branch information
FillZpp authored Jan 18, 2022
1 parent c445216 commit 01eae1f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
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

0 comments on commit 01eae1f

Please sign in to comment.