From e8c26c8132dfe1d59ec90be9ea1b6b6411b620bb Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Fri, 22 Apr 2022 08:45:37 -0400 Subject: [PATCH] [ws-daemon] Check blkio throttle exists --- .../ws-daemon/pkg/cgroup/plugin_iolimit_v1.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/ws-daemon/pkg/cgroup/plugin_iolimit_v1.go b/components/ws-daemon/pkg/cgroup/plugin_iolimit_v1.go index 75d4a401ed5967..696f839dc5075f 100644 --- a/components/ws-daemon/pkg/cgroup/plugin_iolimit_v1.go +++ b/components/ws-daemon/pkg/cgroup/plugin_iolimit_v1.go @@ -6,6 +6,7 @@ package cgroup import ( "context" + "errors" "fmt" "os" "path/filepath" @@ -94,11 +95,17 @@ func (c *IOLimiterV1) Apply(ctx context.Context, basePath, cgroupPath string) er return lines } - writeLimit := func(fn string, content []string) error { + writeLimit := func(limitPath string, content []string) error { for _, l := range content { - err := os.WriteFile(fn, []byte(l), 0644) + _, err := os.Stat(limitPath) + if errors.Is(err, os.ErrNotExist) { + log.WithError(err).WithField("limitPath", limitPath).Debug("blkio file does not exist") + continue + } + + err = os.WriteFile(limitPath, []byte(l), 0644) if err != nil { - log.WithError(err).WithField("fn", fn).WithField("line", l).Warn("cannot write limit") + log.WithError(err).WithField("limitPath", limitPath).WithField("line", l).Warn("cannot write limit") continue } }