Hello Bala.FA, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/41209

to review the following change.

Change subject: gluster: New verb to mount & update fstab for meta-volume
......................................................................

gluster: New verb to mount & update fstab for meta-volume

This patch adds a new verb 'MetaVolumeMount' to
update fstab entry for meta-volume and mount it. This
meta-volume is needed by various glusterfs features
like snapshot-schedule, geo-replication etc. It is
expected to be mounted on all gluster nodes. It takes
an optional argument metaVolumeName.

Change-Id: If2d109a5de9374f21b1b94f73187b653c121a8b4
Signed-off-by: Darshan N <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/40497
Continuous-Integration: Jenkins CI
Reviewed-by: Bala.FA <[email protected]>
Reviewed-by: Dan Kenigsberg <[email protected]>
---
M client/vdsClientGluster.py
M vdsm/gluster/api.py
M vdsm/gluster/apiwrapper.py
M vdsm/gluster/exception.py
M vdsm/rpc/vdsmapi-gluster-schema.json
5 files changed, 98 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/41209/1

diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 4f53eb4..cf6eff6 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -758,6 +758,15 @@
         pp.pprint(status)
         return status['status']['code'], status['status']['message']
 
+    def do_glusterMetaVolumeMount(self, args):
+        params = self._eqSplit(args)
+        metaVolumeName = params.get('metaVolumeName', '')
+
+        status = self.s.glusterMetaVolumeMount(metaVolumeName)
+
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
 
 def getGlusterCmdDict(serv):
     return \
@@ -1288,5 +1297,10 @@
              serv.do_glusterVolumeEmptyCheck,
              ('volumeName=<volume name>',
               'Check if the given volume is empty or not'
+              )),
+         'glusterMetaVolumeMount': (
+             serv.do_glusterMetaVolumeMount,
+             ('[volumeName=<volume name>]',
+              'mount the meta-volume'
               ))
          }
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 8974e8e..6539c19 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -22,16 +22,23 @@
 import os
 from functools import wraps
 from vdsm.define import doneCode
+from vdsm import constants, utils
 from pwd import getpwnam
+from storage import mount
 
 import supervdsm as svdsm
 import exception as ge
 from . import makePublic
 from . import safeWrite
+import fstab
+import logging
 
 _SUCCESS = {'status': doneCode}
 GEOREP_PUB_KEY_PATH = "/var/lib/glusterd/geo-replication/common_secret.pem.pub"
 MOUNT_BROKER_ROOT = "/var/mountbroker-root"
+META_VOLUME = "gluster_shared_storage"
+META_VOL_MOUNT_POINT = "/var/run/gluster/shared_storage"
+FS_TYPE = "glusterfs"
 
 
 GLUSTER_RPM_PACKAGES = (
@@ -140,6 +147,53 @@
         except OSError as e:
             raise ge.GlusterMountBrokerRootCreateFailedException(err=[str(e)])
     return
+
+
+@makePublic
+def mountMetaVolume(metaVolumeName):
+    def _metaVolumeFstabUpdate(metaVolumeName):
+        try:
+            fs_spec = "127.0.0.1:" + metaVolumeName
+            fstab.FsTab().add(fs_spec, META_VOL_MOUNT_POINT, FS_TYPE,
+                              mntOpts=['defaults', '_netdev'])
+        except IOError as e:
+            raise ge.GlusterMetaVolumeFstabUpdateFailedException(
+                err=["fstab update failed", str(e)])
+        except ge.GlusterHostStorageDeviceFsTabFoundException as e:
+            logging.warn(e.message)
+
+    _metaVolumeFstabUpdate(metaVolumeName)
+
+    if os.path.ismount(META_VOL_MOUNT_POINT):
+        try:
+            fs_spec = mount.getMountFromTarget(
+                os.path.realpath(META_VOL_MOUNT_POINT)).fs_spec
+            if fs_spec.endswith(META_VOLUME):
+                logging.warn("Meta Volume %s already mounted at %s" % (
+                    META_VOLUME, META_VOL_MOUNT_POINT))
+                return True
+            else:
+                raise ge.GlusterMetaVolumeMountFailedException(
+                    err=["%s already mounted at %s" % (
+                        fs_spec, META_VOL_MOUNT_POINT)])
+        except OSError as e:
+            raise ge.GlusterMetaVolumeMountFailedException(
+                err=["Failed to check if volume is already mounted",
+                     str(e)])
+    else:
+        try:
+            os.makedirs(META_VOL_MOUNT_POINT, 0o755)
+        except OSError as e:
+            if e.errno != errno.EEXIST:
+                raise ge.GlusterMetaVolumeMountFailedException(
+                    err=['Mount Point creation failed', str(e)])
+
+    command = [constants.EXT_MOUNT, META_VOL_MOUNT_POINT]
+    rc, out, err = utils.execCmd(command)
+    if rc:
+        raise ge.GlusterMetaVolumeMountFailedException(
+            rc, out, err)
+    return True
 
 
 class GlusterApi(object):
@@ -644,6 +698,10 @@
         status = self.svdsmProxy.glusterVolumeEmptyCheck(volumeName)
         return {'volumeEmptyCheck': status}
 
+    @exportAsVerb
+    def metaVolumeMount(self, metaVolumeName=META_VOLUME, options=None):
+        self.svdsmProxy.glusterMountMetaVolume(metaVolumeName)
+
 
 def getGlusterMethods(gluster):
     l = []
diff --git a/vdsm/gluster/apiwrapper.py b/vdsm/gluster/apiwrapper.py
index 6d70a85..c7b193e 100644
--- a/vdsm/gluster/apiwrapper.py
+++ b/vdsm/gluster/apiwrapper.py
@@ -18,7 +18,7 @@
 # Refer to the README and COPYING files for full details of the license
 #
 from clientIF import clientIF
-from gluster.api import GlusterApi
+from gluster.api import GlusterApi, META_VOLUME
 
 
 class GlusterApiBase(object):
@@ -309,6 +309,9 @@
     def volumeEmptyCheck(self, volumeName):
         return self._gluster.volumeEmptyCheck(volumeName)
 
+    def metaVolumeMount(self, metaVolumeName=META_VOLUME):
+        return self._gluster.metaVolumeMount(metaVolumeName)
+
 
 class GlusterSnapshot(GlusterApiBase):
     def __init__(self):
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index 8d3ec7a..2fa1e88 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -591,6 +591,16 @@
     message = "Failed to Check if gluster volume is empty"
 
 
+class GlusterMetaVolumeMountFailedException(GlusterVolumeException):
+    code = 4575
+    message = "Failed to mount meta volume"
+
+
+class GlusterMetaVolumeFstabUpdateFailedException(GlusterVolumeException):
+    code = 4576
+    message = "Failed to Update fstab entry for meta-volume"
+
+
 # geo-replication
 class GlusterGeoRepException(GlusterException):
     code = 4200
diff --git a/vdsm/rpc/vdsmapi-gluster-schema.json 
b/vdsm/rpc/vdsmapi-gluster-schema.json
index 8b4043f..a471923 100644
--- a/vdsm/rpc/vdsmapi-gluster-schema.json
+++ b/vdsm/rpc/vdsmapi-gluster-schema.json
@@ -2150,3 +2150,15 @@
 {'command': {'class': 'GlusterVolume', 'name': 'volumeEmptyCheck'},
  'data': {'volumeName': 'str'},
  'returns': 'VolumeEmptyCheck'}
+
+##
+# @GlusterVolume.metaVolumeMount:
+#
+# Mount glusterfs meta volume
+#
+# @metaVolumeName: #optional Gluster meta volume name
+#
+# Since: 4.17.0
+##
+{'command': {'class': 'GlusterVolume', 'name': 'metaVolumeMount'},
+ 'data': {'*metaVolumeName': 'str'}}


-- 
To view, visit https://gerrit.ovirt.org/41209
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2d109a5de9374f21b1b94f73187b653c121a8b4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5-gluster
Gerrit-Owner: Darshan N <[email protected]>
Gerrit-Reviewer: Bala.FA <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to