Просмотр исходного кода

AMBARI-319. Scale puppet master to large number of nodes. (Contributed by Jitendra)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1345404 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K 13 лет назад
Родитель
Сommit
a845f72a7f

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-319. Scale puppet master to large number of nodes. (Jitendra via Vikram)
+
   AMBARI-318. Do not install the packages that install init.d scripts (Ramya via Vikram).
 
   AMBARI-304. Upgrade to yui-3.5.1. Manage Services commit (Vinod via Vikram)

+ 19 - 1
hmc/ShellScripts/puppet_agent_install.sh

@@ -145,6 +145,15 @@ if [[ "$ret" != "0" ]]; then
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
   exit 1
 fi
+
+#Install ruby
+out=`yum install -y ruby-devel rubygems`
+ret=$?
+if [[ "$ret" != "0" ]]; then
+  echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
+  exit 1
+fi
+
 out=`mkdir -p /etc/puppet/agent 2>&1`
 agent_auth_conf="path /run\nauth any\nallow $master\n\npath /\nauth any"
 out=`echo -e $agent_auth_conf > /etc/puppet/agent/auth.conf`
@@ -157,13 +166,22 @@ if [[ "$ret" != "0" ]]; then
   exit 1
 fi
 
+#Download modules and untar
+out=`curl -o /etc/puppet/agent/modules.tgz $master/hmc/modules.tgz && cd /etc/puppet/agent/ &&  tar zxf modules.tgz --strip-components 1 && cd -`
+ret=$?
+if [[ "$ret" != "0" ]]; then
+  echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
+  exit 1
+fi
+out=`rm /etc/puppet/agent/modules.tgz`
+
 #TODO clean this up for better fix. For now make sure we stop puppet agent. The issue here is we do not know if we started this puppet agent during our run or not.
 echo "Stopping puppet agent using service stop command"
 out=`service puppet stop`
 ret=$?
 
 echo "Starting puppet agent for HMC"
-out=`puppet agent --verbose --confdir=/etc/puppet/agent --listen --runinterval 5 --server $master --report --no-client --waitforcert 10 --configtimeout 600 --debug --logdest=/var/log/puppet_agent.log --httplog /var/log/puppet_agent_http.log --autoflush 2>&1`
+out=`puppet agent --verbose --confdir=/etc/puppet/agent --listen --runinterval 5 --server $master --report --no-client --waitforcert 10 --configtimeout 600 --debug --logdest=/var/log/puppet_agent.log --httplog /var/log/puppet_agent_http.log --autoflush --use_cached_catalog 2>&1`
 ret=$?
 if [[ "$ret" != "0" ]]; then
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2

+ 8 - 5
hmc/package/rpm/SPECS/hmc.spec

@@ -37,7 +37,7 @@ Buildroot: %{_tmppath}/%{name}-%{version}-buildroot
 Requires: php >= 5, sqlite >= 3, php-pdo, php-pecl-json, httpd, puppet = 2.7.9, pdsh, httpd-devel, ruby-devel, rubygems, mod_passenger, mod_ssl
 %define web_prefixdir %{_prefix}/share/hmc
 %define httpd_confdir %{_sysconfdir}/httpd/conf.d
-%define puppet_dir %{_sysconfdir}/puppet/master
+%define puppet_master_dir %{_sysconfdir}/puppet/master
 %define hmc_passwd_dir %{_sysconfdir}/hmc
 %define hmc_db_dir %{_var}/db/hmc
 %define hmc_run_dir %{_var}/run/hmc
@@ -59,8 +59,9 @@ This package provides a Management Console for Hadoop Cluster.
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/bin/
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/yum_repo/
-%__mkdir -p $RPM_BUILD_ROOT/%{puppet_dir}/
-%__mkdir -p $RPM_BUILD_ROOT/%{puppet_dir}/manifests
+%__mkdir -p $RPM_BUILD_ROOT/%{puppet_master_dir}/
+%__mkdir -p $RPM_BUILD_ROOT/%{puppet_master_dir}/manifests
+%__mkdir -p $RPM_BUILD_ROOT/%{puppet_master_dir}/modules/catalog/files
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/
 %__install -d "%{buildroot}%{hmc_db_dir}"
 %__install -d "%{buildroot}%{hmc_log_dir}"
@@ -81,10 +82,12 @@ This package provides a Management Console for Hadoop Cluster.
 %__cp -rf yui-3.5.1 $RPM_BUILD_ROOT/%{web_prefixdir}/
 %__cp -f yuiCombinator.php $RPM_BUILD_ROOT/%{web_prefixdir}/
 %__cp -rf conf $RPM_BUILD_ROOT/%{web_prefixdir}/
-%__cp -rf puppet/modules $RPM_BUILD_ROOT/%{puppet_dir}
+%__cp -rf puppet/manifestloader $RPM_BUILD_ROOT/%{puppet_master_dir}
+%__cp -rf puppet/modules/stdlib $RPM_BUILD_ROOT/%{puppet_master_dir}/modules
 %__cp -f "%{SOURCE2}" $RPM_BUILD_ROOT/%{web_prefixdir}/yum_repo/
 %__install -D -m0755 puppet/reports/get_revision $RPM_BUILD_ROOT/%{web_prefixdir}/bin
 %__cp -rf puppet/reports/hmcreport.rb $RPM_BUILD_ROOT/usr/lib/ruby/site_ruby/1.8/puppet/reports/
+%__tar czf $RPM_BUILD_ROOT/%{web_prefixdir}/modules.tgz puppet/modules
 echo "Alias /hdp %{_prefix}/share/hdp" > $RPM_BUILD_ROOT/%{httpd_confdir}/hdp_mon_dashboard.conf
 %post
 if test X"$RPM_INSTALL_PREFIX0" = X"" ; then
@@ -126,7 +129,7 @@ rm -rf /var/run/hmc/license
 /usr/lib/ruby/site_ruby/1.8/puppet/reports/hmcreport.rb
 %config /etc/init.d/%{name}
 %{hmc_passwd_dir}*
-%{puppet_dir}/*
+%{puppet_master_dir}/*
 %{hmc_db_dir}
 %{hmc_log_dir}
 %{hmc_run_dir}/*

+ 5 - 3
hmc/php/conf/Config.inc

@@ -9,11 +9,13 @@ $GLOBALS["CLUSTERMAIN_PATH"] = $INSTALL_ROOT . "/php/orchestrator/ClusterMain.ph
 $GLOBALS["DB_PATH"] = "/var/db/hmc/data/data.db";
 
 $GLOBALS["puppetMaxParallelKicks"] = 10;
-$GLOBALS["puppetManifestDir"] = "/etc/puppet/master/manifests/";
+$GLOBALS["puppetManifestDir"] = "/etc/puppet/master/modules/catalog/files/";
 $GLOBALS["puppetKickVersionFile"] = "/var/lib/puppet/puppet_kick_version.txt";
 $GLOBALS["puppetReportsDir"] = "/var/lib/puppet/reports";
-$GLOBALS["puppetKickTimeout"] = 60;
-$GLOBALS["puppetModulesDirectory"] = "/etc/puppet/master/modules";
+$GLOBALS["puppetKickTimeout"] = 180;
+$GLOBALS["puppetModulesDirectory"] = "/etc/puppet/agent/modules";
+$GLOBALS["manifestloaderFile"] = "/etc/puppet/master/manifestloader/site.pp";
+$GLOBALS["manifestloaderDestinationDir"] = "/etc/puppet/master/manifests";
 $GLOBALS["puppet_install"] = "/usr/share/hmc/ShellScripts/puppet_agent_install.sh";
 $GLOBALS["DRYRUN"] = FALSE;
 

+ 0 - 1
hmc/php/frontend/fetchTxnProgress.php

@@ -685,7 +685,6 @@ $lastTransaction = $progressSubTxn;
 
 $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
 
-$logger->log_debug("Process running? ".$progress['processRunning']." encountered error ".$progress['encounteredError']);
 if (($progress['processRunning'] == FALSE) || ($progress['encounteredError'] == TRUE)) {
   // get the transaction status info from db
   $retval = $dbAccessor->getTransactionStatusInfo($clusterName, $txnId);

+ 3 - 0
hmc/php/puppet/PuppetInvoker.php

@@ -200,6 +200,9 @@
            $timedoutNodes, $successfullNodes, $nodes); 
       }
 
+      //Add manifest loader
+      copy($GLOBALS["manifestloaderFile"], $GLOBALS["manifestloaderDestinationDir"] . "/site.pp");
+
       //Generate manifest
       $modulesDir = $GLOBALS["puppetModulesDirectory"];
       ManifestGenerator::generateManifest($manifestDir, $hostInfo,

+ 1 - 3
hmc/puppet/conf/puppet.conf.template

@@ -10,7 +10,6 @@
     # Where SSL certificates are kept.
     # The default value is '$confdir/ssl'.
     ssldir = $vardir/ssl
-    pluginsync = true
 
 [agent]
     # The file in which puppetd stores a list of the classes
@@ -24,7 +23,6 @@
     # extension indicating the cache format is added automatically.
     # The default value is '$confdir/localconfig'.
     localconfig = $vardir/localconfig
-    pluginsync = true
 
 [master]
   ssl_client_header=SSL_CLIENT_S_DN
@@ -36,4 +34,4 @@
   debug=true
   logdest=/var/log/puppet_master.log
   autoflush=true
-  pluginsync = true
+  use_cached_catalog = true

+ 43 - 0
hmc/puppet/manifestloader/site.pp

@@ -0,0 +1,43 @@
+class manifestloader () {
+    anchor { 'manifestloader::begin': }
+    file { '/etc/puppet/agent/site.pp':
+      ensure => present,
+      source => "puppet:///modules/catalog/site.pp",  
+      mode => '0755',
+      require => Anchor['manifestloader::begin'],      
+      notify => Exec['rm_puppet_apply_log']
+    }
+
+    exec {'rm_puppet_apply_log':
+      command   => "rm -f /var/log/puppet_apply.log",
+      path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+      notify    => Exec['puppet_apply'],
+      require   => File['/etc/puppet/agent/site.pp'],
+      logoutput => "true"
+    }
+
+    exec { 'puppet_apply':
+      command   => "puppet apply --confdir=/etc/puppet/agent --logdest=/var/log/puppet_apply.log --debug --autoflush /etc/puppet/agent/site.pp",
+      timeout   => 1200,
+      path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+      require   => Exec['rm_puppet_apply_log'],
+      notify    => Exec['append'],
+      logoutput => "true"
+    }
+
+    exec { 'append':
+      command   => "cat /var/log/puppet_apply.log",
+      path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+      require   => Exec['puppet_apply'],
+      notify   => Anchor['manifestloader::end'],
+      logoutput => "true"
+    }
+    anchor { 'manifestloader::end': }
+}
+
+node default {
+ #stage{1 :}
+ include manifestloader
+ #class {'manifestloader': stage => 1}
+}
+