Skip to content

Commit

Permalink
refactor: correct ReCreate to Recreate (#177)
Browse files Browse the repository at this point in the history
correct ReCreate to Recreate
  • Loading branch information
wu8685 committed Mar 28, 2024
1 parent 9f93834 commit 692384a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apis/apps/v1alpha1/collaset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type PodUpdateStrategyType string

const (
// CollaSetRecreatePodUpdateStrategyType indicates that CollaSet will always update Pod by deleting and recreate it.
CollaSetRecreatePodUpdateStrategyType PodUpdateStrategyType = "ReCreate"
CollaSetRecreatePodUpdateStrategyType PodUpdateStrategyType = "Recreate"
// CollaSetInPlaceIfPossiblePodUpdateStrategyType indicates thath CollaSet will try to update Pod by in-place update
// when it is possible. Recently, only Pod image can be updated in-place. Any other Pod spec change will make the
// policy fall back to CollaSetRecreatePodUpdateStrategyType.
Expand Down
12 changes: 6 additions & 6 deletions pkg/controllers/collaset/collaset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ var _ = Describe("collaset controller", func() {
},
},
}
csReCreate := cs.DeepCopy()
csRecreate := cs.DeepCopy()
Expect(c.Create(context.TODO(), cs)).Should(BeNil())

// test1: pvc whenScaled retention policy
Expand Down Expand Up @@ -1817,7 +1817,7 @@ var _ = Describe("collaset controller", func() {
// delete set and pods
Expect(c.Delete(context.TODO(), cs)).Should(BeNil())
podList := &corev1.PodList{}
Expect(c.List(context.TODO(), podList, client.InNamespace(csReCreate.Namespace))).Should(BeNil())
Expect(c.List(context.TODO(), podList, client.InNamespace(csRecreate.Namespace))).Should(BeNil())
for _, pod := range podList.Items {
Expect(c.Delete(context.TODO(), pod.DeepCopy())).Should(BeNil())
}
Expand All @@ -1835,16 +1835,16 @@ var _ = Describe("collaset controller", func() {
pvcNames.Insert(allPvcs.Items[i].Name)
}
// recreate set
csReCreate.Spec.ScaleStrategy.PersistentVolumeClaimRetentionPolicy = &appsv1alpha1.PersistentVolumeClaimRetentionPolicy{
csRecreate.Spec.ScaleStrategy.PersistentVolumeClaimRetentionPolicy = &appsv1alpha1.PersistentVolumeClaimRetentionPolicy{
WhenDeleted: appsv1alpha1.RetainPersistentVolumeClaimRetentionPolicyType,
}
Expect(c.Create(context.TODO(), csReCreate)).Should(BeNil())
Expect(c.Create(context.TODO(), csRecreate)).Should(BeNil())
time.Sleep(3 * time.Second)
Eventually(func() bool {
Expect(c.List(context.TODO(), podList, client.InNamespace(csReCreate.Namespace))).Should(BeNil())
Expect(c.List(context.TODO(), podList, client.InNamespace(csRecreate.Namespace))).Should(BeNil())
return len(podList.Items) == 4
}, 5*time.Second, 1*time.Second).Should(BeTrue())
Expect(c.Get(context.TODO(), types.NamespacedName{Namespace: csReCreate.Namespace, Name: csReCreate.Name}, csReCreate)).Should(BeNil())
Expect(c.Get(context.TODO(), types.NamespacedName{Namespace: csRecreate.Namespace, Name: csRecreate.Name}, csRecreate)).Should(BeNil())
// pvcs should be retained
for i := range podList.Items {
pod := podList.Items[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestValidatingCollaSet(t *testing.T) {
},
},
"invalid-update-policy": {
messageKeyWords: "supported values: \"ReCreate\", \"InPlaceIfPossible\", \"InPlaceOnly\", \"Replace\"",
messageKeyWords: "supported values: \"Recreate\", \"InPlaceIfPossible\", \"InPlaceOnly\", \"Replace\"",
cls: &appsv1alpha1.CollaSet{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Expand Down

0 comments on commit 692384a

Please sign in to comment.