Skip to content

Commit

Permalink
[ws-daemon] Check blkio throttle exists
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Apr 22, 2022
1 parent 02a04a7 commit e8c26c8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/ws-daemon/pkg/cgroup/plugin_iolimit_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cgroup

import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit e8c26c8

Please sign in to comment.