Validate node groups without volumes

MapR FS requires at least 1 separate partition or drive
to be deployed successfully. Hence, if there are neither
Cinder volumes nor ephemeral drive appended, cluster has
to be considered invalid

Change-Id: I9fac12be36b2e1f002db40cfdceecd662b7e7ee3
Closes-Bug: #1439433
This commit is contained in:
Artem Osadchyi 2015-04-03 15:12:37 +03:00
parent b85cc4691b
commit 4d9dd41ef3
3 changed files with 26 additions and 0 deletions

View File

@ -72,6 +72,7 @@ Every MapR cluster must contain:
* exactly 1 *Webserver* process
* odd number of *ZooKeeper* processes but not less than 1
* *FileServer* process on every node
* at least 1 Cinder volume or ephemeral drive per instance
Every Hadoop cluster must contain exactly 1 *Oozie* process

View File

@ -78,6 +78,7 @@ class MapRFS(s.Service):
vu.at_least(1, CLDB),
vu.each_node_has(FILE_SERVER),
vu.on_same_node(CLDB, FILE_SERVER),
vu.has_volumes(),
]
def service_dir(self, cluster_context):

View File

@ -19,6 +19,7 @@ from sahara.conductor import resource as r
import sahara.exceptions as ex
from sahara.i18n import _
import sahara.plugins.exceptions as e
import sahara.utils.openstack.nova as nova
class LessThanCountException(e.InvalidComponentCountException):
@ -78,6 +79,16 @@ class NodeServiceConflictException(ex.SaharaException):
self.code = NodeServiceConflictException.ERROR_CODE
class NoVolumesException(ex.SaharaException):
MESSAGE = _('%s must have at least 1 volume or ephemeral drive')
ERROR_CODE = "NO_VOLUMES"
def __init__(self, ng_name):
super(NoVolumesException, self).__init__()
self.message = NoVolumesException.MESSAGE % ng_name
self.code = NoVolumesException.ERROR_CODE
def at_least(count, component):
def validate(cluster_context, component, count):
actual_count = cluster_context.get_instances_count(component)
@ -173,3 +184,16 @@ def create_fake_cluster(cluster, existing, additional):
cluster_dict.update({'node_groups': updated + not_updated})
fake = r.ClusterResource(cluster_dict)
return fake
def get_ephemeral(node_group):
return nova.get_flavor(id=node_group.flavor_id).ephemeral
def has_volumes():
def validate(cluster_context):
for node_group in cluster_context.cluster.node_groups:
if not (node_group.volumes_per_node or get_ephemeral(node_group)):
raise NoVolumesException(node_group.name)
return validate