Updated Branches:
  refs/heads/object_store f7c1b711a -> 84607c1e5

Fix CLOUDSTACK-2537: Use mount.parent configured value to mount NFS
cache on MS to avoid permission issue.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/84607c1e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/84607c1e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/84607c1e

Branch: refs/heads/object_store
Commit: 84607c1e53450c6f5a41ed16fba9e006fb3edf6b
Parents: f7c1b71
Author: Min Chen <min.c...@citrix.com>
Authored: Fri May 17 17:49:40 2013 -0700
Committer: Min Chen <min.c...@citrix.com>
Committed: Fri May 17 17:49:58 2013 -0700

----------------------------------------------------------------------
 .../resource/LocalNfsSecondaryStorageResource.java |   14 +++++++++++++-
 .../resource/NfsSecondaryStorageResource.java      |    6 ++++--
 2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84607c1e/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git 
a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
 
b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
index 7322a81..02ff8bc 100644
--- 
a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
+++ 
b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
@@ -44,6 +44,8 @@ import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.NfsTO;
 import com.cloud.agent.api.to.S3TO;
 import com.cloud.agent.api.to.SwiftTO;
+import com.cloud.configuration.Config;
+import com.cloud.configuration.dao.ConfigurationDaoImpl;
 import com.cloud.storage.JavaStorageLayer;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 
@@ -57,13 +59,20 @@ import com.cloud.utils.script.Script;
 @Component
 public class LocalNfsSecondaryStorageResource extends 
NfsSecondaryStorageResource {
 
-    private static final Logger s_logger = 
Logger.getLogger(NfsSecondaryStorageResource.class);
+    private static final Logger s_logger = 
Logger.getLogger(LocalNfsSecondaryStorageResource.class);
 
     public LocalNfsSecondaryStorageResource() {
         this._dlMgr = new DownloadManagerImpl();
         ((DownloadManagerImpl) 
_dlMgr).setThreadPool(Executors.newFixedThreadPool(10));
         _storage = new JavaStorageLayer();
         this._inSystemVM = false;
+        // get mount parent folder configured in global setting, if set, this 
will overwrite _parent in NfsSecondaryStorageResource to work
+        // around permission issue for default /mnt folder
+        ConfigurationDaoImpl configDao = new ConfigurationDaoImpl();
+        String mountParent = configDao.getValue(Config.MountParent.key());
+        if (mountParent != null) {
+            _parent = mountParent + File.separator + "secStorage";
+        }
     }
 
     @Override
@@ -171,6 +180,7 @@ public class LocalNfsSecondaryStorageResource extends 
NfsSecondaryStorageResourc
         res.addAll(parser.getPaths());
         for (String s : res) {
             if (s.contains(root)) {
+                s_logger.debug("mount point " + root + " already exists");
                 return root;
             }
         }
@@ -194,6 +204,7 @@ public class LocalNfsSecondaryStorageResource extends 
NfsSecondaryStorageResourc
                 file.delete();
             return null;
         }
+        s_logger.debug("Successfully mount " + nfsPath);
 
         // Change permissions for the mountpoint
         script = new Script(true, "chmod", _timeout, s_logger);
@@ -203,6 +214,7 @@ public class LocalNfsSecondaryStorageResource extends 
NfsSecondaryStorageResourc
             s_logger.warn("Unable to set permissions for " + root + " due to " 
+ result);
             return null;
         }
+        s_logger.debug("Successfully set 777 permission for " + root);
 
         // XXX: Adding the check for creation of snapshots dir here. Might have
         // to move it somewhere more logical later.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84607c1e/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
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 1125d7f..24b2e0b 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
@@ -236,11 +236,13 @@ public class NfsSecondaryStorageResource extends 
ServerResourceBase implements S
             downloadDirectory.mkdirs();
 
             if (!downloadDirectory.exists()) {
-                final String errMsg = format("Unable to create directory " + 
"download directory %1$s for download from S3.",
-                        downloadDirectory.getName());
+                final String errMsg = "Unable to create directory " + 
downloadPath + " to copy from S3 to cache.";
                 s_logger.error(errMsg);
                 return new CopyCmdAnswer(errMsg);
             }
+            else{
+                s_logger.debug("Directory " + downloadPath + " already 
exists");
+            }
 
             List<File> files = getDirectory(s3, s3.getBucketName(), destPath, 
downloadDirectory, new FileNamingStrategy() {
                 @Override

Reply via email to