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 { for _, sb := range sandboxes {
client.StopPodSandbox(sb.Id) if err := client.StopPodSandbox(sb.Id); err != nil {
client.RemovePodSandbox(sb.Id) return err
}
if err := client.RemovePodSandbox(sb.Id); err != nil {
return err
}
} }
return nil return nil

View File

@ -22,7 +22,6 @@ import (
func setRlimit() error { func setRlimit() error {
rlimit := int64(100000) rlimit := int64(100000)
if rlimit > 0 {
var limit syscall.Rlimit var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err return err
@ -33,6 +32,5 @@ func setRlimit() error {
return err return err
} }
} }
}
return nil return nil
} }

View File

@ -24,7 +24,6 @@ import (
func setRlimit() error { func setRlimit() error {
rlimit := uint64(100000) rlimit := uint64(100000)
if rlimit > 0 {
var limit syscall.Rlimit var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err return err
@ -38,6 +37,5 @@ func setRlimit() error {
return err return err
} }
} }
}
return nil return nil
} }

View File

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