From 9f51f9064d66827a2ac3462eee605112fc9e9d4a Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Wed, 3 Jul 2019 11:26:35 +0800 Subject: [PATCH] Fix poolmanager specializes a function pod repeatedly if istio is enabled (#1208) --- pkg/executor/poolmgr/gpm.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/executor/poolmgr/gpm.go b/pkg/executor/poolmgr/gpm.go index 34e89b6c..801d5575 100644 --- a/pkg/executor/poolmgr/gpm.go +++ b/pkg/executor/poolmgr/gpm.go @@ -300,9 +300,16 @@ func (gpm *GenericPoolManager) IsValid(fsvc *fscache.FuncSvc) bool { for _, obj := range fsvc.KubernetesObjects { if obj.Kind == "pod" { pod, err := gpm.kubernetesClient.CoreV1().Pods(obj.Namespace).Get(obj.Name, metav1.GetOptions{}) - if err == nil && strings.Contains(fsvc.Address, pod.Status.PodIP) && utils.IsReadyPod(pod) { - gpm.logger.Info("valid pod address", zap.String("address", fsvc.Address)) - return true + if err == nil && utils.IsReadyPod(pod) { + // Normally, the address format is http://[pod-ip]:[port], however, if the + // Istio is enabled the address format changes to http://[svc-name]:[port]. + // So if the Istio is enabled and pod is in ready state, we return true directly; + // Otherwise, we need to ensure that the address contains pod ip. + if gpm.enableIstio || + (!gpm.enableIstio && strings.Contains(fsvc.Address, pod.Status.PodIP)) { + gpm.logger.Debug("valid address", zap.String("address", fsvc.Address)) + return true + } } } }