Return-Path: X-Original-To: apmail-cloudstack-issues-archive@www.apache.org Delivered-To: apmail-cloudstack-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B54271982F for ; Thu, 21 Apr 2016 14:02:26 +0000 (UTC) Received: (qmail 56076 invoked by uid 500); 21 Apr 2016 14:02:26 -0000 Delivered-To: apmail-cloudstack-issues-archive@cloudstack.apache.org Received: (qmail 55962 invoked by uid 500); 21 Apr 2016 14:02:26 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 55693 invoked by uid 500); 21 Apr 2016 14:02:26 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 55690 invoked by uid 99); 21 Apr 2016 14:02:26 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Apr 2016 14:02:26 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id C77B52C1F6B for ; Thu, 21 Apr 2016 14:02:25 +0000 (UTC) Date: Thu, 21 Apr 2016 14:02:25 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-9349) Unable to detach root volume when using Hypervisor Type KVM MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CLOUDSTACK-9349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15251937#comment-15251937 ] ASF GitHub Bot commented on CLOUDSTACK-9349: -------------------------------------------- Github user dmabry commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1500#discussion_r60585058 --- Diff: test/integration/component/test_volumes.py --- @@ -603,7 +603,144 @@ def test_01_volume_attach_detach(self): "Check the state of VM" ) except Exception as e: - self.fail("Exception occuered: %s" % e) + self.fail("Exception occurred: %s" % e) + return + + @attr(tags=["advanced", "advancedns"], required_hardware="false") + def test_02_root_volume_attach_detach(self): + """Test Root Volume attach/detach to VM + """ + + # Validate the following + # 1. Deploy a VM + # 2. Verify that we are testing a supported hypervisor + # 3. Check for root volume + # 4. Stop VM + # 5. Detach root volume + # 6. Verify root volume detached + # 7. Attach root volume + # 8. Start VM + + # Verify we are using a supported hypervisor + if (self.hypervisor.lower() == 'vmware' + or self.hypervisor.lower() == 'kvm' + or self.hypervisor.lower() == 'simulator' + or self.hypervisor.lower() == 'xenserver'): + + try: + # Check for root volume + root_volume_response = Volume.list( + self.apiclient, + virtualmachineid=self.virtual_machine.id, + type='ROOT', + listall=True + ) + self.assertNotEqual( + root_volume_response, + None, + "Check if root volume exists in ListVolumes" + ) + self.assertEqual( + isinstance(root_volume_response, list), + True, + "Check list volumes response for valid list" + ) + # Grab the root volume for later use + root_volume = root_volume_response[0] + + # Stop VM + self.debug("Stopping the VM: %s" % self.virtual_machine.id) + self.virtual_machine.stop(self.apiclient) + + # Ensure VM is stopped before detaching the root volume + time.sleep(self.services["sleep"]) + + vm_response = VirtualMachine.list( + self.apiclient, + id=self.virtual_machine.id, + ) + vm = vm_response[0] + self.assertEqual( + vm.state, + 'Stopped', + "Check the state of VM" + ) + + # Detach root volume from VM + self.virtual_machine.detach_volume( + self.apiclient, + root_volume + ) + + # Verify that root disk is gone + no_root_volume_response = Volume.list( + self.apiclient, + virtualmachineid=self.virtual_machine.id, + type='ROOT', + listall=True + ) + self.assertEqual( + no_root_volume_response, + None, + "Check if root volume exists in ListVolumes" + ) + + # Attach root volume to VM + self.virtual_machine.attach_volume( + self.apiclient, + root_volume, + 0 + ) + + # Check for root volume + new_root_volume_response = Volume.list( + self.apiclient, + virtualmachineid=self.virtual_machine.id, + type='ROOT', + listall=True + ) + self.assertNotEqual( + new_root_volume_response, + None, + "Check if root volume exists in ListVolumes" + ) + self.assertEqual( + isinstance(new_root_volume_response, list), + True, + "Check list volumes response for valid list" + ) + + # Start VM + self.virtual_machine.start(self.apiclient) + # Sleep to ensure that VM is in ready state + time.sleep(self.services["sleep"]) --- End diff -- @jburwell - Thanks for the feedback. I will make the suggested changes as it make complete sense to wait_until instead of waiting for an arbitrary amount of time that may be too long or not long enough. > Unable to detach root volume when using Hypervisor Type KVM > ----------------------------------------------------------- > > Key: CLOUDSTACK-9349 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9349 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the default.) > Components: Volumes > Affects Versions: 4.5.1, 4.6.2, 4.7.1, 4.8.0, 4.9.0 > Environment: Centos 7 > Reporter: Simon Weller > Priority: Minor > Fix For: 4.7.2 > > > Back in 4.5, support was added in CLOUDSTACK-6284 for detaching root volumes. The original support was meant to work with Xen, VMware and KVM. > After chatting with fuflo in the Cloudstack irc channel, it was pointed out that a constraint was not correctly modified in VolumeApiServiceImpl.java to allow the detach to occur when vm.getHypervisorType() == HypervisorType.KVM. > This is a very useful feature, as it allows us to simulate a snapshot revert with Ceph by using createVolume sourced from a snapshot, then detaching and reattaching the root volume (new root volume needs to be attached as device=0). > I'm going to propose a PR for this shortly -- This message was sent by Atlassian JIRA (v6.3.4#6332)