Allow VM that has never started to have volumes attached#3276
Conversation
for the use case where users want to attach disk in allocated state but not ready, we need to have more states for keeping track of attaching state. Test this by creating a VM with "startvm=false", create a disk and try attaching it in allocated state. It would give an exception on latest 4.11 but will be fixed on this patch.
|
@blueorangutan package |
|
@anuragaw a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2701 |
|
@blueorangutan test |
|
@anuragaw a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3496)
|
|
@anuragaw can you implement a marvin test for the test-case. |
|
@blueorangutan package |
|
@anuragaw a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2704 |
|
@blueorangutan test |
Done @rhtyd , let me know if this covers the case . Thanks! |
| UploadError("Volume upload encountered some error"), | ||
| UploadAbandoned("Volume upload is abandoned since the upload was never initiated within a specificed time"), | ||
| Attaching("The volume is attaching to a VM"); | ||
| AttachingFromReady("The volume is attaching to a VM from Ready State"), |
There was a problem hiding this comment.
@anuragaw don't change the original state Attaching to honour db volume states that may already be in Attaching state in db. This may cause usage issues post an upgrade.
There was a problem hiding this comment.
Ah, my bad. Fixing.
| handleTargetsForVMware(hostId, volumePool.getHostAddress(), volumePool.getPort(), volume.get_iScsiName()); | ||
| // volumePool() should be null if the VM we are detaching the disk from has never been started before | ||
| // only revoke access on volumes that are actually on a datastore | ||
| if (volumePool != null) { |
There was a problem hiding this comment.
Should the original logic be retained? What happens if volumePool is null?
There was a problem hiding this comment.
If the volumePool was null initially the dataStore was null in previous implementation and revokeAccess did nothing. That happens after this check as well.
Also I don't think it should be null as the handleTargetsForVMWare(hostId,volumePool.getHostAddress()... would crash.
| UploadAbandoned("Volume upload is abandoned since the upload was never initiated within a specificed time"), | ||
| Attaching("The volume is attaching to a VM"); | ||
| AttachingFromReady("The volume is attaching to a VM from Ready State"), | ||
| AttachingFromAllocated("The volume is attaching to a VM from Allocated State"); |
There was a problem hiding this comment.
I think we can still fix the issue without introducing a new state. All we're saying is to allow volumes's attaching state whether their previous state is Ready or Allocated.
There was a problem hiding this comment.
The reason we need a new state is that if an attach fails we want the disk to return to the original state it was in - Ready -> Attaching -> FAIL -> Ready, or Allocated -> Attaching -> FAIL -> Allocated.
Perhaps I am misunderstanding something?
There was a problem hiding this comment.
Looking back at the original patch that caused regression, it seems that simple Allocated->Attaching would suffice. I'll change.
| s_fsm.addTransition(new StateMachine2.Transition<State, Event>(Ready, Event.AttachRequested, Attaching, null)); | ||
| s_fsm.addTransition(new StateMachine2.Transition<State, Event>(Attaching, Event.OperationSucceeded, Ready, null)); | ||
| s_fsm.addTransition(new StateMachine2.Transition<State, Event>(Attaching, Event.OperationFailed, Ready, null)); | ||
| s_fsm.addTransition(new StateMachine2.Transition<State, Event>(Allocated, Event.AttachRequested, AttachingFromAllocated, null)); |
There was a problem hiding this comment.
Let's keep this only and rest can follow the same, i.e. allow both Ready and Allocated state volumes to go into Attaching state on the event.
| self.assertEqual(root_volume.podname, list_pods.name) | ||
|
|
||
| @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true") | ||
| def test_11_attach_volume_with_unstarted_vm(self): |
There was a problem hiding this comment.
Test case LGTM. Also check Travis if this passes OK.
…g pool id in attaching state
|
@blueorangutan package |
|
@blueorangutan package |
|
@anuragaw a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2711 |
|
@blueorangutan test |
|
@anuragaw a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
@blueorangutan package |
|
@anuragaw a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2712 |
|
Trillian test result (tid-3504)
|
|
Trillian test result (tid-3506)
|
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2715 |
|
@blueorangutan test matrix |
|
@rhtyd a Trillian-Jenkins matrix job (centos6 mgmt + xs71, centos7 mgmt + vmware65, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3525)
|
|
Trillian test result (tid-3524)
|
With this patch b766bf7
we started tracking disks in attaching state so that other attach request can fail gracefully. However this missed the case where disks were in allocated state but attach was requested.
For the use case where users want to attach disk in allocated state but not ready, we need to have allocated-attaching transition as well. We must take care of returning to the original state - allocated or ready - when attach request has completed.
For the use case of unstarted vm's the disk must proceed as follows - "Allocated" -> Attaching -> Allocated. When VM is started, the disk is "created" and pool is assigned. For the use case of started VMs it's more trivial and disk proceeds as follows - Ready -> Attaching -> Ready.
Test this by creating a VM with "startvm=false", create a disk and try attaching it in allocated state. It would give an exception on latest 4.11 but will be fixed on this patch.
Description
Types of changes
Screenshots (if appropriate):
How Has This Been Tested?
Manually (using CloudMonkey, dashboard) and through Marvin Test