@@ -1670,11 +1670,14 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
1670
1670
1671
1671
score , niceErr := proc .Niceness (a .syscaller )
1672
1672
if niceErr != nil && ! xerrors .Is (niceErr , os .ErrPermission ) {
1673
- debouncer .Warn (ctx , "unable to get proc niceness" ,
1674
- slog .F ("cmd" , proc .Cmd ()),
1675
- slog .F ("pid" , proc .PID ),
1676
- slog .Error (niceErr ),
1677
- )
1673
+ if ! isNoSuchProcessErr (niceErr ) {
1674
+ debouncer .Warn (ctx , "unable to get proc niceness" ,
1675
+ slog .F ("cmd" , proc .Cmd ()),
1676
+ slog .F ("pid" , proc .PID ),
1677
+ slog .Error (niceErr ),
1678
+ )
1679
+ }
1680
+
1678
1681
continue
1679
1682
}
1680
1683
@@ -1690,12 +1693,14 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
1690
1693
if niceErr == nil {
1691
1694
err := proc .SetNiceness (a .syscaller , niceness )
1692
1695
if err != nil && ! xerrors .Is (err , os .ErrPermission ) {
1693
- debouncer .Warn (ctx , "unable to set proc niceness" ,
1694
- slog .F ("cmd" , proc .Cmd ()),
1695
- slog .F ("pid" , proc .PID ),
1696
- slog .F ("niceness" , niceness ),
1697
- slog .Error (err ),
1698
- )
1696
+ if ! isNoSuchProcessErr (err ) {
1697
+ debouncer .Warn (ctx , "unable to set proc niceness" ,
1698
+ slog .F ("cmd" , proc .Cmd ()),
1699
+ slog .F ("pid" , proc .PID ),
1700
+ slog .F ("niceness" , niceness ),
1701
+ slog .Error (err ),
1702
+ )
1703
+ }
1699
1704
}
1700
1705
}
1701
1706
@@ -1704,12 +1709,14 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
1704
1709
oomScoreStr := strconv .Itoa (oomScore )
1705
1710
err := afero .WriteFile (a .filesystem , fmt .Sprintf ("/proc/%d/oom_score_adj" , proc .PID ), []byte (oomScoreStr ), 0o644 )
1706
1711
if err != nil && ! xerrors .Is (err , os .ErrPermission ) {
1707
- debouncer .Warn (ctx , "unable to set oom_score_adj" ,
1708
- slog .F ("cmd" , proc .Cmd ()),
1709
- slog .F ("pid" , proc .PID ),
1710
- slog .F ("score" , oomScoreStr ),
1711
- slog .Error (err ),
1712
- )
1712
+ if ! isNoSuchProcessErr (err ) {
1713
+ debouncer .Warn (ctx , "unable to set oom_score_adj" ,
1714
+ slog .F ("cmd" , proc .Cmd ()),
1715
+ slog .F ("pid" , proc .PID ),
1716
+ slog .F ("score" , oomScoreStr ),
1717
+ slog .Error (err ),
1718
+ )
1719
+ }
1713
1720
}
1714
1721
}
1715
1722
modProcs = append (modProcs , proc )
@@ -2139,3 +2146,7 @@ func (l *logDebouncer) log(ctx context.Context, level slog.Level, msg string, fi
2139
2146
}
2140
2147
l .messages [msg ] = time .Now ()
2141
2148
}
2149
+
2150
+ func isNoSuchProcessErr (err error ) bool {
2151
+ return err != nil && strings .Contains (err .Error (), "no such process" )
2152
+ }
0 commit comments