Skip to content

Commit bf7013f

Browse files
Likitha Shettyyadvr
authored andcommitted
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 6475323) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent d466eca commit bf7013f

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎core/src/com/cloud/storage/JavaStorageLayer.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ public String[] listFiles(String path) {
142142
return paths;
143143
}
144144

145+
@Override
146+
public List<String> listMountPointsByMsHost(String path, long msHostId) {
147+
List<String> mountPaths = new ArrayList<String>();
148+
File[] files = new File(path).listFiles();
149+
if (files == null) {
150+
return mountPaths;
151+
}
152+
for (File file : files) {
153+
if (file.getName().startsWith(String.valueOf(msHostId) + "."))
154+
mountPaths.add(file.getAbsolutePath());
155+
}
156+
return mountPaths;
157+
}
158+
145159
@Override
146160
public boolean mkdir(String path) {
147161
synchronized (path.intern()) {

‎core/src/com/cloud/storage/StorageLayer.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.io.File;
2323
import java.io.IOException;
24+
import java.util.List;
2425

2526
import com.cloud.utils.component.Manager;
2627

@@ -149,4 +150,6 @@ public interface StorageLayer extends Manager {
149150
boolean setWorldReadableAndWriteable(File file);
150151

151152
boolean deleteDir(String dir);
153+
154+
List<String> listMountPointsByMsHost(String path, long msHostId);
152155
}

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,8 @@ private void startupCleanup(String parent) {
696696
long mshostId = ManagementServerNode.getManagementServerId();
697697

698698
// cleanup left-over NFS mounts from previous session
699-
String[] mounts = _storage.listFiles(parent + File.separator + String.valueOf(mshostId) + ".*");
700-
if (mounts != null && mounts.length > 0) {
699+
List<String> mounts = _storage.listMountPointsByMsHost(parent, mshostId);
700+
if (mounts != null && !mounts.isEmpty()) {
701701
for (String mountPoint : mounts) {
702702
s_logger.info("umount NFS mount from previous session: " + mountPoint);
703703

0 commit comments

Comments
 (0)