From b065c3c8115e3b06d791e193980c7b519e265412 Mon Sep 17 00:00:00 2001 From: shepherd cheung <1220798123@qq.com> Date: Tue, 9 Jul 2024 20:35:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=20Modification=E3=80=91=E4=BF=AE=E5=A4=8Ddeployment?= =?UTF-8?q?=E7=94=9F=E6=88=90ranktable=20bug=20=E3=80=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=BA=20Modifier=E3=80=91Atlas=5Fzxp=20=E3=80=90=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=E4=BA=BA=20Reviewer=E3=80=91Atlas=5Fkfa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/ring-controller/ranktable/v2/ranktable.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/ring-controller/ranktable/v2/ranktable.go b/pkg/ring-controller/ranktable/v2/ranktable.go index aa31ff7..f270a38 100644 --- a/pkg/ring-controller/ranktable/v2/ranktable.go +++ b/pkg/ring-controller/ranktable/v2/ranktable.go @@ -47,6 +47,10 @@ func (r *RankTable) BeforeUpdate() { // CachePodInfo :Cache pod info to RankTableV2 func (r *RankTable) CachePodInfo(pod *apiCoreV1.Pod, instance ranktablev1.Instance, rankStr string) error { + if _, ok := r.Servers.Load(pod.UID); ok { + return fmt.Errorf("%s/%s already exists in ranktable", pod.Namespace, pod.Name) + } + rankIndex, err := strconv.Atoi(rankStr) if err != nil { return fmt.Errorf("conv rankStr(%s) to int failed, err: %v", rankStr, err) -- Gitee From e86420b25de2ab8ab7789349ac5d3f219931ee97 Mon Sep 17 00:00:00 2001 From: shepherd cheung <1220798123@qq.com> Date: Wed, 10 Jul 2024 10:15:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=20Modification=E3=80=91=E4=BF=AE=E5=A4=8Ddeployment?= =?UTF-8?q?=E7=94=9F=E6=88=90ranktable=20bug=20=E3=80=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=BA=20Modifier=E3=80=91Atlas=5Fzxp=20=E3=80=90=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=E4=BA=BA=20Reviewer=E3=80=91Atlas=5Fkfa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/ring-controller/agent/vcjobworker.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/ring-controller/agent/vcjobworker.go b/pkg/ring-controller/agent/vcjobworker.go index 38f1aa1..851d9db 100644 --- a/pkg/ring-controller/agent/vcjobworker.go +++ b/pkg/ring-controller/agent/vcjobworker.go @@ -354,17 +354,17 @@ func (b *WorkerInfo) handleAddUpdateEvent(podInfo *podIdentifier, pod *apiCoreV1 if rankExist { return fmt.Errorf("pod %s/%s already has rankIndex: %s", pod.Namespace, pod.Name, rankIndexStr) } + rankIndexStr = strconv.Itoa(int(b.rankIndex)) - err := b.updatePod(pod, func(newPod *apiCoreV1.Pod) { - rankIndexStr = strconv.Itoa(int(b.rankIndex)) - newPod.Annotations[PodRankIndexKey] = rankIndexStr - }) + // Cache device info from the pod + err := b.configmapData.CachePodInfo(pod, instance, rankIndexStr) if err != nil { return err } - // Cache device info from the pod - err = b.configmapData.CachePodInfo(pod, instance, rankIndexStr) + err = b.updatePod(pod, func(newPod *apiCoreV1.Pod) { + newPod.Annotations[PodRankIndexKey] = rankIndexStr + }) if err != nil { return err } -- Gitee From d295a3cbcb98c5c673d2094b592f21ecb83654ef Mon Sep 17 00:00:00 2001 From: shepherd cheung <1220798123@qq.com> Date: Thu, 18 Jul 2024 12:13:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=20Modification=E3=80=91=E4=BF=AE=E5=A4=8Ddeployment?= =?UTF-8?q?=E7=94=9F=E6=88=90ranktable=20bug=20=E3=80=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=BA=20Modifier=E3=80=91Atlas=5Fzxp=20=E3=80=90=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=E4=BA=BA=20Reviewer=E3=80=91Atlas=5Fkfa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/ring-controller/ranktable/v2/ranktable_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/ring-controller/ranktable/v2/ranktable_test.go b/pkg/ring-controller/ranktable/v2/ranktable_test.go index de736c4..ad73641 100644 --- a/pkg/ring-controller/ranktable/v2/ranktable_test.go +++ b/pkg/ring-controller/ranktable/v2/ranktable_test.go @@ -62,8 +62,9 @@ func TestCachePodInfo(t *testing.T) { fake.CachePodInfo(po, instance, rank) po2 := &apiCoreV1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "test1"}} rank = RankNumExpect2 + expectedErr := errors.New("/test1 already exists in ranktable") err = fake.CachePodInfo(po2, instance, rank) - assert.Equal(t, nil, err) + assert.Equal(t, expectedErr, err) assert.Equal(t, RankNumExpect2, rank) fmt.Println("CachePodInfo() should return err != nil when deviceInfo is wrong") -- Gitee