AMBARI-22484. Stack advisor should disallow lzo enable without accepting license agreement. Additional fixes. (mpapirkovskyy)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e12efe38 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e12efe38 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e12efe38 Branch: refs/heads/branch-3.0-perf Commit: e12efe38a0cdc6a0e1554026949bfeef60673a5a Parents: 82692bd Author: Myroslav Papirkovskyi <[email protected]> Authored: Wed Nov 29 17:23:49 2017 +0200 Committer: Myroslav Papirkovskyi <[email protected]> Committed: Wed Nov 29 18:30:08 2017 +0200 ---------------------------------------------------------------------- .../stackadvisor/StackAdvisorRequest.java | 8 +++++ .../stacks/HDP/2.0.6/services/stack_advisor.py | 36 +++++++++++++++----- .../src/main/resources/stacks/stack_advisor.py | 9 +++++ .../stacks/2.0.6/common/test_stack_advisor.py | 14 ++++++-- 4 files changed, 55 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e12efe38/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java index 62b8d15..b30eec6 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java @@ -123,6 +123,9 @@ public class StackAdvisorRequest { this.configGroups = configGroups; } + /** + * @return true if GPL license is accepted, false otherwise + */ public Boolean getGplLicenseAccepted() { return gplLicenseAccepted; } @@ -199,6 +202,11 @@ public class StackAdvisorRequest { return this; } + /** + * Set GPL license acceptance parameter to request. + * @param gplLicenseAccepted is GPL license accepted. + * @return stack advisor request builder. + */ public StackAdvisorRequestBuilder withGPLLicenseAccepted( Boolean gplLicenseAccepted) { this.instance.gplLicenseAccepted = gplLicenseAccepted; http://git-wip-us.apache.org/repos/asf/ambari/blob/e12efe38/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py index bfa2f5a..5584377 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py @@ -352,20 +352,38 @@ class HDP206StackAdvisor(DefaultStackAdvisor): self.recommendHadoopProxyUsers(configurations, services, hosts) def getLZOSupportValidationItems(self, properties, services): + ''' + Checks GPL license is accepted when GPL software is used. + :param properties: dict of properties' name and value pairs + :param services: list of services + :return: NOT_APPLICABLE messages in case GPL license is not accepted + ''' services_list = self.get_services_list(services) + validations = [] if "HDFS" in services_list: lzo_allowed = services["gpl-license-accepted"] - property_name = "io.compression.codec.lzo.class" - if property_name in properties: - property_value = properties.get(property_name) - if not lzo_allowed and "com.hadoop.compression.lzo.LzoCodec" in property_value: - return [{"config-name": property_name, "item": self.getErrorItem( - "Your Ambari Server has not been configured to download LZO and install it. " - "LZO is GPL software and requires you to accept a license prior to use. " - "Please refer to this documentation to configure Ambari before proceeding.")}] - return [] + self.validatePropertyToLZOCodec("io.compression.codecs", properties, lzo_allowed, validations) + self.validatePropertyToLZOCodec("io.compression.codec.lzo.class", properties, lzo_allowed, validations) + return validations + + def validatePropertyToLZOCodec(self, property_name, properties, lzo_allowed, validations): + ''' + Checks specified property contains LZO codec class and requires GPL license acceptance. + :param property_name: property name + :param properties: dict of properties' name and value pairs + :param lzo_allowed: is gpl license accepted + :param validations: list with validation failures + ''' + lzo_codec_class = "com.hadoop.compression.lzo.LzoCodec" + if property_name in properties: + property_value = properties.get(property_name) + if not lzo_allowed and lzo_codec_class in property_value: + validations.append({"config-name": property_name, "item": self.getNotApplicableItem( + "Your Ambari Server has not been configured to download LZO and install it. " + "LZO is GPL software and requires you to accept a license prior to use. " + "Please refer to the documentation to configure Ambari before proceeding.")}) def recommendHbaseConfigurations(self, configurations, clusterData, services, hosts): # recommendations for HBase env config http://git-wip-us.apache.org/repos/asf/ambari/blob/e12efe38/ambari-server/src/main/resources/stacks/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/stack_advisor.py b/ambari-server/src/main/resources/stacks/stack_advisor.py index 89f2997..0dcfff8 100644 --- a/ambari-server/src/main/resources/stacks/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/stack_advisor.py @@ -1749,6 +1749,15 @@ class DefaultStackAdvisor(StackAdvisor): """ return {"level": "ERROR", "message": message} + def getNotApplicableItem(self, message): + ''' + Creates report about validation error that can not be ignored. + UI should not allow the proceeding of work. + :param message: error description. + :return: report about error. + ''' + return {"level": "NOT_APPLICABLE", "message": message} + def getComponentHostNames(self, servicesDict, serviceName, componentName): for service in servicesDict["services"]: if service["StackServices"]["service_name"] == serviceName: http://git-wip-us.apache.org/repos/asf/ambari/blob/e12efe38/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py index 6c774af..300ffe9 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py @@ -2522,7 +2522,8 @@ class TestHDP206StackAdvisor(TestCase): 'hadoop.proxyuser.hdfs-user.groups': '*', 'hadoop.proxyuser.yarn-user.hosts': 'host1,host2', 'hadoop.proxyuser.yarn-user.groups': '*', - 'io.compression.codec.lzo.class': 'com.hadoop.compression.lzo.LzoCodec'} + 'io.compression.codec.lzo.class': 'com.hadoop.compression.lzo.LzoCodec', + 'io.compression.codecs': 'AnotherCodec, com.hadoop.compression.lzo.LzoCodec'} services = { 'services': [ { 'StackServices': {'service_name': 'HDFS'}}, @@ -2558,10 +2559,17 @@ class TestHDP206StackAdvisor(TestCase): res_expected = [{'config-type': 'core-site', 'message': 'Your Ambari Server has not been configured to download LZO and install it. ' 'LZO is GPL software and requires you to accept a license prior to use. ' - 'Please refer to this documentation to configure Ambari before proceeding.', + 'Please refer to the documentation to configure Ambari before proceeding.', + 'type': 'configuration', + 'config-name': 'io.compression.codecs', + 'level': 'NOT_APPLICABLE'}, + {'config-type': 'core-site', + 'message': 'Your Ambari Server has not been configured to download LZO and install it. ' + 'LZO is GPL software and requires you to accept a license prior to use. ' + 'Please refer to the documentation to configure Ambari before proceeding.', 'type': 'configuration', 'config-name': 'io.compression.codec.lzo.class', - 'level': 'ERROR'}] + 'level': 'NOT_APPLICABLE'}] res = self.stackAdvisor.validateHDFSConfigurationsCoreSite(properties, {}, configurations, services, hosts) self.assertEquals(res, res_expected)
