From 1e4b2e2d27904bae2586791ad7351ffa745fe37f Mon Sep 17 00:00:00 2001 From: junqian Date: Mon, 18 Jan 2021 16:54:49 +0800 Subject: [PATCH] bug fix for pods with different controllerRef --- pkg/tapp/controller.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/tapp/controller.go b/pkg/tapp/controller.go index 27ae367..d76b9e9 100644 --- a/pkg/tapp/controller.go +++ b/pkg/tapp/controller.go @@ -308,7 +308,16 @@ func (c *Controller) getPodsForTApp(tapp *tappv1.TApp) ([]*corev1.Pod, error) { result := make([]*corev1.Pod, 0, len(pods)) for i := range pods { // TODO: does it impact performance? - result = append(result, pods[i].DeepCopy()) + controllerRef := metav1.GetControllerOf(pods[i]) + if controllerRef == nil { + continue + } + if controllerRef.UID == tapp.UID { + result = append(result, pods[i].DeepCopy()) + } else { + klog.V(4).Infof("pod %s in namespace %s matches the selector of tapp %s, but has different controllerRef", + pods[i].Name, pods[i].Namespace, util.GetTAppFullName(tapp)) + } } return result, nil }