oVirt / vdsm

The Virtual Desktop Server Manager
GNU General Public License v2.0
161 stars 202 forks source link

qemuimg: log warning on cmd error #356

Closed aesteve-rh closed 1 year ago

aesteve-rh commented 1 year ago

Add flag warn_stderr to Command class to log to WARNING level instead of DEBUG level if the command execution has data in the stderr output, even if the command finished succesfully.

Also, the logged message changes if the new warn_stderr flag is set, printing the command that originated the error output.

Legacy debug logging remains unchanged.

ProgressCommand in qemuimg will enable the flag so that qemuimg commands show warning on errors.

Example:

09:49:34,851 WARNING (MainThread) [storage.operation] Command
   ['/usr/bin/qemu-img', 'commit', '-p', '-t', 'none', '-b'...]
   succeeded with warnings: bytearray(b"qcow2_free_clusters failed: No space left on
   device\nqemu-img: Lost persistent bitmaps during inactivation of node \'#block365\':
   Failed to write bitmap \'stale-bitmap5\' to file: No space left on
   device\nqemu-img: Failed to flush the refcount block cache: No space
   left on device\n") (operation:159)']

Signed-off-by: Albert Esteve aesteve@redhat.com

nirs commented 1 year ago

Add flag to Command class to log to WARNING level instead of DEBUG level if the command execution has data in the stderr output, even if the command finished succesfully.

This was correct for the initial implementation, but now we don't change only the log level but log different log for this case.

ProgressCommand in qemuimg will enable the flag so that qemuimg commands show warning on errors.

Example:

09:49:34,851 WARNING (MainThread) [storage.operation] Command
   ['/usr/bin/qemu-img', 'commit', '-p', '-t', 'none', '-b'...]
   succeeded with warnings: SUCCESS: <err> = bytearray(b"qcow2_free_clusters failed: No space left on
   device\nqemu-img: Lost persistent bitmaps during inactivation of node \'#block365\':
   Failed to write bitmap \'stale-bitmap5\' to file: No space left on
   device\nqemu-img: Failed to flush the refcount block cache: No space
   left on device\n"); <rc> = 0 (operation:159)']

Warning looks good!

Except the SUCCESS: <err> and ; <rc> = 0 - these is legacy text that should remain in the legacy debug log.

mz-pdm commented 1 year ago

/ost