Skip to content

Commit

Permalink
Keep kernel.pid_max smaller than 1048575. (#565)
Browse files Browse the repository at this point in the history
* Keep the kernel.pid_max smaller than 1048575.

* Revise format and comment.
  • Loading branch information
guoshiuan committed Sep 11, 2024
1 parent bad633f commit e3017e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions topo/topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"time"

Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -61,6 +64,7 @@ import (
)

var (
setPIDMaxScript = filepath.Join(homedir.HomeDir(), "kne-internal", "set_pid_max.sh")
protojsonUnmarshaller = protojson.UnmarshalOptions{
AllowPartial: true,
DiscardUnknown: false,
Expand Down Expand Up @@ -484,6 +488,14 @@ func (m *Manager) load() error {
uid++
}
for k, n := range nMap {
// Bug: Some vendors incorrectly increase the value of kernel.pid_max which
// causes other vendors to have issues. Run this script as a temporary
// workaround.
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 {
Expand Down

0 comments on commit e3017e3

Please sign in to comment.