Skip to content

Fix memory stats for KVM - #6358

Merged
DaanHoogland merged 18 commits into
apache:mainfrom
scclouds:fix-memory-stats-for-kvm
Nov 9, 2022
Merged

Fix memory stats for KVM#6358
DaanHoogland merged 18 commits into
apache:mainfrom
scclouds:fix-memory-stats-for-kvm

Conversation

@joseflauzino

Copy link
Copy Markdown
Contributor

Description

Using KVM hypervisor, the free memory stats of the user VMs that are returned by ACS do not correspond to those observed directly in the VMs (when using the free -m command, for example).

It was identified that the problem was in the memory stats collection process performed by Libvirt. This happens because the period that Libvirt would get memory stats updates for each VM was never set. Thus, even if ACS periodically requested the stats for the hosts, the data obtained were always the same.

This PR solves the mentioned problem. A new Agent configuration parameter called vm.memballoon.stats.period was created. This parameter allows operatos to set the time interval in which Libvirt will get memory stats updates. The default value of this parameter is 60 seconds, the same default value as the vm.stats.interval parameter. However, in a cloud containing multiple Management Servers, operators can set the value of vm.memballoon.stats.period lower than the vm.stats.interval, so that each Management Server always gets updated memory stats for all user VMs (since each Management Server can request stats at different instants).

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

In a local lab, I tested multiple combinations for all the related Agent properties (vm.memballoon.stats.period, vm.stats.interval, and vm.memballoon.disable). In all cases tested, the memory stats of the user VMs were obtained properly.
Also, I added unit tests.

Comment thread agent/src/main/java/com/cloud/agent/Agent.java Outdated
@joseflauzino

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@joseflauzino a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 3358

…tead of virsh command to get Libvirt domains
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@acs-robot

Copy link
Copy Markdown

Found UI changes, kicking a new UI QA build
@blueorangutan ui

@joseflauzino

Copy link
Copy Markdown
Contributor Author

I moved the code to a more appropriate location. Also, I adjusted the code to get the VM list (Libvirt domains) by using libvirt-java instead of a virsh command.
Thanks for the reviews.

@acs-robot

Copy link
Copy Markdown

Found UI changes, kicking a new UI QA build
@blueorangutan ui

@blueorangutan

Copy link
Copy Markdown

@acs-robot a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

UI build: ✔️
Live QA URL: http://qa.cloudstack.cloud:8080/client/pr/6358 (SL-JID-1609)

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joseflauzino ,
please have a look at the code smells reported:

SonarCloud Quality Gate failed. Quality Gate failed

Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 12 Code Smells

71.6% 71.6% Coverage 0.0% 0.0% Duplication

some of them make more sense than others, but none arereally senseless as far as I can see.

Comment thread agent/src/main/java/com/cloud/agent/properties/AgentProperties.java Outdated
Comment thread agent/src/main/java/com/cloud/agent/properties/AgentProperties.java Outdated
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@joseflauzino

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@joseflauzino a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@sonarqubecloud

sonarqubecloud Bot commented Jun 3, 2022

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 11 Code Smells

70.9% 70.9% Coverage
0.0% 0.0% Duplication

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 3525

Comment thread agent/src/main/java/com/cloud/agent/properties/AgentProperties.java Outdated
@yadvr

yadvr commented Jul 27, 2022

Copy link
Copy Markdown
Member

ping @joseflauzino can you address the review comments?

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-5184)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 39770 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6358-t5184-kvm-centos7.zip
Smoke tests completed. 99 look OK, 5 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_add_primary_storage_disabled_host Error 0.60 test_primary_storage.py
test_01_primary_storage_nfs Error 0.10 test_primary_storage.py
ContextSuite context=TestStorageTags>:setup Error 0.18 test_primary_storage.py
test_01_secure_vm_migration Error 156.36 test_vm_life_cycle.py
test_02_unsecure_vm_migration Error 270.83 test_vm_life_cycle.py
test_03_secured_to_nonsecured_vm_migration Error 141.97 test_vm_life_cycle.py
test_08_migrate_vm Error 43.85 test_vm_life_cycle.py
test_03_deploy_and_scale_kubernetes_cluster Failure 33.00 test_kubernetes_clusters.py
test_07_deploy_kubernetes_ha_cluster Failure 60.73 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 38.07 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 39.99 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 130.33 test_kubernetes_clusters.py
test_02_list_snapshots_with_removed_data_store Error 8.56 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 8.56 test_snapshots.py
test_hostha_enable_ha_when_host_in_maintenance Error 304.80 test_hostha_kvm.py

Comment thread agent/src/main/java/com/cloud/agent/properties/AgentProperties.java Outdated
@weizhouapache

Copy link
Copy Markdown
Member

@joseflauzino
I use some your changes in fb86898

@acs-robot

Copy link
Copy Markdown

Found UI changes, kicking a new UI QA build
@blueorangutan ui

@joseflauzino

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@joseflauzino a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. LL-JID 184

Comment thread agent/conf/agent.properties Outdated
Comment thread agent/conf/agent.properties Outdated
* 1st parameter: the VM name;<br>
* 2nd parameter: the period (in seconds).
*/
private static final String COMMAND_SET_MEM_BALLOON_STATS_PERIOD = "virsh dommemstat %s --period %s --live";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GutoVeronezi
GutoVeronezi self-requested a review November 7, 2022 14:29
@joseflauzino

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@joseflauzino a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. LL-JID 212

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, two minor sonar issues. will re-run regression tests.
Most of the sonar issues are not your doing @joseflauzino . Could you have a quick look anyway?

@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2022

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 13 Code Smells

75.1% 75.1% Coverage
0.0% 0.0% Duplication

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-46)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 44501 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6358-t46-kvm-centos7.zip
Smoke tests completed. 102 look OK, 2 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_02_upgrade_kubernetes_cluster Failure 264.05 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 492.99 test_kubernetes_clusters.py
test_01_redundant_vpc_site2site_vpn Failure 749.85 test_vpc_vpn.py
test_01_vpc_site2site_vpn_multiple_options Error 1275.47 test_vpc_vpn.py
test_01_vpc_site2site_vpn Error 546.30 test_vpc_vpn.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KVM automatically adds ballooning

9 participants