cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Change storage pool scope from Cluster to Zone and vise versa

Open abh1sar opened this issue 1 year ago • 33 comments

Description

This PR adds the functionality to change the scope of the Primary storage from zone to cluster scope and vice versa.

Feature is tested and supported for Hypervisors : KVM and VMware (Simulator will also work) Protocol : NFS and Ceph, and Storage Provider : Default Primary

Although the supported configuration is mentioned above, the root admin can use this feature for other configurations as well, but proper warning would be given that officially this feature is only tested for a limited set of hypervisor-storage configuration. And other configurations might not work and need some extra steps. We will give this information in the UI prompt as well as Api docs. Apache CloudStack documentation will also get a mention on what hypervisors/storage is supported.

Documentation PR : https://github.com/apache/cloudstack-documentation/pull/395

The option for scope change is provided as a new action button to root admin once a Primary storage has been disabled.

A new api changeStoragePoolScope handles the execution after doing all relevant checks. It makes DB changes and also connects to the hypervisor hosts to add or remove the storage pool as required. It adds the storage pool to the applicable hosts when the scope is changing from Cluster to Zone. And it removes the storage pool from the hosts when the scope is changing from Zone to Cluster. Management server or the Cloudstack agents don’t need to be restarted for this.

Scope change from Zone to Cluster cannot be done if there are volumes associated with running-VMs belonging to other clusters. Api will throw an error in this case.

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)
  • [x] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
  • [ ] build/CI

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [x] Minor

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [ ] Minor
  • [ ] Trivial

Screenshots (if appropriate):

Screenshot from 2024-04-02 02-45-12

image

image

How Has This Been Tested?

KVM + NFS

Cluster to Zone
  1. Verified that Scope is changing correctly. Hosts in other clusters have the storage pool mounted.
  2. New instance on other clusters are able to use the storage pool
  3. Offline a host in Cluster C2. Change the scope from C1 to Zone. Online the host and verify that the storage pool gets mounted on the host.
Zone to Cluster
  1. Verified that Scope is changing correctly. Hosts in other clusters don't have the storage pool mounted.
  2. Offline a host in Cluster C2. Change the scope from Zone to Cluster C1. Online the host and verify that the storage pool gets gets removed from the host.
  3. Deploy a VM in Cluster C2 having a volume in the Zone wide storage pool. Change scope from Zone to C1 fails as we have a volume from C2 in the storage pool.
  4. Repeat of # 2 but the VM is in stopped state. This time scope change from Zone to C1 succeeds. Restart of the VM succeeds in C1 as the storage pool is now present in C1.

VMware + NFS

Tested basic functionality.

How did you try to break this feature and the system with this change?

abh1sar avatar Apr 03 '24 05:04 abh1sar

@blueorangutan package

rohityadavcloud avatar Apr 03 '24 05:04 rohityadavcloud

@rohityadavcloud a [SL] 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 avatar Apr 03 '24 05:04 blueorangutan

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9138

blueorangutan avatar Apr 03 '24 06:04 blueorangutan

@blueorangutan test

andrijapanicsb avatar Apr 03 '24 08:04 andrijapanicsb

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

blueorangutan avatar Apr 03 '24 08:04 blueorangutan

Codecov Report

Attention: Patch coverage is 48.17927% with 185 lines in your changes missing coverage. Please review.

Project coverage is 15.77%. Comparing base (814c8b6) to head (1b698c1).

Files Patch % Lines
...ain/java/com/cloud/storage/StorageManagerImpl.java 44.61% 23 Missing and 13 partials :warning:
...loudstack/api/response/VirtualMachineResponse.java 32.69% 35 Missing :warning:
...mmand/admin/storage/ChangeStoragePoolScopeCmd.java 13.88% 31 Missing :warning:
...n/java/com/cloud/resource/ResourceManagerImpl.java 0.00% 16 Missing :warning:
.../main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java 50.00% 11 Missing :warning:
...in/vm/ListAffectedVmsForStorageScopeChangeCmd.java 23.07% 10 Missing :warning:
...ain/java/com/cloud/api/query/QueryManagerImpl.java 75.67% 3 Missing and 6 partials :warning:
.../com/cloud/storage/dao/StoragePoolHostDaoImpl.java 46.15% 7 Missing :warning:
...e/lifecycle/BasePrimaryDataStoreLifeCycleImpl.java 86.04% 4 Missing and 2 partials :warning:
...orage/volume/datastore/PrimaryDataStoreHelper.java 86.48% 4 Missing and 1 partial :warning:
... and 10 more
Additional details and impacted files
@@             Coverage Diff              @@
##               4.19    #8875      +/-   ##
============================================
+ Coverage     15.01%   15.77%   +0.76%     
- Complexity    11086    11121      +35     
============================================
  Files          5393     5033     -360     
  Lines        471529   442426   -29103     
  Branches      59743    53754    -5989     
============================================
- Hits          70788    69782    -1006     
+ Misses       392854   364872   -27982     
+ Partials       7887     7772     -115     
Flag Coverage Δ
uitests ?
unittests 15.77% <48.17%> (+0.04%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Apr 03 '24 09:04 codecov-commenter

@abh1sar lint Github action is failing due to missing eof in some files.

vishesh92 avatar Apr 03 '24 09:04 vishesh92

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

Test Result Time (s) Test File
test_01_primary_storage_scope_change Error 0.06 test_primary_storage.py
test_02_trigger_shutdown Failure 341.66 test_safe_shutdown.py

blueorangutan avatar Apr 03 '24 23:04 blueorangutan

In a discussion with @rohityadavcloud and @andrijapanicsb it was decided to not gate this feature for other hypervisor and storage types. We will give the root admin the option to change the scope, but by giving enough warning that officially this feature is only tested for a limited set of hypervisor-storage configuration. And other configurations might not work and need some extra steps.

We will give this information in the UI prompt as well as Api docs. Apache CloudStack documentation will also get a mention on what hypervisors/storage is supported.

So, I have removed the checks in UI and StorageManagerImpl, and added proper warning. Only check present is for hypervisorType which is same as the hypervisor types currently supported for Zone wide primary storage.

abh1sar avatar Apr 06 '24 06:04 abh1sar

@blueorangutan package

weizhouapache avatar Apr 09 '24 12:04 weizhouapache

@weizhouapache a [SL] 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 avatar Apr 09 '24 12:04 blueorangutan

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9203

blueorangutan avatar Apr 09 '24 13:04 blueorangutan

@blueorangutan test rocky8 kvm-rocky8

weizhouapache avatar Apr 09 '24 14:04 weizhouapache

@weizhouapache a [SL] Trillian-Jenkins test job (rocky8 mgmt + kvm-rocky8) has been kicked to run smoke tests

blueorangutan avatar Apr 09 '24 14:04 blueorangutan

[SF] Trillian Build Failed (tid-9765)

blueorangutan avatar Apr 09 '24 14:04 blueorangutan

@blueorangutan test rocky8 kvm-rocky8

weizhouapache avatar Apr 09 '24 17:04 weizhouapache

@weizhouapache a [SL] Trillian-Jenkins test job (rocky8 mgmt + kvm-rocky8) has been kicked to run smoke tests

blueorangutan avatar Apr 09 '24 17:04 blueorangutan

[SF] Trillian test result (tid-9766) Environment: kvm-rocky8 (x2), Advanced Networking with Mgmt server r8 Total time taken: 51815 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8875-t9766-kvm-rocky8.zip Smoke tests completed. 129 look OK, 0 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File

blueorangutan avatar Apr 10 '24 08:04 blueorangutan

@rohityadavcloud Gentle reminder for review.

abh1sar avatar Apr 11 '24 05:04 abh1sar

@abh1sar can you

  • pull or merge the latest 4.19 on your PR branch
  • resolve all review comments you've addressed
  • address any other outstanding remark(s)
  • ask for a re-review from reviewers whose comments you've addressed thnx

rohityadavcloud avatar Apr 19 '24 07:04 rohityadavcloud

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

github-actions[bot] avatar Apr 22 '24 12:04 github-actions[bot]

@shwstppr @weizhouapache @DaanHoogland I have addressed the review comments. Please check.

abh1sar avatar Apr 23 '24 10:04 abh1sar

@blueorangutan package

abh1sar avatar Apr 25 '24 05:04 abh1sar

@abh1sar a [SL] 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 avatar Apr 25 '24 06:04 blueorangutan

Packaging result [SF]: ✖️ el7 ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 9420

blueorangutan avatar Apr 25 '24 06:04 blueorangutan

@shwstppr @weizhouapache I have added some UT to increase coverage. Please check.

abh1sar avatar Apr 29 '24 09:04 abh1sar

@blueorangutan package

abh1sar avatar Apr 30 '24 05:04 abh1sar

@abh1sar a [SL] 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 avatar Apr 30 '24 05:04 blueorangutan

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9474

blueorangutan avatar Apr 30 '24 06:04 blueorangutan

@blueorangutan test rocky8 kvm-rocky8

abh1sar avatar Apr 30 '24 08:04 abh1sar