You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Ignasi Barrera <no...@github.com> on 2017/04/26 19:40:04 UTC

[jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

https://issues.apache.org/jira/browse/JCLOUDS-1274
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds-labs/pull/387

-- Commit Summary --

  * JCLOUDS-1274: Delete managed disks when cleaning up VM resources

-- File Changes --

    M azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CleanupResources.java (40)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/387.patch
https://github.com/jclouds/jclouds-labs/pull/387.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Ignasi Barrera <no...@github.com>.
nacx commented on this pull request.



> +      deleteJobs.add(deleteManagedDisk(osDisk.managedDiskParameters()));
+
+      for (DataDisk dataDisk : virtualMachine.properties().storageProfile().dataDisks()) {
+         deleteJobs.add(deleteManagedDisk(dataDisk.managedDiskParameters()));
+      }
+
+      return all(filter(deleteJobs, notNull()), resourceDeleted);
+   }
+   
+   @Nullable
+   private URI deleteManagedDisk(@Nullable ManagedDiskParameters managedDisk) {
+      if (managedDisk != null) {
+         IdReference diskRef = IdReference.create(managedDisk.id());
+         logger.debug(">> deleting managed disk %s...", diskRef.name());
+         return api.getDiskApi(diskRef.resourceGroup()).delete(diskRef.name());
+      }

Done!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387#discussion_r113793693

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Andrea Turli <no...@github.com>.
andreaturli commented on this pull request.



> +      deleteJobs.add(deleteManagedDisk(osDisk.managedDiskParameters()));
+
+      for (DataDisk dataDisk : virtualMachine.properties().storageProfile().dataDisks()) {
+         deleteJobs.add(deleteManagedDisk(dataDisk.managedDiskParameters()));
+      }
+
+      return all(filter(deleteJobs, notNull()), resourceDeleted);
+   }
+   
+   @Nullable
+   private URI deleteManagedDisk(@Nullable ManagedDiskParameters managedDisk) {
+      if (managedDisk != null) {
+         IdReference diskRef = IdReference.create(managedDisk.id());
+         logger.debug(">> deleting managed disk %s...", diskRef.name());
+         return api.getDiskApi(diskRef.resourceGroup()).delete(diskRef.name());
+      }

maybe we can `log.warn` that the disk didn't get deleted?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387#pullrequestreview-34968139

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Andrea Turli <no...@github.com>.
cool +1

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387#issuecomment-297831883

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Ignasi Barrera <no...@github.com>.
/cc @andreaturli @danielestevez 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387#issuecomment-297519617

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Andrea Turli <no...@github.com>.
minor comment, not tested, but looks good to me

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387#issuecomment-297547130

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Ignasi Barrera <no...@github.com>.
Squashed and pushed to [master](http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/004fbcf8) and [2.0.x](http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/9dc23402). Thanks for the reviews @andreaturli!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387#issuecomment-297836574

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Ignasi Barrera <no...@github.com>.
Closed #387.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387#event-1061154613

Re: [jclouds/jclouds-labs] JCLOUDS-1274: Delete managed disks when cleaning up VM resources (#387)

Posted by Ignasi Barrera <no...@github.com>.
@nacx pushed 1 commit.

23abb62  Log disks that are not deleted when cleaning up a node


-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/387/files/222a048bfd1090e36b0a9de274ef17993b42fed5..23abb622e7d054894a8832878c39348675a1bed7