oVirt / vdsm

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

virt: Fix negative cpuUser value in getAllVmStats #378

Closed saksham-oracle closed 1 year ago

saksham-oracle commented 1 year ago

When calling the command 'vdsm-client Host getAllVmStats', sometimes value of cpuUser was coming negative.

Fix:

The cpuUser value was coming negative due to less accuracy of user_time and system_time values (upto 2 decimal) as compared to cpu_time values (upto 9 decimal) returned by libvirt. Fixed the issue by adding the check in vmstats.py for negative cpuUser values and setting them to 0.

Signed-off-by: Saksham Srivastava saksham.sa.srivastava@oracle.com

saksham-oracle commented 1 year ago

Can someone review this? I have made the suggested changes.

saksham-oracle commented 1 year ago

Made changes for the failed checks too:

lib/vdsm/virt/vmstats.py:134:80: E501 line too long (81 > 79 characters)
            stats['cpuUser'] = 0.00 if stats['cpuUser'] < 0 else stats['cpuUser']
saksham-oracle commented 1 year ago

Removed the trailing spaces that caused the test failure last time.

mz-pdm commented 1 year ago

Great, looks good now and CI passes. The last thing to do is to add a proper header line to the commit message. See other commits in Vdsm repository how the first lines of commit messages look like, something like "virt: Fix negative cpuUsed in getAllVmStats" could fit here.

saksham-oracle commented 1 year ago

Thanks, made the change.

mz-pdm commented 1 year ago

Ah, I meant the header line of the commit message, not of the PR.

saksham-oracle commented 1 year ago

Made the change to commit message.

mz-pdm commented 1 year ago

/ost

mz-pdm commented 1 year ago

/ci

mz-pdm commented 1 year ago

Hm, CI is not in a very good mood today: shaky tests, OST failing, ... @michalskrivanek what can we do about it?

michalskrivanek commented 1 year ago

el8stream doesn't work due to ansible 2.14 currently. try el9stream

michalskrivanek commented 1 year ago

/ost basic-suite-master el9stream

mz-pdm commented 1 year ago

/ost

mz-pdm commented 1 year ago

/ost basic-suite-master el9stream

mz-pdm commented 1 year ago

/ost basic-suite-master el9stream

michalskrivanek commented 1 year ago

/ost basic-suite-master el9stream

mz-pdm commented 1 year ago

Thank you for the contribution!