util: set pid limit only for nodeserver

setting pod limit only for nodeserver for below
reasons

* We dont execute any commands  with CLI
anymore in controller service
* Controller deployment is not privileged
enough to set the pid limits.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2023-04-25 09:38:03 +02:00 committed by mergify[bot]
parent 5cd2930744
commit b71beb7ad0

View File

@ -208,24 +208,7 @@ func main() {
logAndExit(err.Error())
}
// the driver may need a higher PID limit for handling all concurrent requests
if conf.PidLimit != 0 {
currentLimit, pidErr := util.GetPIDLimit()
if pidErr != nil {
klog.Errorf("Failed to get the PID limit, can not reconfigure: %v", pidErr)
} else {
log.DefaultLog("Initial PID limit is set to %d", currentLimit)
err = util.SetPIDLimit(conf.PidLimit)
switch {
case err != nil:
klog.Errorf("Failed to set new PID limit to %d: %v", conf.PidLimit, err)
case conf.PidLimit == -1:
log.DefaultLog("Reconfigured PID limit to %d (max)", conf.PidLimit)
default:
log.DefaultLog("Reconfigured PID limit to %d", conf.PidLimit)
}
}
}
setPIDLimit(&conf)
if conf.EnableGRPCMetrics || conf.Vtype == livenessType {
// validate metrics endpoint
@ -282,6 +265,28 @@ func main() {
os.Exit(0)
}
func setPIDLimit(conf *util.Config) {
// set pidLimit only for NodeServer
// the driver may need a higher PID limit for handling all concurrent requests
if conf.IsNodeServer && conf.PidLimit != 0 {
currentLimit, pidErr := util.GetPIDLimit()
if pidErr != nil {
klog.Errorf("Failed to get the PID limit, can not reconfigure: %v", pidErr)
} else {
log.DefaultLog("Initial PID limit is set to %d", currentLimit)
err := util.SetPIDLimit(conf.PidLimit)
switch {
case err != nil:
klog.Errorf("Failed to set new PID limit to %d: %v", conf.PidLimit, err)
case conf.PidLimit == -1:
log.DefaultLog("Reconfigured PID limit to %d (max)", conf.PidLimit)
default:
log.DefaultLog("Reconfigured PID limit to %d", conf.PidLimit)
}
}
}
}
// initControllers will initialize all the controllers.
func initControllers() {
// Add list of controller here.