Skip to content

Commit

Permalink
ws-daemon: Add the disposal in the priority plugin when the workspace…
Browse files Browse the repository at this point in the history
… has gone
  • Loading branch information
utam0k authored and roboquat committed Oct 24, 2022
1 parent bc4d4c3 commit 9bdc0a5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions components/ws-daemon/pkg/cgroup/plugin_process_priority_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ func (c *ProcessPriorityV2) Type() Version { return Version2 }
func (c *ProcessPriorityV2) Apply(ctx context.Context, opts *PluginOptions) error {
fullCgroupPath := filepath.Join(opts.BasePath, opts.CgroupPath)

_, err := os.Stat(fullCgroupPath)
if errors.Is(err, fs.ErrNotExist) {
return xerrors.Errorf("cannot read cgroup directory %s: %w", fullCgroupPath, err)
}

go func() {
time.Sleep(10 * time.Second)

data, err := ioutil.ReadFile(filepath.Join(fullCgroupPath, "workspace", "user", "cgroup.procs"))
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
log.WithField("path", fullCgroupPath).WithError(err).Warn("the target cgroup has gone")
return
} else if err != nil {
log.WithField("path", fullCgroupPath).WithError(err).Errorf("cannot read cgroup.procs file")
return
}
Expand Down

0 comments on commit 9bdc0a5

Please sign in to comment.