Merge pull request #8267 from helen-frank/feature/OptimizationcheckBinarySizes

Optimization containerd-stress
This commit is contained in:
Derek McGowan 2023-03-14 17:16:20 -07:00 committed by GitHub
commit fe3cd1781b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 30 deletions

View File

@ -158,8 +158,13 @@ func criCleanup(ctx context.Context, client internalapi.RuntimeService) error {
}
for _, sb := range sandboxes {
client.StopPodSandbox(sb.Id)
client.RemovePodSandbox(sb.Id)
if err := client.StopPodSandbox(sb.Id); err != nil {
return err
}
if err := client.RemovePodSandbox(sb.Id); err != nil {
return err
}
}
return nil

View File

@ -22,17 +22,15 @@ import (
func setRlimit() error {
rlimit := int64(100000)
if rlimit > 0 {
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err
}
if limit.Cur < rlimit {
limit.Cur = rlimit
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err
}
if limit.Cur < rlimit {
limit.Cur = rlimit
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err
}
}
}
return nil
}

View File

@ -24,19 +24,17 @@ import (
func setRlimit() error {
rlimit := uint64(100000)
if rlimit > 0 {
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err
}
if limit.Cur < rlimit {
limit.Cur = rlimit
if limit.Max < limit.Cur {
limit.Max = limit.Cur
}
if limit.Cur < rlimit {
limit.Cur = rlimit
if limit.Max < limit.Cur {
limit.Max = limit.Cur
}
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err
}
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err
}
}
return nil

View File

@ -18,27 +18,34 @@ package main
import (
"os"
"path/filepath"
"github.com/sirupsen/logrus"
)
const defaultPath = "/usr/local/bin/"
var binaries = []string{
"ctr",
"containerd",
"containerd-shim",
"containerd-shim-runc-v1",
"containerd-shim-runc-v2",
defaultPath + "ctr",
defaultPath + "containerd",
defaultPath + "containerd-shim",
defaultPath + "containerd-shim-runc-v1",
defaultPath + "containerd-shim-runc-v2",
}
// checkBinarySizes checks and reports the binary sizes for the containerd compiled binaries to prometheus
func checkBinarySizes() {
for _, name := range binaries {
fi, err := os.Stat(filepath.Join("/usr/local/bin", name))
fi, err := os.Stat(name)
if err != nil {
logrus.WithError(err).Error("stat binary")
continue
}
if fi.IsDir() {
logrus.Error(name, "is not a file")
continue
}
binarySizeGauge.WithValues(name).Set(float64(fi.Size()))
}
}