Commit e2fb251c authored by k8s-merge-robot's avatar k8s-merge-robot Committed by GitHub

Merge pull request #29266 from xiangpengzhao/fix_defer_close

Automatic merge from submit-queue Add f.Close() for applyOOMScoreAdj
parents 6fd685b5 91d11ed7
...@@ -76,6 +76,12 @@ func applyOOMScoreAdj(pid int, oomScoreAdj int) error { ...@@ -76,6 +76,12 @@ func applyOOMScoreAdj(pid int, oomScoreAdj int) error {
continue continue
} }
if _, err := f.Write([]byte(value)); err != nil { if _, err := f.Write([]byte(value)); err != nil {
// we can ignore the return value of f.Close() here.
f.Close()
err = fmt.Errorf("failed to apply oom-score-adj to pid %d (%v)", pid, err)
continue
}
if err = f.Close(); err != nil {
err = fmt.Errorf("failed to apply oom-score-adj to pid %d (%v)", pid, err) err = fmt.Errorf("failed to apply oom-score-adj to pid %d (%v)", pid, err)
continue continue
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment