istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pilot/cmd/pilot-agent/app/fds.go (about)

     1  // Copyright Istio Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package app
    16  
    17  // RaiseFileLimits sets the file limit to the maximum allowed, to avoid exhaustion of file descriptors.
    18  // This is done by setting soft limit == hard limit.
    19  // Typical container runtimes already do this, but on VMs, etc this is generally not the case, and a limit of 1024 is common -- this is quite low!
    20  //
    21  // Go already sets this (https://github.com/golang/go/issues/46279).
    22  // However, it will restore the original limit for subprocesses (Envoy):
    23  // https://github.com/golang/go/blob/f0d1195e13e06acdf8999188decc63306f9903f5/src/syscall/rlimit.go#L14.
    24  // By explicitly doing it ourselves, we get the limit passed through to Envoy.
    25  //
    26  // This function returns the new limit additionally, for convenience.
    27  func RaiseFileLimits() (uint64, error) {
    28  	return raiseFileLimits()
    29  }