Skip to content

Commit 919600c

Browse files
authored
Merge pull request #1413 from YaoZengzeng/fix-crosss
fix flaky of `TestCrossNamespace`
2 parents e56e0ac + b7848f1 commit 919600c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/controller/manage/manage_controller.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (c *KmeshManageController) handlePodAdd(obj interface{}) {
159159
c.enableKmeshManage(newPod)
160160
}
161161

162-
func (c *KmeshManageController) handlePodUpdate(_, newObj interface{}) {
162+
func (c *KmeshManageController) handlePodUpdate(oldObj, newObj interface{}) {
163163
pod, ok := newObj.(*corev1.Pod)
164164
if !ok {
165165
log.Errorf("expected *corev1.Pod but got %T", newObj)
@@ -169,6 +169,20 @@ func (c *KmeshManageController) handlePodUpdate(_, newObj interface{}) {
169169
log.Debugf("pod %s/%s is being deleted, skip remanage", pod.Namespace, pod.Name)
170170
return
171171
}
172+
173+
oldPod, ok := oldObj.(*corev1.Pod)
174+
if !ok {
175+
log.Errorf("expected *corev1.Pod but got %T", oldObj)
176+
return
177+
}
178+
179+
// We don't need to remanage the pod if the annotation of KmeshRedirectionAnnotation is changed.
180+
// Ref: https://github.com/kmesh-net/kmesh/issues/1357
181+
if oldPod.Annotations[constants.KmeshRedirectionAnnotation] != pod.Annotations[constants.KmeshRedirectionAnnotation] {
182+
log.Debugf("pod %s/%s annotation of KmeshRedirectionAnnotation is changed, skip remanage", pod.Namespace, pod.Name)
183+
return
184+
}
185+
172186
c.handlePodAdd(newObj)
173187
}
174188

0 commit comments

Comments
 (0)