Merge "Adding ability disable anti_affinty check in plugin"

This commit is contained in:
Jenkins 2015-12-04 20:40:20 +00:00 committed by Gerrit Code Review
commit 0d4dbeadaa
3 changed files with 41 additions and 20 deletions

View File

@ -157,6 +157,10 @@ ENABLE_HBASE_COMMON_LIB = p.Config('Enable HBase Common Lib',
'general', 'cluster', config_type='bool',
priority=1, default_value=True)
REQUIRE_ANTI_AFFINITY = p.Config('Require Anti Affinity',
'general', 'cluster', config_type='bool',
priority=2, default_value=True)
SWIFT_LIB_URL = p.Config(
'Hadoop OpenStack library URL', 'general', 'cluster', priority=1,
default_value=DEFAULT_SWIFT_LIB_URL,
@ -196,8 +200,8 @@ EXECUTOR_EXTRA_CLASSPATH = p.Config(
def _get_cluster_plugin_configs():
return [CDH5_REPO_URL, CDH5_REPO_KEY_URL, CM5_REPO_URL, CM5_REPO_KEY_URL,
KMS_REPO_URL, KMS_REPO_KEY_URL,
ENABLE_SWIFT, ENABLE_HBASE_COMMON_LIB, SWIFT_LIB_URL,
EXTJS_LIB_URL, AWAIT_AGENTS_TIMEOUT,
ENABLE_SWIFT, REQUIRE_ANTI_AFFINITY, ENABLE_HBASE_COMMON_LIB,
SWIFT_LIB_URL, EXTJS_LIB_URL, AWAIT_AGENTS_TIMEOUT,
AWAIT_MANAGER_STARTING_TIMEOUT, EXECUTOR_EXTRA_CLASSPATH]
@ -343,6 +347,10 @@ def _get_config_value(cluster, key):
'general', {}).get(key.name, key.default_value)
def get_required_anti_affinity(cluster):
return _get_config_value(cluster, REQUIRE_ANTI_AFFINITY)
def get_cdh5_repo_url(cluster):
return _get_config_value(cluster, CDH5_REPO_URL)

View File

@ -46,6 +46,7 @@ def validate_cluster_creating(cluster):
_('Number of datanodes must be not less than dfs_replication.'))
jn_count = _get_inst_count(cluster, 'HDFS_JOURNALNODE')
require_anti_affinity = PU.c_helper.get_required_anti_affinity(cluster)
if jn_count > 0:
if jn_count < 3:
raise ex.InvalidComponentCountException('HDFS_JOURNALNODE',
@ -57,14 +58,14 @@ def validate_cluster_creating(cluster):
if zk_count < 1:
raise ex.RequiredServiceMissingException('ZOOKEEPER',
required_by='HDFS HA')
if 'HDFS_SECONDARYNAMENODE' not in _get_anti_affinity(cluster):
raise ex.NameNodeHAConfigurationError(_('HDFS_SECONDARYNAMENODE '
'should be enabled '
'in anti_affinity.'))
if 'HDFS_NAMENODE' not in _get_anti_affinity(cluster):
raise ex.NameNodeHAConfigurationError(_('HDFS_NAMENODE '
'should be enabled '
'in anti_affinity.'))
if require_anti_affinity:
if 'HDFS_SECONDARYNAMENODE' not in _get_anti_affinity(cluster):
raise ex.NameNodeHAConfigurationError(
_('HDFS_SECONDARYNAMENODE should be enabled '
'in anti_affinity.'))
if 'HDFS_NAMENODE' not in _get_anti_affinity(cluster):
raise ex.NameNodeHAConfigurationError(
_('HDFS_NAMENODE should be enabled in anti_affinity.'))
rm_count = _get_inst_count(cluster, 'YARN_RESOURCEMANAGER')
if rm_count > 1:
@ -82,12 +83,14 @@ def validate_cluster_creating(cluster):
if zk_count < 1:
raise ex.RequiredServiceMissingException('ZOOKEEPER',
required_by='RM HA')
if 'YARN_RESOURCEMANAGER' not in _get_anti_affinity(cluster):
raise ex.ResourceManagerHAConfigurationError(
_('YARN_RESOURCEMANAGER should be enabled in anti_affinity.'))
if 'YARN_STANDBYRM' not in _get_anti_affinity(cluster):
raise ex.ResourceManagerHAConfigurationError(
_('YARN_STANDBYRM should be enabled in anti_affinity.'))
if require_anti_affinity:
if 'YARN_RESOURCEMANAGER' not in _get_anti_affinity(cluster):
raise ex.ResourceManagerHAConfigurationError(
_('YARN_RESOURCEMANAGER should be enabled in '
'anti_affinity.'))
if 'YARN_STANDBYRM' not in _get_anti_affinity(cluster):
raise ex.ResourceManagerHAConfigurationError(
_('YARN_STANDBYRM should be enabled in anti_affinity.'))
hs_count = _get_inst_count(cluster, 'YARN_JOBHISTORY')
if hs_count > 1:

View File

@ -19,19 +19,29 @@ from sahara.tests.unit.plugins.cdh import utils as ctu
class ConfigHelperTestCase(base.SaharaTestCase):
def setUp(self):
super(ConfigHelperTestCase, self).setUp()
self.cluster = ctu.get_fake_cluster(cluster_configs={})
def test_is_swift_enabled(self):
cluster = ctu.get_fake_cluster(cluster_configs={})
self.assertTrue(c_h.is_swift_enabled(cluster))
self.assertTrue(c_h.is_swift_enabled(self.cluster))
cluster = ctu.get_fake_cluster(
cluster_configs={'general': {c_h.ENABLE_SWIFT.name: False}})
self.assertFalse(c_h.is_swift_enabled(cluster))
def test_get_swift_lib_url(self):
cluster = ctu.get_fake_cluster(cluster_configs={})
self.assertEqual(c_h.DEFAULT_SWIFT_LIB_URL,
c_h.get_swift_lib_url(cluster))
c_h.get_swift_lib_url(self.cluster))
cluster = ctu.get_fake_cluster(
cluster_configs={'general': {c_h.SWIFT_LIB_URL.name: 'spam'}})
self.assertEqual('spam', c_h.get_swift_lib_url(cluster))
def test_get_required_anti_affinity(self):
self.assertTrue(c_h.get_required_anti_affinity(self.cluster))
cluster = ctu.get_fake_cluster(
cluster_configs={'general': {
c_h.REQUIRE_ANTI_AFFINITY.name: False}})
self.assertFalse(c_h.get_required_anti_affinity(cluster))