CLOUDSTACK-8111. NFS secondary storage repetitively mounted on CS server with ESXi hypervisors.

Fix cleanup of NFS mounts on management server during server starup by correcting how mount points are listed for a management server.

(cherry picked from commit 647532376f)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Likitha Shetty 2014-03-20 11:29:57 +05:30 committed by Rohit Yadav
parent d466ecaf7a
commit bf7013f0ea
3 changed files with 19 additions and 2 deletions

View File

@ -142,6 +142,20 @@ public class JavaStorageLayer implements StorageLayer {
return paths;
}
@Override
public List<String> listMountPointsByMsHost(String path, long msHostId) {
List<String> mountPaths = new ArrayList<String>();
File[] files = new File(path).listFiles();
if (files == null) {
return mountPaths;
}
for (File file : files) {
if (file.getName().startsWith(String.valueOf(msHostId) + "."))
mountPaths.add(file.getAbsolutePath());
}
return mountPaths;
}
@Override
public boolean mkdir(String path) {
synchronized (path.intern()) {

View File

@ -21,6 +21,7 @@ package com.cloud.storage;
import java.io.File;
import java.io.IOException;
import java.util.List;
import com.cloud.utils.component.Manager;
@ -149,4 +150,6 @@ public interface StorageLayer extends Manager {
boolean setWorldReadableAndWriteable(File file);
boolean deleteDir(String dir);
List<String> listMountPointsByMsHost(String path, long msHostId);
}

View File

@ -696,8 +696,8 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
long mshostId = ManagementServerNode.getManagementServerId();
// cleanup left-over NFS mounts from previous session
String[] mounts = _storage.listFiles(parent + File.separator + String.valueOf(mshostId) + ".*");
if (mounts != null && mounts.length > 0) {
List<String> mounts = _storage.listMountPointsByMsHost(parent, mshostId);
if (mounts != null && !mounts.isEmpty()) {
for (String mountPoint : mounts) {
s_logger.info("umount NFS mount from previous session: " + mountPoint);