diff --git a/pkg/controllers/collaset/collaset_controller_test.go b/pkg/controllers/collaset/collaset_controller_test.go index f9a4bff0..dc4bd92d 100644 --- a/pkg/controllers/collaset/collaset_controller_test.go +++ b/pkg/controllers/collaset/collaset_controller_test.go @@ -130,6 +130,19 @@ var _ = Describe("collaset controller", func() { return expectedStatusReplicas(c, cs, 0, 0, 0, 2, 2, 0, 0, 0) }, 5*time.Second, 1*time.Second).Should(BeNil()) + Eventually(func() bool { + Expect(c.List(context.TODO(), podList, client.InNamespace(cs.Namespace))).Should(BeNil()) + return len(podList.Items) == 2 + }, 5*time.Second, 1*time.Second).Should(BeTrue()) + + for _, pod := range podList.Items { + if pod.Name == originPodName { + continue + } + + Expect(pod.Labels[appsv1alpha1.PodCreatingLabel]).ShouldNot(BeEquivalentTo("")) + } + // update collaset with recreate update observedGeneration := cs.Status.ObservedGeneration Expect(updateCollaSetWithRetry(c, cs.Namespace, cs.Name, func(cls *appsv1alpha1.CollaSet) bool { diff --git a/pkg/controllers/collaset/synccontrol/replace.go b/pkg/controllers/collaset/synccontrol/replace.go index 2cf9432b..9c9ea05e 100644 --- a/pkg/controllers/collaset/synccontrol/replace.go +++ b/pkg/controllers/collaset/synccontrol/replace.go @@ -154,6 +154,7 @@ func (r *RealSyncControl) replaceOriginPods( ownedIDs[newPodId].Remove(podcontext.JustCreateContextDataKey) } newPod.Labels[appsv1alpha1.PodReplacePairOriginName] = originPod.GetName() + newPod.Labels[appsv1alpha1.PodCreatingLabel] = strconv.FormatInt(time.Now().UnixNano(), 10) newPodContext.Put(podcontext.RevisionContextDataKey, replaceRevision.Name) // create pvcs for new pod err = r.pvcControl.CreatePodPvcs(ctx, instance, newPod, resources.ExistingPvcs)