From 7fa57922a40428d73e80f5f2a48ff67c8cecd148 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Wed, 24 Apr 2013 15:20:25 -0600 Subject: [PATCH] Detail: Delete KVMHA dir contents if found when deleting templates, volumes from Nfs Secondary storage BUG-ID: CLOUDSTACK-2173 Bugfix-for: 4.2 Signed-off-by: Marcus Sorensen 1366838425 -0600 --- .../resource/NfsSecondaryStorageResource.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 1176d762f95..638d5cad99d 100755 --- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -1291,6 +1291,17 @@ SecondaryStorageResource { if (!found && f.getName().equals("template.properties")) { found = true; } + + // KVM HA monitor makes a mess in the templates with its heartbeat tests + // Don't let this stop us from cleaning up the template + if (f.isDirectory() && f.getName().equals("KVMHA")) { + s_logger.debug("Deleting KVMHA directory contents from template location"); + File[] haFiles = f.listFiles(); + for (File haFile : haFiles) { + haFile.delete(); + } + } + if (!f.delete()) { return new Answer(cmd, false, "Unable to delete file " + f.getName() + " under Template path " + relativeTemplatePath); @@ -1339,6 +1350,17 @@ SecondaryStorageResource { if (!found && f.getName().equals("volume.properties")) { found = true; } + + // KVM HA monitor makes a mess in the templates with its heartbeat tests + // Don't let this stop us from cleaning up the template + if (f.isDirectory() && f.getName().equals("KVMHA")) { + s_logger.debug("Deleting KVMHA directory contents from template location"); + File[] haFiles = f.listFiles(); + for (File haFile : haFiles) { + haFile.delete(); + } + } + if (!f.delete()) { return new Answer(cmd, false, "Unable to delete file " + f.getName() + " under Volume path " + relativeVolumePath);