Clear pool id if volume allocation fails#8202
Conversation
…located with a pool id assigned
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## 4.18 #8202 +/- ##
============================================
+ Coverage 13.10% 13.12% +0.01%
- Complexity 9122 9135 +13
============================================
Files 2720 2720
Lines 257638 257645 +7
Branches 40168 40171 +3
============================================
+ Hits 33753 33805 +52
+ Misses 219619 219548 -71
- Partials 4266 4292 +26 ☔ View full report in Codecov by Sentry. |
|
@blueorangutan package |
|
@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. |
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7690 |
|
@blueorangutan test |
|
@harikrishna-patnala a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
harikrishna-patnala
left a comment
There was a problem hiding this comment.
LGTM, Tested both root and data disks, VM started fine.
There was a problem hiding this comment.
clgtm, one worry though; @anniejili Do we need to check if the volume is actually present on the pool? I.E. if the volume has been allocated before it might actually exist (even though it has the state of Allocated)
@DaanHoogland according to the volume state machine, volume will be in allocated state either as the starting state or when the operation is failed. So I dont think volume will actually present. I feel this code check is good enough. |
|
There was a problem hiding this comment.
CLGTM, simpel principle.
However I accept @harikrishna-patnala 's argument, it won't hurt to try if they can break it, as per the discussion here: #8202 (comment)
| if (toBeCreated.getState() == Volume.State.Allocated && toBeCreated.getPoolId() != null) { | ||
| toBeCreated.setPoolId(null); | ||
| if (!_volsDao.update(toBeCreated.getId(), toBeCreated)) { | ||
| throw new CloudRuntimeException(String.format("Error updating volume [%s] to clear pool Id.", toBeCreated.getId())); | ||
| } | ||
| if (s_logger.isDebugEnabled()) { | ||
| String msg = String.format("Setting pool_id to NULL for volume id=%s as it is in Allocated state", toBeCreated.getId()); | ||
| s_logger.debug(msg); | ||
| } | ||
| } |
There was a problem hiding this comment.
this can be moved to a separate method and tested (separately)
|
@blueorangutan package |
|
@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. |
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7755 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
…me_allocation_fails
|
Rebased with the latest 4.18 branch. |
|
[SF] Trillian test result (tid-8352)
|
|
@blueorangutan package |
|
@DaanHoogland 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. |
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7794 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-8373)
|
|
Awesome work, congrats on your first merged pull request! |
|
Thanks everyone! |
Description
When there is outage in storage API coincides with a VM start, the volume could be stuck in "Allocated" state but with a pool Id assigned in DB. It blocked the ability to start the VM during planDeployment process, in the method storagePoolCompatibleWithVolumePool() shown below when validating a volume with a storage pool, if the volume's pool Id is not null and state is Allocated, it would always return false for any storage pools. As a result, the allocator cannot find a suitable pool and it blocks the VM start process.
This PR fixed the issue above by validating volumes's state and pool id before the deployment in DeploymentPlanningManagerImpl.java's findSuitablePoolsForVolumes() method. Before DeploymentPlanningManager is trying to find suitable storage pools for volumes, if any volume is in Allocated state with a pool ID, the pool id will be cleared.
Testing
For a stopped VM, manually updated its root volume state to "Allocated" with a pool ID. Then restart the VM.
Before the change
2023-08-22 23:40:00,948 INFO [o.a.c.a.c.u.v.StartVMCmd] (API-Job-Executor-70:ctx-xxxx job-xxxx ctx-xxxx) (logid:xxxx) No destination found for a deployment for VM instance {id: "xxxx", name: "xxxx, uuid: "xxxx", type="User"}
After the change
The VM is started successfully.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
The change is tested via added junit test cases. The change is also tested and verified in Cloud Stack development environment.