This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch reduce-handle-connect-time
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git
The following commit(s) were added to refs/heads/reduce-handle-connect-time by
this push:
new c7d6987 cache ip more time
c7d6987 is described below
commit c7d698710644b09723ff7c1de993274d55d59cf9
Author: mrproliu <[email protected]>
AuthorDate: Sat Dec 28 17:39:29 2024 +0800
cache ip more time
---
pkg/process/finders/kubernetes/finder.go | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/pkg/process/finders/kubernetes/finder.go
b/pkg/process/finders/kubernetes/finder.go
index 03f8481..66ba15d 100644
--- a/pkg/process/finders/kubernetes/finder.go
+++ b/pkg/process/finders/kubernetes/finder.go
@@ -56,7 +56,7 @@ var log = logger.GetLogger("process", "finder", "kubernetes")
var (
kubepodsRegex =
regexp.MustCompile(`cri-containerd-(?P<Group>\w+)\.scope`)
openShiftPodsRegex = regexp.MustCompile(`crio-(?P<Group>\w+)\.scope`)
- ipExistTimeout = time.Minute
+ ipExistTimeout = time.Minute * 10
)
type ProcessFinder struct {
@@ -416,16 +416,12 @@ func (f *ProcessFinder) IsPodIP(ip string) (bool, error) {
}
pods, err := f.CLI.CoreV1().Pods(v1.NamespaceAll).List(f.ctx,
metav1.ListOptions{
FieldSelector: fields.OneTermEqualSelector("status.podIP",
ip).String(),
+ Limit: 1,
})
if err != nil {
return false, err
}
- found := false
- for _, pod := range pods.Items {
- if pod.Status.PodIP == ip {
- found = true
- }
- }
+ found := len(pods.Items) > 0
f.podIPChecker.Set(ip, found, ipExistTimeout)
return found, nil