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 98a02f8  cache avalanche
98a02f8 is described below

commit 98a02f8abc67b54490e07d52f814569b1b73fda9
Author: mrproliu <[email protected]>
AuthorDate: Sat Dec 28 20:43:11 2024 +0800

    cache avalanche
---
 pkg/process/finders/kubernetes/finder.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pkg/process/finders/kubernetes/finder.go 
b/pkg/process/finders/kubernetes/finder.go
index 66ba15d..ec99938 100644
--- a/pkg/process/finders/kubernetes/finder.go
+++ b/pkg/process/finders/kubernetes/finder.go
@@ -21,6 +21,7 @@ import (
        "bufio"
        "context"
        "fmt"
+       "k8s.io/apimachinery/pkg/util/rand"
        "os"
        "regexp"
        "strconv"
@@ -423,6 +424,8 @@ func (f *ProcessFinder) IsPodIP(ip string) (bool, error) {
        }
        found := len(pods.Items) > 0
 
-       f.podIPChecker.Set(ip, found, ipExistTimeout)
+       // the timeout added a random value to avoid the cache avalanche
+       addedTime := time.Millisecond * time.Duration(rand.IntnRange(500, 5000))
+       f.podIPChecker.Set(ip, found, ipExistTimeout+addedTime)
        return found, nil
 }

Reply via email to