AMBARI-22336. Alerts UPDATE/DELETE should work deleting and adding a cluster (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/05c5bf79 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/05c5bf79 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/05c5bf79 Branch: refs/heads/branch-3.0-perf Commit: 05c5bf798c2b69d41f3ddfa340cffc7c447ea9fb Parents: 9d99c44 Author: Andrew Onishuk <[email protected]> Authored: Tue Oct 31 14:13:18 2017 +0200 Committer: Andrew Onishuk <[email protected]> Committed: Tue Oct 31 14:13:18 2017 +0200 ---------------------------------------------------------------------- .../ClusterAlertDefinitionsCache.py | 22 ++++++++++++++++++++ .../ambari/server/stack/StackManager.java | 2 +- .../apache/ambari/server/state/ServiceInfo.java | 2 +- .../custom_actions/scripts/check_host.py | 1 + .../stacks/PERF/1.0/repos/repoinfo.xml | 1 + .../stacks/PERF/2.0/repos/repoinfo.xml | 1 + contrib/utils/perf/deploy-gce-perf-cluster.py | 16 ++++++-------- 7 files changed, 33 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/05c5bf79/ambari-agent/src/main/python/ambari_agent/ClusterAlertDefinitionsCache.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/ClusterAlertDefinitionsCache.py b/ambari-agent/src/main/python/ambari_agent/ClusterAlertDefinitionsCache.py index 914f453..e2ed4cf 100644 --- a/ambari-agent/src/main/python/ambari_agent/ClusterAlertDefinitionsCache.py +++ b/ambari-agent/src/main/python/ambari_agent/ClusterAlertDefinitionsCache.py @@ -39,6 +39,9 @@ limitations under the License. """ from ambari_agent.ClusterCache import ClusterCache +import logging + +logger = logging.getLogger(__name__) class ClusterAlertDefinitionsCache(ClusterCache): """ @@ -70,6 +73,11 @@ class ClusterAlertDefinitionsCache(ClusterCache): mutable_dict = self._get_mutable_copy() for cluster_id in cache_update: + # adding a new cluster via UPDATE + if not cluster_id in mutable_dict: + mutable_dict[cluster_id] = cache_update[cluster_id] + continue + for alert_definition in cache_update[cluster_id]['alertDefinitions']: id_to_update = alert_definition['definitionId'] index_of_alert = self.get_alert_definition_index_by_id(mutable_dict, cluster_id, id_to_update) @@ -82,9 +90,20 @@ class ClusterAlertDefinitionsCache(ClusterCache): def cache_delete(self, cache_update, cache_hash): mutable_dict = self._get_mutable_copy() + clusters_ids_to_delete = [] for cluster_id in cache_update: + if not cluster_id in mutable_dict: + logger.error("Cannot do alert_definitions delete for cluster cluster_id={0}, because do not have information about the cluster".format(cluster_id)) + continue + + # deleting whole cluster + if cache_update[cluster_id] == {}: + clusters_ids_to_delete.append(cluster_id) + continue + for alert_definition in cache_update[cluster_id]['alertDefinitions']: + id_to_update = alert_definition['definitionId'] index_of_alert = self.get_alert_definition_index_by_id(mutable_dict, cluster_id, id_to_update) @@ -93,6 +112,9 @@ class ClusterAlertDefinitionsCache(ClusterCache): del mutable_dict[cluster_id]['alertDefinitions'][index_of_alert] + for cluster_id in clusters_ids_to_delete: + del mutable_dict[cluster_id] + self.rewrite_cache(mutable_dict, cache_hash) http://git-wip-us.apache.org/repos/asf/ambari/blob/05c5bf79/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java index eb6737a..239d9cf 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java @@ -81,7 +81,7 @@ public class StackManager { /** * Prefix used for common stack hooks parent path string */ - public static final String DEFAULT_HOOKS_FOLDER = "stack-hooks"; + public static final String DEFAULT_HOOKS_FOLDER = "stacks/PERF/1.0/hooks"; /** * Prefix used for extension services parent path string http://git-wip-us.apache.org/repos/asf/ambari/blob/05c5bf79/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java index 8fe6583..eb45572 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java @@ -87,7 +87,7 @@ public class ServiceInfo implements Validable{ JAVA } @XmlElement(name="service_advisor_type") - private ServiceAdvisorType serviceAdvisorType = null; + private ServiceAdvisorType serviceAdvisorType = ServiceAdvisorType.PYTHON; @XmlTransient private List<PropertyInfo> properties; http://git-wip-us.apache.org/repos/asf/ambari/blob/05c5bf79/ambari-server/src/main/resources/custom_actions/scripts/check_host.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py index e610307..0ccbd88 100644 --- a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py +++ b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py @@ -116,6 +116,7 @@ class CheckHost(Script): self.pkg_provider = get_provider("Package") def actionexecute(self, env): + raise Exception("Skip") Logger.info("Host checks started.") config = Script.get_config() tmp_dir = Script.get_tmp_dir() http://git-wip-us.apache.org/repos/asf/ambari/blob/05c5bf79/ambari-server/src/main/resources/stacks/PERF/1.0/repos/repoinfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/PERF/1.0/repos/repoinfo.xml b/ambari-server/src/main/resources/stacks/PERF/1.0/repos/repoinfo.xml old mode 100644 new mode 100755 index 0895fab..3801e0c --- a/ambari-server/src/main/resources/stacks/PERF/1.0/repos/repoinfo.xml +++ b/ambari-server/src/main/resources/stacks/PERF/1.0/repos/repoinfo.xml @@ -16,6 +16,7 @@ limitations under the License. --> <reposinfo> + <latest>/var/lib/ambari-server/resources/stacks/PERF/1.0/hdp_urlinfo.json</latest> <os family="redhat6"> <repo> <baseurl>http://foo-1.0.1.0-1</baseurl> http://git-wip-us.apache.org/repos/asf/ambari/blob/05c5bf79/ambari-server/src/main/resources/stacks/PERF/2.0/repos/repoinfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/PERF/2.0/repos/repoinfo.xml b/ambari-server/src/main/resources/stacks/PERF/2.0/repos/repoinfo.xml old mode 100644 new mode 100755 index 5c3b40b..3bb0235 --- a/ambari-server/src/main/resources/stacks/PERF/2.0/repos/repoinfo.xml +++ b/ambari-server/src/main/resources/stacks/PERF/2.0/repos/repoinfo.xml @@ -16,6 +16,7 @@ limitations under the License. --> <reposinfo> + <latest>/var/lib/ambari-server/resources/stacks/PERF/2.0/hdp_urlinfo.json</latest> <os family="redhat6"> <repo> <baseurl>http://foo-2.0.0.0-1</baseurl> http://git-wip-us.apache.org/repos/asf/ambari/blob/05c5bf79/contrib/utils/perf/deploy-gce-perf-cluster.py ---------------------------------------------------------------------- diff --git a/contrib/utils/perf/deploy-gce-perf-cluster.py b/contrib/utils/perf/deploy-gce-perf-cluster.py index 7431ae9..69aabe3 100644 --- a/contrib/utils/perf/deploy-gce-perf-cluster.py +++ b/contrib/utils/perf/deploy-gce-perf-cluster.py @@ -28,12 +28,12 @@ import re import socket cluster_prefix = "perf" -ambari_repo_file_url = "http://s3.amazonaws.com/dev.hortonworks.com/ambari/centos6/2.x/updates/2.5.0.0/ambaribn.repo" +ambari_repo_file_url = "http://10.240.0.30/ambari.repo" public_hostname_script = "foo" hostname_script = "foo" -NUMBER_OF_AGENTS_ON_HOST = 50 +NUMBER_OF_AGENTS_ON_HOST = 70 class SSH: @@ -330,10 +330,7 @@ def create_server_script(server_host_name): contents = "#!/bin/bash\n" + \ "wget -O /etc/yum.repos.d/ambari.repo {0}\n".format(ambari_repo_file_url) + \ - "yum clean all; yum install git ambari-server -y\n" + \ - "mkdir /home ; cd /home ; git clone https://github.com/apache/ambari.git ; cd ambari ; git checkout branch-2.5\n" + \ - "cp -r /home/ambari/ambari-server/src/main/resources/stacks/PERF /var/lib/ambari-server/resources/stacks/PERF\n" + \ - "cp -r /home/ambari/ambari-server/src/main/resources/stacks/PERF /var/lib/ambari-agent/cache/stacks/PERF\n" + \ + "yum clean all; yum install ambari-server -y\n" + \ "sed -i -f /home/ambari/ambari-server/src/main/resources/stacks/PERF/install_packages.sed /var/lib/ambari-server/resources/custom_actions/scripts/install_packages.py\n" + \ "sed -i -f /home/ambari/ambari-server/src/main/resources/stacks/PERF/install_packages.sed /var/lib/ambari-agent/cache/custom_actions/scripts/install_packages.py\n" + \ "\n" + \ @@ -399,13 +396,11 @@ def create_agent_script(server_host_name): # TODO, instead of cloning Ambari repo on each VM, do it on the server once and distribute to all of the agents. contents = "#!/bin/bash\n" + \ "wget -O /etc/yum.repos.d/ambari.repo {0}\n".format(ambari_repo_file_url) + \ - "yum clean all; yum install krb5-workstation git ambari-agent -y\n" + \ - "mkdir /home ; cd /home; git clone https://github.com/apache/ambari.git ; cd ambari ; git checkout branch-2.5\n" + \ - "cp -r /home/ambari/ambari-server/src/main/resources/stacks/PERF /var/lib/ambari-agent/cache/stacks/PERF\n" + \ + "yum clean all; yum install krb5-workstation ambari-agent -y\n" + \ "sed -i -f /var/lib/ambari-agent/cache/stacks/PERF/PythonExecutor.sed /usr/lib/python2.6/site-packages/ambari_agent/PythonExecutor.py\n" + \ "sed -i -e 's/hostname=localhost/hostname={0}/g' /etc/ambari-agent/conf/ambari-agent.ini\n".format(server_host_name) + \ "sed -i -e 's/agent]/agent]\\nhostname_script={0}\\npublic_hostname_script={1}\\n/1' /etc/ambari-agent/conf/ambari-agent.ini\n".format(hostname_script, public_hostname_script) + \ - "python /home/ambari/ambari-agent/conf/unix/agent-multiplier.py start\n" + \ + "wget http://10.240.0.30/agent-multiplier.py ; python agent-multiplier.py start\n" + \ "exit 0" with open("agent.sh", "w") as f: @@ -429,6 +424,7 @@ def execute_command(args, ip, cmd, fail_message, custom_option='', login='root') if status_code != 0: raise Exception(ssh_result["errormsg"]) + print ssh_result return ssh_result["log"][0]
