From a862152d7bbc51c0a82d3b8f20cfc096118fb177 Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Wed, 11 Sep 2024 19:28:43 +0000 Subject: [PATCH] Keep the kernel.pid_max smaller than 1048575. --- topo/topo.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/topo/topo.go b/topo/topo.go index 41a91292..b0c0f0a8 100644 --- a/topo/topo.go +++ b/topo/topo.go @@ -19,6 +19,7 @@ import ( "fmt" "io" "os" + "path/filepath" "strings" "time" @@ -29,6 +30,7 @@ import ( "github.com/openconfig/gnmi/errlist" "github.com/openconfig/kne/cluster/kind" "github.com/openconfig/kne/events" + "github.com/openconfig/kne/exec/run" "github.com/openconfig/kne/metrics" "github.com/openconfig/kne/pods" cpb "github.com/openconfig/kne/proto/controller" @@ -45,6 +47,7 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" + "k8s.io/client-go/util/homedir" log "k8s.io/klog/v2" _ "github.com/openconfig/kne/topo/node/alpine" @@ -61,6 +64,7 @@ import ( ) var ( + setPIDMaxScript = filepath.Join(homedir.HomeDir(), "kne-internal", "set_pid_max.sh") protojsonUnmarshaller = protojson.UnmarshalOptions{ AllowPartial: true, DiscardUnknown: false, @@ -484,6 +488,14 @@ func (m *Manager) load() error { uid++ } for k, n := range nMap { + // If the script is found, then run it. Else silently ignore it. + // The set_pid_max script modifies the kernel.pid_max value to + // be acceptable for the Cisco 8000e container. + if _, err := os.Stat(setPIDMaxScript); err == nil { + if err := run.LogCommand(setPIDMaxScript); err != nil { + return fmt.Errorf("failed to exec set_pid_max script: %w", err) + } + } log.Infof("Adding Node: %s:%s", n.Name, n.Vendor) nn, err := node.New(m.topo.Name, n, m.kClient, m.rCfg, m.basePath, m.kubecfg) if err != nil {