Bladeren bron

AMBARI-506. Do not use epel in local yum repo installs (Contributed by Hitesh)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1347354 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K 13 jaren geleden
bovenliggende
commit
5a67a1c6e9

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-506. Do not use epel in local yum repo installs (Hitesh via Vikram)
+
   AMBARI-507. Install rpms instead of tar.gz downloads (Ramya via Vikram)
 
   AMBARI-505. Messaging Update (Yusaku via Vikram)

+ 28 - 13
hmc/ShellScripts/puppet_agent_install.sh

@@ -33,9 +33,10 @@ trap 'pp_cmd=$ppp_cmd; ppp_cmd=$previous_command; previous_command=$this_command
 usage() {
   echo "
 Usage: $0 with the following parameters
-    --puppet-master            Puppet Master
+    --puppet-master     Puppet Master
     --repo-file         Repo File
     --gpg-key-files     GPG Key files - comma-separated
+    --using-local-repo  Whether local repo is being used
   "
 }
 
@@ -44,6 +45,7 @@ OPTS=$(getopt \
   -o '' \
   -l 'puppet-master:' \
   -l 'repo-file:' \
+  -l 'using-local-repo' \
   -l 'gpg-key-files:' \
   -l 'help' \
   -- "$@")
@@ -56,6 +58,8 @@ fi
 
 echo "DEBUG: opts ${OPTS}"
 
+USINGLOCALREPO=0
+
 eval set -- "${OPTS}"
 while true ; do
   case "$1" in
@@ -68,6 +72,9 @@ while true ; do
     --gpg-key-files)
       GPGKEYFILESTR=$2 ; shift 2
       ;;
+    --using-local-repo)
+      USINGLOCALREPO=1; shift
+      ;;
     --help)
       usage ;
       exit 0
@@ -100,6 +107,7 @@ fi
 master=${MASTER}
 repoFile=${REPOFILE}
 gpgKeyFiles=${GPGKEYFILES}
+usingLocalRepo=${USINGLOCALREPO}
 
 echo "DEBUG: Puppet Master: ${master}"
 echo "DEBUG: Repo File: ${repoFile}"
@@ -139,20 +147,27 @@ host=`hostname -f | tr '[:upper:]' '[:lower:]'`
 out=`/etc/init.d/iptables stop 1>/dev/null`
 
 #check if epel repo is installed if not try installing
-epel_installed=`yum repolist enabled | grep epel`
-if [[ "x$epel_installed" != "x" ]]; then 
-  echo "Already Installed epel repo"
-else
-  cmd="cat $repoFile | grep \"baseurl\" | awk -F= '{print \$2}'| awk 'NR==1' | sed 's/ //g'"
-  epelUrl=`eval $cmd`
-  epelRPM=$epelUrl/epel-release-5-4.noarch.rpm
-  rpm -Uvh $epelRPM
-  #make sure epel is installed else fail 
+#only needed if non-local repo mode
+echo "Using local repo setting is ${usingLocalRepo}"
+if [[ "${usingLocalRepo}" == "0" ]]; then
+  echo "Checking to see if epel needs to be installed"
   epel_installed=`yum repolist enabled | grep epel`
-  if [[ "x$epel_installed" == "x" ]]; then
-    echo "$host:_ERROR_:retcode:[1], CMD:[rpm -Uvh $epelRPM]: OUT:[Not Installed]" >&2
-    exit 1
+  if [[ "x$epel_installed" != "x" ]]; then
+    echo "Already Installed epel repo"
+  else
+    cmd="cat $repoFile | grep \"baseurl\" | awk -F= '{print \$2}'| awk 'NR==1' | sed 's/ //g'"
+    epelUrl=`eval $cmd`
+    epelRPM=$epelUrl/epel-release-5-4.noarch.rpm
+    rpm -Uvh $epelRPM
+    #make sure epel is installed else fail
+    epel_installed=`yum repolist enabled | grep epel`
+    if [[ "x$epel_installed" == "x" ]]; then
+      echo "$host:_ERROR_:retcode:[1], CMD:[rpm -Uvh $epelRPM]: OUT:[Not Installed]" >&2
+      exit 1
+    fi
   fi
+else
+  echo "Skipping epel check+install as local repo mode is enabled"
 fi
 
 echo "Installing puppet using yum"

+ 1 - 2
hmc/db/schema.dump

@@ -254,8 +254,7 @@ INSERT OR REPLACE INTO "ConfigProperties" ( key, default_value, display_name, de
 
 -- Configuration for local yum mirror support
 INSERT OR REPLACE INTO "ConfigProperties" ( key, default_value, display_name, description, service_name, display_type, display_attributes ) VALUES ( "yum_repo_file", "/etc/yum.repos.d/hdp.repo", "Path to YUM Repo file", "Path to YUM Repo file", "MISCELLANEOUS", "NODISPLAY", '{ "isPassword": false, "noDisplay": true, "reconfigurable": false, "displayType": "text" }' );
-INSERT OR REPLACE INTO "ConfigProperties" ( key, default_value, display_name, description, service_name, display_type, display_attributes ) VALUES ( "apache_artifacts_download_url", "http://s3.amazonaws.com/dev.hortonworks.com/HDP-1.0.11/repos/centos5/tars/", "Apache Artifacts Download URL", "URL form where to download HDP artifacts", "MISCELLANEOUS", "NODISPLAY", '{ "isPassword": false, "noDisplay": true, "reconfigurable": false, "displayType": "text" }' );
-INSERT OR REPLACE INTO "ConfigProperties" ( key, default_value, display_name, description, service_name, display_type, display_attributes ) VALUES ( "gpl_artifacts_download_url", "https://s3.amazonaws.com/dev.hortonworks.com/ARTIFACTS/", "GPL Artifacts Download URL", "URL form where to download GPL artifacts", "MISCELLANEOUS", "NODISPLAY", '{ "isPassword": false, "noDisplay": true, "reconfigurable": false, "displayType": "text" }' );
+INSERT OR REPLACE INTO "ConfigProperties" ( key, default_value, display_name, description, service_name, display_type, display_attributes ) VALUES ( "using_local_repo", "false", "Whether a local repo is being used", "Whether a local repo is being used", "MISCELLANEOUS", "NODISPLAY", '{ "isPassword": false, "noDisplay": true, "reconfigurable": false, "displayType": "checkbox" }' );
 
 --                                         gsCluster.properties keys
 

+ 0 - 4
hmc/html/initializeCluster.php

@@ -132,10 +132,6 @@
                       <div id="yumMirrorSupportFormFieldsId" style="display:none">
                         <label for="yumRepoFilePathId"><?php echo $RES['initWizard.addNodes.yumRepoFilePath.label'] ?></label>
                         <input type="text" name="YumRepoFilePath" id="yumRepoFilePathId" value="" placeholder="">
-                        <label for="hmcArtifactsDownloadUrlId"><?php echo $RES['initWizard.addNodes.apacheArtifactsDownloadUrl.label'] ?></label>
-                        <input type="text" name="HmcArtifactsDownloadUrl" id="hmcArtifactsDownloadUrlId" value="" placeholder="">
-                        <label for="hmcGplArtifactsDownloadUrlId"><?php echo $RES['initWizard.addNodes.gplArtifactsDownloadUrl.label'] ?></label>
-                        <input type="text" name="HmcGplArtifactsDownloadUrl" id="hmcGplArtifactsDownloadUrlId" value="" placeholder="">
                       </div>
                     </div>
                     <div id="fileUploadWrapperDivId">

+ 19 - 51
hmc/js/addNodes.js

@@ -13,18 +13,15 @@ InstallationWizard.AddNodes = {
        * needs to be done here.
        */
       if (globalYui.one("#yumMirrorSupportFormButtonId")) {
-        globalYui.one("#yumRepoFilePathId").set('value', '');
-        globalYui.one("#hmcArtifactsDownloadUrlId").set('value', '');
-        globalYui.one("#hmcGplArtifactsDownloadUrlId").set('value', '');
+        if (globalYui.one("#yumMirrorSupportFormButtonId").get('checked')) {
+          globalYui.one('#yumMirrorSupportFormFieldsId').setStyle('display', 'block');
+        } else {
+          globalYui.one('#yumMirrorSupportFormFieldsId').setStyle('display', 'none');
+          globalYui.one("#yumRepoFilePathId").set('value', '');
+        }
       }
       globalYui.one("#addNodesCoreDivId").setStyle('display', 'block');
 
-      if (globalYui.one("#yumMirrorSupportFormButtonId") && addNodesRenderData.yumRepo) {
-        globalYui.one("#yumRepoFilePathId").set('value', addNodesRenderData.yumRepo.yumRepoFilePath);
-        globalYui.one("#hmcArtifactsDownloadUrlId").set('value', addNodesRenderData.yumRepo.hdpArtifactsDownloadUrl);
-        globalYui.one("#hmcGplArtifactsDownloadUrlId").set('value', addNodesRenderData.yumRepo.gplArtifactsDownloadUrl);
-      }
-
       hideLoadingImg();
     }
 };
@@ -85,20 +82,11 @@ globalYui.one('#addNodesSubmitButtonId').on('click',function (e) {
     globalYui.one("#clusterHostsFileId").removeClass('formInputError');
   }
 
-  if (errCount != 0) {
-    globalYui.one(focusId).focus();
-    setFormStatus(message, true);
-    return;
-  }
-
   if (globalYui.one("#yumMirrorSupportFormButtonId")) {
     if (globalYui.one("#yumMirrorSupportFormButtonId").get('checked')) {
       // local yum mirror support
       var repoFile = globalYui.Lang.trim(globalYui.one("#yumRepoFilePathId").get('value'));
-      var artifactsUrl = globalYui.Lang.trim(globalYui.one("#hmcArtifactsDownloadUrlId").get('value'));
-      var gplArtifactsUrl = globalYui.Lang.trim(globalYui.one("#hmcGplArtifactsDownloadUrlId").get('value'));
-
-      if (repoFile = '') {
+      if (repoFile == '') {
         errCount++;
         if (focusId == '') {
           focusId = '#yumRepoFilePathId';
@@ -109,33 +97,15 @@ globalYui.one('#addNodesSubmitButtonId').on('click',function (e) {
         message += 'Yum Repo file not specified';
         globalYui.one("#yumRepoFilePathId").addClass('formInputError');
       }
-
-      if (artifactsUrl = '') {
-        errCount++;
-        if (focusId == '') {
-          focusId = '#hmcArtifactsDownloadUrlId';
-        }
-        if (message != '') {
-          message += '. ';
-        }
-        message += 'HDP Artifacts Download URL not specified';
-        globalYui.one("#hmcArtifactsDownloadUrlId").addClass('formInputError');
-      }
-
-      if (artifactsUrl = '') {
-        errCount++;
-        if (focusId == '') {
-          focusId = '#hmcGplArtifactsDownloadUrlId';
-        }
-        if (message != '') {
-          message += '. ';
-        }
-        message += 'GPL Artifacts Download URL not specified';
-        globalYui.one("#hmcGplArtifactsDownloadUrlId").addClass('formInputError');
-      }
     }
   }
 
+  if (errCount != 0) {
+    globalYui.one(focusId).focus();
+    setFormStatus(message, true);
+    return;
+  }
+
   clearFormStatus();
 
   showLoadingImg();
@@ -235,23 +205,20 @@ globalYui.one("#fileUploadTargetId").on('load', function (e) {
     doPostUpload = false;
     
     var repoFile = '';
-    var artifactsUrl = '';
-    var gplArtifactsUrl = '';
+    var localYumRepo = false;
 
     if (globalYui.one("#yumMirrorSupportFormButtonId")) {
       if (globalYui.one("#yumMirrorSupportFormButtonId").get('checked')) {
+        localYumRepo = true;
         // local yum mirror support
         repoFile = globalYui.Lang.trim(globalYui.one("#yumRepoFilePathId").get('value'));
-        artifactsUrl = globalYui.Lang.trim(globalYui.one("#hmcArtifactsDownloadUrlId").get('value'));
-        gplArtifactsUrl = globalYui.Lang.trim(globalYui.one("#hmcGplArtifactsDownloadUrlId").get('value'));
       }
     }
 
     var addNodesRequestData = {
       "ClusterDeployUser" : globalYui.Lang.trim(globalYui.one("#clusterDeployUserId").get('value')),
-      "yumRepoFilePath": repoFile,
-      "hdpArtifactsDownloadUrl" : artifactsUrl,
-      "gplArtifactsDownloadUrl": gplArtifactsUrl
+      "useLocalYumRepo" : localYumRepo,
+      "yumRepoFilePath": repoFile
     }
 
     // Trigger the execution of setting up nodes
@@ -274,7 +241,8 @@ globalYui.one("#fileUploadTargetId").on('load', function (e) {
           globalYui.log("PARSED DATA: " + globalYui.Lang.dump(setupNodesJson));
           if (setupNodesJson.result != 0) {
             // Error!
-            alert("Got error!" + setupNodesJson.error);
+            alert("Got error! " + setupNodesJson.error);
+            hideLoadingImg();
             return;
           }
           setupNodesJson = setupNodesJson.response;

+ 7 - 0
hmc/php/frontend/addNodes/bootstrap.php

@@ -20,6 +20,7 @@ include_once "../util/YumRepoConfigParser.php";
 
     $master=strtolower(exec('hostname -f'));
     $repoFile = $repo['yumRepoFilePath'];
+    $usingLocalRepo = $repo['usingLocalRepo'];
     $gpgKeyFiles = $repo['gpgKeyFiles'];
 
     exec ("/etc/init.d/iptables stop");
@@ -56,6 +57,10 @@ include_once "../util/YumRepoConfigParser.php";
     $rcmd = "/tmp/puppet_agent_install.sh --puppet-master=" . $master
         . " --repo-file=" . $remoteRepoFilePath
         . " --gpg-key-files=" . $remoteGpgKeyPaths;
+
+    if ("true" == strtolower($usingLocalRepo)) {
+        $rcmd .= " --using-local-repo ";
+    }
     $logger->log_info("Running $rcmd to bootstrap each node");
 
     runPdsh($clusterName, "bootstrapNodes", $user, $readFromFile, $rcmd);
@@ -109,6 +114,7 @@ if ($configs["result"] != 0) {
 }
 
 $repoFile = $configs["properties"]["yum_repo_file"];
+$usingLocalRepo = $configs["properties"]["using_local_repo"];
 $gpgKeyLocations = getEnabledGpgKeyLocations($repoFile);
 if ($gpgKeyLocations === FALSE) {
   $subTransactionReturnValue = $dbAccessor->updateSubTransactionOpStatus($clusterName, $parentSubTxnId, $mySubTxnId, "TOTALFAILURE");
@@ -164,6 +170,7 @@ foreach ($gpgKeyLocations as $repoId => $gpgInfo) {
 }
 
 $repository = array( "yumRepoFilePath" => $repoFile,
+                     "usingLocalRepo" => $usingLocalRepo,
                      "gpgKeyFiles" => $gpgKeyFiles);
 
 $logger->log_debug("BootStrapping with puppet");

+ 1 - 6
hmc/php/frontend/createCluster.php

@@ -148,13 +148,8 @@ $output = array(
                  "result" => $result,
                  "error" => $error,
                  "response" => array(
-                                 "clusterName" => $response["clusterName"],
-                                 "yumRepo" => array (
-                                   "yumRepoFilePath" => $propertiesArr["configs"]["yum_repo_file"]["value"],
-                                   "hdpArtifactsDownloadUrl" => $propertiesArr["configs"]["apache_artifacts_download_url"]["value"],
-                                   "gplArtifactsDownloadUrl" => $propertiesArr["configs"]["gpl_artifacts_download_url"]["value"]
+                                 "clusterName" => $response["clusterName"]
                         )
-                   ),
               );
 
 print (json_encode($output));

+ 13 - 21
hmc/php/frontend/nodesAction.php

@@ -29,9 +29,8 @@ if ($propertiesArr["result"] != 0) {
 // Override with current svc configs
 // Override with POST params
 
+$useLocalYumRepo = $propertiesArr["configs"]["using_local_repo"]["value"];
 $repoFilePath = $propertiesArr["configs"]["yum_repo_file"]["value"];
-$hdpArtifactsDownloadUrl = $propertiesArr["configs"]["apache_artifacts_download_url"]["value"];
-$gplArtifactsDownloadUrl = $propertiesArr["configs"]["gpl_artifacts_download_url"]["value"];
 
 $currentConfigs = $dbAccessor->getServiceConfig($clusterName);
 if ($currentConfigs["result"] != 0) {
@@ -41,19 +40,18 @@ if ($currentConfigs["result"] != 0) {
   return;
 }
 
+if (isset($currentConfigs["properties"]["using_local_repo"]) && 
+    $currentConfigs["properties"]["using_local_repo"] != "") {
+  $useLocalYumRepo = $currentConfigs["properties"]["using_local_repo"];
+}
+
 if (isset($currentConfigs["properties"]["yum_repo_file"])
     && $currentConfigs["properties"]["yum_repo_file"] != "") {
   $repoFilePath = $currentConfigs["properties"]["yum_repo_file"];
 }
 
-if (isset($currentConfigs["properties"]["apache_artifacts_download_url"])
-    && $currentConfigs["properties"]["apache_artifacts_download_url"] != "") {
-  $hdpArtifactsDownloadUrl = $currentConfigs["properties"]["apache_artifacts_download_url"];
-}
-
-if (isset($currentConfigs["properties"]["gpl_artifacts_download_url"])
-    && $currentConfigs["properties"]["gpl_artifacts_download_url"] != "") {
-  $gplArtifactsDownloadUrl = $currentConfigs["properties"]["gpl_artifacts_download_url"];
+if (isset($_POST['useLocalYumRepo']) && (trim($_POST['useLocalYumRepo']) != "")) {
+  $useLocalYumRepo = trim($_POST['useLocalYumRepo']);
 }
 
 if (isset($_POST['yumRepoFilePath'])
@@ -61,14 +59,9 @@ if (isset($_POST['yumRepoFilePath'])
   $repoFilePath = trim($_POST['yumRepoFilePath']);
 }
 
-if (isset($_POST['hdpArtifactsDownloadUrl'])
-    && trim($_POST['hdpArtifactsDownloadUrl']) != "") {
-  $hdpArtifactsDownloadUrl = trim($_POST['hdpArtifactsDownloadUrl']);
-}
-
-if (isset($_POST['gplArtifactsDownloadUrl'])
-    && trim($_POST['gplArtifactsDownloadUrl']) != "") {
-  $gplArtifactsDownloadUrl = trim($_POST['gplArtifactsDownloadUrl']);
+if ("true" != strtolower($useLocalYumRepo)) {
+  // Restore to default if we are not using the local repo
+  $repoFilePath = $propertiesArr["configs"]["yum_repo_file"]["value"];
 }
 
 header("Content-type: application/json");
@@ -99,9 +92,8 @@ if (parse_url($hdpArtifactsDownloadUrl) === FALSE
 }
 */
 
-$configs =  array ( "yum_repo_file" => $repoFilePath,
-                    "apache_artifacts_download_url" => $hdpArtifactsDownloadUrl,
-                    "gpl_artifacts_download_url" => $gplArtifactsDownloadUrl);
+$configs =  array ( "using_local_repo" => $useLocalYumRepo,
+                    "yum_repo_file" => $repoFilePath);
 $dbResponse = $dbAccessor->updateServiceConfigs($clusterName, $configs);
 if ($dbResponse["result"] != 0) {
   $logger->log_error("Got error while persisting configs: ".$dbResponse["error"]);