Skip to content

Commit

Permalink
update PodDecoration revision annotation name (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eikykun committed Feb 19, 2024
1 parent eb06583 commit dbbb7e3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apis/apps/v1alpha1/well_known_annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ const (

// PodDecoration Annotation
const (
// AnnotationResourceDecorationRevision struct: { groupName: {name: pdName, revision: currentRevision}, groupName: {} }
AnnotationResourceDecorationRevision = "cafe.sofastack.io/pod-decoration-revision"
// AnnotationPodDecorationRevision struct: { groupName: {name: pdName, revision: currentRevision}, groupName: {} }
AnnotationPodDecorationRevision = "poddecoration.kusionstack.io/revisions"
)
4 changes: 2 additions & 2 deletions pkg/controllers/collaset/utils/poddecoration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ var _ = Describe("PodDecoration utils", func() {
getter.revisions["foo-101"] = getter.latestPodDecorations[0]
getter.revisions["foo-200"] = getter.latestPodDecorations[1]
getter.revisions["foo-201"] = getter.latestPodDecorations[1]
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{appsv1alpha1.AnnotationResourceDecorationRevision: "[{\"name\":\"foo-1\",\"revision\":\"foo-100\"},{\"name\":\"foo-2\",\"revision\":\"foo-200\"}]"}}}
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{appsv1alpha1.AnnotationPodDecorationRevision: "[{\"name\":\"foo-1\",\"revision\":\"foo-100\"},{\"name\":\"foo-2\",\"revision\":\"foo-200\"}]"}}}
pds, err := getter.GetUpdatedDecorationsByOldPod(context.TODO(), pod)
Expect(err).Should(BeNil())
Expect(len(pds)).Should(Equal(2))
Expect(pds["foo-101"]).ShouldNot(BeNil())
Expect(pds["foo-201"]).ShouldNot(BeNil())
getter.latestPodDecorationNames = sets.NewString()
getter.latestPodDecorations = []*appsv1alpha1.PodDecoration{}
pod.Annotations[appsv1alpha1.AnnotationResourceDecorationRevision] = "[{\"name\":\"foo-1\",\"revision\":\"foo-101\"},{\"name\":\"foo-2\",\"revision\":\"foo-201\"}]"
pod.Annotations[appsv1alpha1.AnnotationPodDecorationRevision] = "[{\"name\":\"foo-1\",\"revision\":\"foo-101\"},{\"name\":\"foo-2\",\"revision\":\"foo-201\"}]"
pds, err = getter.GetUpdatedDecorationsByOldPod(context.TODO(), pod)
Expect(err).Should(BeNil())
Expect(len(pds)).Should(Equal(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ var _ = Describe("PodDecoration controller", func() {
}, 5*time.Second, 1*time.Second).Should(BeEquivalentTo(2))
// annotation cleared
for _, po := range podList.Items {
Expect(po.Annotations[appsv1alpha1.AnnotationResourceDecorationRevision]).Should(BeEquivalentTo("[]"))
Expect(po.Annotations[appsv1alpha1.AnnotationPodDecorationRevision]).Should(BeEquivalentTo("[]"))
}
Eventually(func() error {
return c.Get(ctx, types.NamespacedName{Name: podDecoration.Name, Namespace: testcase}, podDecoration)
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/utils/poddecoration/anno.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func GetDecorationRevisionInfo(pod *corev1.Pod) (info DecorationRevisionInfo) {
if pod.Annotations == nil {
return
}
val, ok := pod.Annotations[appsv1alpha1.AnnotationResourceDecorationRevision]
val, ok := pod.Annotations[appsv1alpha1.AnnotationPodDecorationRevision]
if !ok {
return
}
Expand All @@ -69,7 +69,7 @@ func setDecorationInfo(pod *corev1.Pod, podDecorations map[string]*appsv1alpha1.
if pod.Annotations == nil {
pod.Annotations = map[string]string{}
}
pod.Annotations[appsv1alpha1.AnnotationResourceDecorationRevision] = GetDecorationInfoString(podDecorations)
pod.Annotations[appsv1alpha1.AnnotationPodDecorationRevision] = GetDecorationInfoString(podDecorations)
}

func GetDecorationInfoString(podDecorations map[string]*appsv1alpha1.PodDecoration) string {
Expand Down

0 comments on commit dbbb7e3

Please sign in to comment.