Skip to content

Commit

Permalink
Add new pod lifecycle phase (#299)
Browse files Browse the repository at this point in the history
* add pod label to indicate PodOpsLifecycle phase

* add UT

* add creating label when replacing pod created

* add UT
  • Loading branch information
wu8685 authored Oct 29, 2024
1 parent a91ffd8 commit e4e981f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/controllers/collaset/collaset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/collaset/synccontrol/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e4e981f

Please sign in to comment.