@@ -1677,11 +1677,14 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
1677
1677
1678
1678
score , niceErr := proc .Niceness (a .syscaller )
1679
1679
if niceErr != nil && ! xerrors .Is (niceErr , os .ErrPermission ) {
1680
- debouncer .Warn (ctx , "unable to get proc niceness" ,
1681
- slog .F ("cmd" , proc .Cmd ()),
1682
- slog .F ("pid" , proc .PID ),
1683
- slog .Error (niceErr ),
1684
- )
1680
+ if ! isNoSuchProcessErr (niceErr ) {
1681
+ debouncer .Warn (ctx , "unable to get proc niceness" ,
1682
+ slog .F ("cmd" , proc .Cmd ()),
1683
+ slog .F ("pid" , proc .PID ),
1684
+ slog .Error (niceErr ),
1685
+ )
1686
+ }
1687
+
1685
1688
continue
1686
1689
}
1687
1690
@@ -1697,12 +1700,14 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
1697
1700
if niceErr == nil {
1698
1701
err := proc .SetNiceness (a .syscaller , niceness )
1699
1702
if err != nil && ! xerrors .Is (err , os .ErrPermission ) {
1700
- debouncer .Warn (ctx , "unable to set proc niceness" ,
1701
- slog .F ("cmd" , proc .Cmd ()),
1702
- slog .F ("pid" , proc .PID ),
1703
- slog .F ("niceness" , niceness ),
1704
- slog .Error (err ),
1705
- )
1703
+ if ! isNoSuchProcessErr (err ) {
1704
+ debouncer .Warn (ctx , "unable to set proc niceness" ,
1705
+ slog .F ("cmd" , proc .Cmd ()),
1706
+ slog .F ("pid" , proc .PID ),
1707
+ slog .F ("niceness" , niceness ),
1708
+ slog .Error (err ),
1709
+ )
1710
+ }
1706
1711
}
1707
1712
}
1708
1713
@@ -1711,12 +1716,14 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
1711
1716
oomScoreStr := strconv .Itoa (oomScore )
1712
1717
err := afero .WriteFile (a .filesystem , fmt .Sprintf ("/proc/%d/oom_score_adj" , proc .PID ), []byte (oomScoreStr ), 0o644 )
1713
1718
if err != nil && ! xerrors .Is (err , os .ErrPermission ) {
1714
- debouncer .Warn (ctx , "unable to set oom_score_adj" ,
1715
- slog .F ("cmd" , proc .Cmd ()),
1716
- slog .F ("pid" , proc .PID ),
1717
- slog .F ("score" , oomScoreStr ),
1718
- slog .Error (err ),
1719
- )
1719
+ if ! isNoSuchProcessErr (err ) {
1720
+ debouncer .Warn (ctx , "unable to set oom_score_adj" ,
1721
+ slog .F ("cmd" , proc .Cmd ()),
1722
+ slog .F ("pid" , proc .PID ),
1723
+ slog .F ("score" , oomScoreStr ),
1724
+ slog .Error (err ),
1725
+ )
1726
+ }
1720
1727
}
1721
1728
}
1722
1729
modProcs = append (modProcs , proc )
@@ -2146,3 +2153,7 @@ func (l *logDebouncer) log(ctx context.Context, level slog.Level, msg string, fi
2146
2153
}
2147
2154
l .messages [msg ] = time .Now ()
2148
2155
}
2156
+
2157
+ func isNoSuchProcessErr (err error ) bool {
2158
+ return err != nil && strings .Contains (err .Error (), "no such process" )
2159
+ }
0 commit comments