-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Restrict the migration of volumes attached to VMs in Starting state #9725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restrict the migration of volumes attached to VMs in Starting state #9725
Conversation
…lume that is attached to a vm in starting mode from being migrated
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.19 #9725 +/- ##
============================================
+ Coverage 15.11% 15.85% +0.73%
- Complexity 11184 11269 +85
============================================
Files 5402 5042 -360
Lines 473120 444385 -28735
Branches 58327 52630 -5697
============================================
- Hits 71507 70441 -1066
+ Misses 393812 366072 -27740
- Partials 7801 7872 +71
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
JoaoJandre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLGTM
|
Is there any other state that we should be checking besides starting? migrating, for example? |
Good point, though this is already an improvement; I think (at least) |
bernardodemarco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I manually tested the PR in a local environment.
I verified that CloudStack doesn't allow the operator to migrate a volume when the virtual machine related to it is starting.
root@cloudstack:~# grep 'logid:d36d1bbc' /var/log/cloudstack/management/management-server.log
2025-01-03 12:36:08,677 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl$5] (API-Job-Executor-11:[ctx-8017eead, job-200]) (logid:d36d1bbc) Executing AsyncJobVO: {id:200, userId: 2, accountId: 2, instanceType: Volume, instanceId: 27, cmd: org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin, cmdInfo: {"response":"json","ctxUserId":"2","sessionkey":"7FhCQRxwVcXt_poXEs3mLf8akmA","volumeid":"30b7f14e-1f8f-4e9c-b364-a9887bc254f4","httpmethod":"GET","ctxStartEventId":"398","ctxDetails":"{\"interface com.cloud.storage.StoragePool\":\"10d28cdf-71a7-33ad-802e-f4ec9042e4fd\",\"interface com.cloud.storage.Volume\":\"30b7f14e-1f8f-4e9c-b364-a9887bc254f4\"}","ctxAccountId":"2","livemigrate":"true","cmdEventType":"VOLUME.MIGRATE","storageid":"10d28cdf-71a7-33ad-802e-f4ec9042e4fd"}, cmdVersion: 0, status: IN_PROGRESS, processStatus: 0, resultCode: 0, result: null, initMsid: 227341783673585, completeMsid: null, lastUpdated: null, lastPolled: null, created: null, removed: null}
2025-01-03 12:36:34,413 DEBUG [c.c.s.VolumeApiServiceImpl] (API-Job-Executor-11:[ctx-8017eead, job-200, ctx-ccb65616]) (logid:d36d1bbc) Unable to migrate volume: [ROOT-24] Id: [27] because the VM: [i-2-24-VM] Id: [6375962a-980e-429e-ba7a-8f164a74b597] has not started yet.
2025-01-03 12:36:37,885 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-11:[ctx-8017eead, job-200]) (logid:d36d1bbc) Unexpected exception while executing org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin com.cloud.utils.exception.CloudRuntimeException: Volume migration is not allowed while the VM is starting.
2025-01-03 12:36:37,888 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-11:[ctx-8017eead, job-200]) (logid:d36d1bbc) Complete async job-200, jobStatus: FAILED, resultCode: 530, result: org.apache.cloudstack.api.response.ExceptionResponse/null/{"uuidList":[],"errorcode":"530","errortext":"Volume migration is not allowed while the VM is starting."}
|
thanks @bernardodemarco @JoaoJandre , do you agree that this PR is good to go, even when more improvements are possible? |
|
@DaanHoogland considering it's an easy change, I don't see why introduce this and change it later. |
Yes, no problem. I'll update the verification to only allow the migration to be performed when the VM is |
@DaanHoogland, @rohityadavcloud, @JoaoJandre I've just applied the changes. root@cloudstack:~# grep -a 'logid:bf08211b' /var/log/cloudstack/management/management-server.log
2025-01-06 12:13:48,480 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-7:ctx-8253b178 job-141) (logid:bf08211b) Executing AsyncJobVO: {id:141, userId: 2, accountId: 2, instanceType: Volume, instanceId: 21, cmd: org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin, cmdInfo: {"response":"json","ctxUserId":"2","sessionkey":"07_Zt7hC_aogIMgiM2EDW7Hs0xk","volumeid":"8dfa4a5e-2e0f-4c57-ad1e-2a19b6a3c6b9","httpmethod":"GET","ctxStartEventId":"273","ctxDetails":"{\"interface com.cloud.storage.Volume\":\"8dfa4a5e-2e0f-4c57-ad1e-2a19b6a3c6b9\",\"interface com.cloud.storage.StoragePool\":\"a0566c34-a49d-31bc-865f-3b57806131d6\"}","ctxAccountId":"2","livemigrate":"false","cmdEventType":"VOLUME.MIGRATE","storageid":"a0566c34-a49d-31bc-865f-3b57806131d6"}, cmdVersion: 0, status: IN_PROGRESS, processStatus: 0, resultCode: 0, result: null, initMsid: 227341783673585, completeMsid: null, lastUpdated: null, lastPolled: null, created: null, removed: null}
2025-01-06 12:13:48,488 DEBUG [c.c.s.VolumeApiServiceImpl] (API-Job-Executor-7:ctx-8253b178 job-141 ctx-fe58e892) (logid:bf08211b) Unable to migrate volume: [ROOT-19] Id: [21] because the VM: [i-2-19-VM] Id: [9228084c-7e2f-4e08-b40d-99a96c2ec23a] is in state [Stopping], which is not supported for migration.
2025-01-06 12:13:48,493 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-7:ctx-8253b178 job-141) (logid:bf08211b) Unexpected exception while executing org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin
2025-01-06 12:13:48,496 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-7:ctx-8253b178 job-141) (logid:bf08211b) Complete async job-141, jobStatus: FAILED, resultCode: 530, result: org.apache.cloudstack.api.response.ExceptionResponse/null/{"uuidList":[],"errorcode":"530","errortext":"Volume migration is not allowed when the VM is in the Stopping state. Supported states are: [Stopped, Running, Shutdown]."} |
|
@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]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12002 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-12056)
|
* 4.19: Restrict the migration of volumes attached to VMs in Starting state (#9725)
…pache#9725) Co-authored-by: Bernardo De Marco Gonçalves <[email protected]>


Description
This PR restricts users from migrating volumes attached to VMs that are in starting state. Migrating volumes while their VMs are starting shouldn't be allowed because sometimes the VM could end up not actually starting, and if ACS starts migrating its volume, this could lead to other issues.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
Image
How Has This Been Tested?
I tested this PR by deploying an instance and then trying to migrate its volume while the instance was starting. Before the changes, the volume migration process would start. After the migration, an error is thrown, as expected.