The count lives in the per-process environment and is only reported by
a forked task at its end. A warning logged while handling a plain API
request stays counted, so every task the process forks afterwards ends
with WARNINGS although nothing in its log warned.

Signed-off-by: Hannes Laimer <[email protected]>
---
reproducer:

run it against a running guest
```
curl -sk -H "$T" -X PUT 
https://localhost:8006/api2/json/nodes/$N/qemu/$V/config --data-urlencode 
"net9=model=e1000,bridge=vmbr0,mtu=1400"
```
potentially a few times with different nics, so every worker is getting
the warning. Then just open a console, and close it again. The warning
count is on the worker, so every task the worker spawns will inherit
this count.

```
Sep 04 08:45:47 sdn1 pvedaemon[19533]: netdev net9: ignoring MTU '1400', not 
using VirtIO
```
is the warning the worker counted, and is in the syslog.

 src/PVE/RESTEnvironment.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
index 81d7e29..7c75272 100644
--- a/src/PVE/RESTEnvironment.pm
+++ b/src/PVE/RESTEnvironment.pm
@@ -562,6 +562,9 @@ sub fork_worker {
 
         $0 = "task $upid";
         $WORKER_FLAG = 1;
+        # the count is reported at the end of this task, warnings the parent 
logged while
+        # handling requests before the fork are not part of it
+        $self->{warning_count} = 0;
 
         $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { die "received 
interrupt\n"; };
 
-- 
2.47.3




Reply via email to