Skip to content

Commit

Permalink
memtierd: golangci-lint fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Dec 9, 2024
1 parent d3b00d4 commit 36b8c06
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/plugins/memtierd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (

type plugin struct {
stub stub.Stub
mask stub.EventMask
config *pluginConfig
cgroupsDir string
ctrMemtierdEnv map[string]*memtierdEnv
Expand Down Expand Up @@ -73,7 +72,6 @@ type qosClass struct {
}

type memtierdEnv struct {
pid int
ctrDir string
configFile string
outputFile string
Expand Down Expand Up @@ -314,7 +312,11 @@ func (p *plugin) StopContainer(ctx context.Context, pod *api.PodSandbox, ctr *ap
log.Debugf("StopContainer: killing memtierd of %s (pid: %d) failed: %s", ppName, pid, err)
}
// Close files, read exit status (leave no zombie processes behind)
go mtdEnv.cmd.Wait()
go func() {
if err := mtdEnv.cmd.Wait(); err != nil {
log.Errorf("StopContainer: waiting for memtierd of %s (pid: %d) failed: %s", ppName, pid, err)
}
}()
}

log.Tracef("StopContainer: removing memtierd run directory %s", mtdEnv.ctrDir)
Expand Down Expand Up @@ -438,9 +440,11 @@ func (me *memtierdEnv) startMemtierd() error {
return fmt.Errorf("failed to start command %s: %q", cmd, err)
}
if cmd.Process != nil {
os.WriteFile(me.pidFile,
if err := os.WriteFile(me.pidFile,
[]byte(fmt.Sprintf("%d\n", cmd.Process.Pid)),
0400)
0400); err != nil {
log.Warnf("failed to write PID file %q: %s", me.pidFile, err)
}
}
me.cmd = cmd
return nil
Expand Down

0 comments on commit 36b8c06

Please sign in to comment.