Commit ff36cacf authored by Dimitris Bliablias's avatar Dimitris Bliablias Committed by Klaus Aehlig

Add missing Gluster storage verification checks

This patch, extends the file-based storage type verification checks to
include the new Gluster storage type. Those modifications include a
missing check for the gluster storage directory at cluster
initialization time, and extends the 'gnt-cluster verify' command to
also verify the gluster file-storage path.
Signed-off-by: default avatarDimitris Bliablias <bl.dimitris@gmail.com>
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>

Cherry-picked from 604c8be2Signed-off-by: default avatarLisa Velden <velden@google.com>
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent f0517981
...@@ -403,7 +403,7 @@ def _InitFileStorageDir(file_storage_dir): ...@@ -403,7 +403,7 @@ def _InitFileStorageDir(file_storage_dir):
def _PrepareFileBasedStorage( def _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir, enabled_disk_templates, file_storage_dir,
default_dir, file_disk_template, default_dir, file_disk_template, _storage_path_acceptance_fn,
init_fn=_InitFileStorageDir, acceptance_fn=None): init_fn=_InitFileStorageDir, acceptance_fn=None):
"""Checks if a file-base storage type is enabled and inits the dir. """Checks if a file-base storage type is enabled and inits the dir.
...@@ -415,14 +415,19 @@ def _PrepareFileBasedStorage( ...@@ -415,14 +415,19 @@ def _PrepareFileBasedStorage(
@param default_dir: default file storage directory when C{file_storage_dir} @param default_dir: default file storage directory when C{file_storage_dir}
is 'None' is 'None'
@type file_disk_template: string @type file_disk_template: string
@param file_disk_template: a disk template whose storage type is 'ST_FILE' or @param file_disk_template: a disk template whose storage type is 'ST_FILE',
'ST_SHARED_FILE' 'ST_SHARED_FILE' or 'ST_GLUSTER'
@type _storage_path_acceptance_fn: function
@param _storage_path_acceptance_fn: checks whether the given file-based
storage directory is acceptable
@see: C{cluster.CheckFileBasedStoragePathVsEnabledDiskTemplates} for details
@rtype: string @rtype: string
@returns: the name of the actual file storage directory @returns: the name of the actual file storage directory
""" """
assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes( assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
constants.ST_FILE, constants.ST_SHARED_FILE constants.ST_FILE, constants.ST_SHARED_FILE, constants.ST_GLUSTER
)) ))
if file_storage_dir is None: if file_storage_dir is None:
...@@ -432,8 +437,8 @@ def _PrepareFileBasedStorage( ...@@ -432,8 +437,8 @@ def _PrepareFileBasedStorage(
lambda path: filestorage.CheckFileStoragePathAcceptance( lambda path: filestorage.CheckFileStoragePathAcceptance(
path, exact_match_ok=True) path, exact_match_ok=True)
cluster.CheckFileStoragePathVsEnabledDiskTemplates( _storage_path_acceptance_fn(logging.warning, file_storage_dir,
logging.warning, file_storage_dir, enabled_disk_templates) enabled_disk_templates)
file_storage_enabled = file_disk_template in enabled_disk_templates file_storage_enabled = file_disk_template in enabled_disk_templates
if file_storage_enabled: if file_storage_enabled:
...@@ -458,6 +463,7 @@ def _PrepareFileStorage( ...@@ -458,6 +463,7 @@ def _PrepareFileStorage(
return _PrepareFileBasedStorage( return _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir, enabled_disk_templates, file_storage_dir,
pathutils.DEFAULT_FILE_STORAGE_DIR, constants.DT_FILE, pathutils.DEFAULT_FILE_STORAGE_DIR, constants.DT_FILE,
cluster.CheckFileStoragePathVsEnabledDiskTemplates,
init_fn=init_fn, acceptance_fn=acceptance_fn) init_fn=init_fn, acceptance_fn=acceptance_fn)
...@@ -472,6 +478,7 @@ def _PrepareSharedFileStorage( ...@@ -472,6 +478,7 @@ def _PrepareSharedFileStorage(
return _PrepareFileBasedStorage( return _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir, enabled_disk_templates, file_storage_dir,
pathutils.DEFAULT_SHARED_FILE_STORAGE_DIR, constants.DT_SHARED_FILE, pathutils.DEFAULT_SHARED_FILE_STORAGE_DIR, constants.DT_SHARED_FILE,
cluster.CheckSharedFileStoragePathVsEnabledDiskTemplates,
init_fn=init_fn, acceptance_fn=acceptance_fn) init_fn=init_fn, acceptance_fn=acceptance_fn)
...@@ -486,6 +493,7 @@ def _PrepareGlusterStorage( ...@@ -486,6 +493,7 @@ def _PrepareGlusterStorage(
return _PrepareFileBasedStorage( return _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir, enabled_disk_templates, file_storage_dir,
pathutils.DEFAULT_GLUSTER_STORAGE_DIR, constants.DT_GLUSTER, pathutils.DEFAULT_GLUSTER_STORAGE_DIR, constants.DT_GLUSTER,
cluster.CheckGlusterStoragePathVsEnabledDiskTemplates,
init_fn=init_fn, acceptance_fn=acceptance_fn) init_fn=init_fn, acceptance_fn=acceptance_fn)
...@@ -682,6 +690,8 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914 ...@@ -682,6 +690,8 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
file_storage_dir) file_storage_dir)
shared_file_storage_dir = _PrepareSharedFileStorage(enabled_disk_templates, shared_file_storage_dir = _PrepareSharedFileStorage(enabled_disk_templates,
shared_file_storage_dir) shared_file_storage_dir)
gluster_storage_dir = _PrepareGlusterStorage(enabled_disk_templates,
gluster_storage_dir)
if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", mac_prefix): if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", mac_prefix):
raise errors.OpPrereqError("Invalid mac prefix given '%s'" % mac_prefix, raise errors.OpPrereqError("Invalid mac prefix given '%s'" % mac_prefix,
......
...@@ -828,8 +828,9 @@ def CheckFileBasedStoragePathVsEnabledDiskTemplates( ...@@ -828,8 +828,9 @@ def CheckFileBasedStoragePathVsEnabledDiskTemplates(
""" """
assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes( assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
constants.ST_FILE, constants.ST_SHARED_FILE constants.ST_FILE, constants.ST_SHARED_FILE, constants.ST_GLUSTER
)) ))
file_storage_enabled = file_disk_template in enabled_disk_templates file_storage_enabled = file_disk_template in enabled_disk_templates
if file_storage_dir is not None: if file_storage_dir is not None:
if file_storage_dir == "": if file_storage_dir == "":
...@@ -872,6 +873,18 @@ def CheckSharedFileStoragePathVsEnabledDiskTemplates( ...@@ -872,6 +873,18 @@ def CheckSharedFileStoragePathVsEnabledDiskTemplates(
constants.DT_SHARED_FILE) constants.DT_SHARED_FILE)
def CheckGlusterStoragePathVsEnabledDiskTemplates(
logging_warn_fn, file_storage_dir, enabled_disk_templates):
"""Checks whether the given gluster storage directory is acceptable.
@see: C{CheckFileBasedStoragePathVsEnabledDiskTemplates}
"""
CheckFileBasedStoragePathVsEnabledDiskTemplates(
logging_warn_fn, file_storage_dir, enabled_disk_templates,
constants.DT_GLUSTER)
def CheckCompressionTools(tools): def CheckCompressionTools(tools):
"""Check whether the provided compression tools look like executables. """Check whether the provided compression tools look like executables.
...@@ -3095,7 +3108,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors): ...@@ -3095,7 +3108,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
""" """
assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes( assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
constants.ST_FILE, constants.ST_SHARED_FILE constants.ST_FILE, constants.ST_SHARED_FILE, constants.ST_GLUSTER
)) ))
cluster = self.cfg.GetClusterInfo() cluster = self.cfg.GetClusterInfo()
...@@ -3128,6 +3141,17 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors): ...@@ -3128,6 +3141,17 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
constants.NV_SHARED_FILE_STORAGE_PATH, constants.NV_SHARED_FILE_STORAGE_PATH,
constants.CV_ENODESHAREDFILESTORAGEPATHUNUSABLE) constants.CV_ENODESHAREDFILESTORAGEPATHUNUSABLE)
def _VerifyGlusterStoragePaths(self, ninfo, nresult):
"""Verifies (file) storage paths.
@see: C{_VerifyStoragePaths}
"""
self._VerifyStoragePaths(
ninfo, nresult, constants.DT_GLUSTER,
constants.NV_GLUSTER_STORAGE_PATH,
constants.CV_ENODEGLUSTERSTORAGEPATHUNUSABLE)
def _VerifyOob(self, ninfo, nresult): def _VerifyOob(self, ninfo, nresult):
"""Verifies out of band functionality of a node. """Verifies out of band functionality of a node.
...@@ -3397,7 +3421,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors): ...@@ -3397,7 +3421,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
""" """
return ([], list(self.my_node_info.keys())) return ([], list(self.my_node_info.keys()))
def Exec(self, feedback_fn): def Exec(self, feedback_fn): # pylint: disable=R0915
"""Verify integrity of the node group, performing various test on nodes. """Verify integrity of the node group, performing various test on nodes.
""" """
...@@ -3696,6 +3720,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors): ...@@ -3696,6 +3720,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
node_i.uuid == master_node_uuid) node_i.uuid == master_node_uuid)
self._VerifyFileStoragePaths(node_i, nresult) self._VerifyFileStoragePaths(node_i, nresult)
self._VerifySharedFileStoragePaths(node_i, nresult) self._VerifySharedFileStoragePaths(node_i, nresult)
self._VerifyGlusterStoragePaths(node_i, nresult)
if nimg.vm_capable: if nimg.vm_capable:
self._UpdateVerifyNodeLVM(node_i, nresult, vg_name, nimg) self._UpdateVerifyNodeLVM(node_i, nresult, vg_name, nimg)
......
...@@ -3015,6 +3015,12 @@ cvEnodesharedfilestoragepathunusable = ...@@ -3015,6 +3015,12 @@ cvEnodesharedfilestoragepathunusable =
Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE, Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
"Shared file storage path unusable") "Shared file storage path unusable")
cvEnodeglusterstoragepathunusable :: (String, String, String)
cvEnodeglusterstoragepathunusable =
("node",
Types.cVErrorCodeToRaw CvENODEGLUSTERSTORAGEPATHUNUSABLE,
"Gluster storage path unusable")
cvEnodessh :: (String, String, String) cvEnodessh :: (String, String, String)
cvEnodessh = cvEnodessh =
("node", ("node",
...@@ -3076,6 +3082,7 @@ cvAllEcodes = ...@@ -3076,6 +3082,7 @@ cvAllEcodes =
cvEnoderpc, cvEnoderpc,
cvEnodesetup, cvEnodesetup,
cvEnodesharedfilestoragepathunusable, cvEnodesharedfilestoragepathunusable,
cvEnodeglusterstoragepathunusable,
cvEnodessh, cvEnodessh,
cvEnodetime, cvEnodetime,
cvEnodeuserscripts, cvEnodeuserscripts,
...@@ -3117,6 +3124,9 @@ nvFileStoragePath = "file-storage-path" ...@@ -3117,6 +3124,9 @@ nvFileStoragePath = "file-storage-path"
nvSharedFileStoragePath :: String nvSharedFileStoragePath :: String
nvSharedFileStoragePath = "shared-file-storage-path" nvSharedFileStoragePath = "shared-file-storage-path"
nvGlusterStoragePath :: String
nvGlusterStoragePath = "gluster-storage-path"
nvHvinfo :: String nvHvinfo :: String
nvHvinfo = "hvinfo" nvHvinfo = "hvinfo"
......
...@@ -413,6 +413,8 @@ $(THH.declareLADT ''String "CVErrorCode" ...@@ -413,6 +413,8 @@ $(THH.declareLADT ''String "CVErrorCode"
, ("CvENODEFILESTORAGEPATHUNUSABLE", "ENODEFILESTORAGEPATHUNUSABLE") , ("CvENODEFILESTORAGEPATHUNUSABLE", "ENODEFILESTORAGEPATHUNUSABLE")
, ("CvENODESHAREDFILESTORAGEPATHUNUSABLE", , ("CvENODESHAREDFILESTORAGEPATHUNUSABLE",
"ENODESHAREDFILESTORAGEPATHUNUSABLE") "ENODESHAREDFILESTORAGEPATHUNUSABLE")
, ("CvENODEGLUSTERSTORAGEPATHUNUSABLE",
"ENODEGLUSTERSTORAGEPATHUNUSABLE")
, ("CvEGROUPDIFFERENTPVSIZE", "EGROUPDIFFERENTPVSIZE") , ("CvEGROUPDIFFERENTPVSIZE", "EGROUPDIFFERENTPVSIZE")
]) ])
$(THH.makeJSONInstance ''CVErrorCode) $(THH.makeJSONInstance ''CVErrorCode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment