incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1361002 - in /incubator/ambari/trunk: ./ hmc/html/ hmc/html/upgradeStack/ hmc/js/ hmc/js/upgradeStack/ hmc/php/frontend/
Date Thu, 12 Jul 2012 23:41:08 GMT
Author: yusaku
Date: Thu Jul 12 23:41:07 2012
New Revision: 1361002

URL: http://svn.apache.org/viewvc?rev=1361002&view=rev
Log:
AMBARI-634. Force redirect to the 'upgrade progress' page to prevent any other actions during
Hadoop stack upgrade (Contributed by yusaku)

Added:
    incubator/ambari/trunk/hmc/php/frontend/upgradeStack.php
Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/hmc/html/_router.php
    incubator/ambari/trunk/hmc/html/upgradeStack/index.php
    incubator/ambari/trunk/hmc/js/clustersList.js
    incubator/ambari/trunk/hmc/js/upgradeStack/index.js
    incubator/ambari/trunk/hmc/js/upgradeStack/showUpgradeProgress.js
    incubator/ambari/trunk/hmc/php/frontend/deployForUpgrade.php
    incubator/ambari/trunk/hmc/php/frontend/listClusters.php
    incubator/ambari/trunk/hmc/php/frontend/uninstallForUpgrade.php

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Jul 12 23:41:07 2012
@@ -12,6 +12,9 @@ Trunk (unreleased changes)
 
   NEW FEATURES
 
+    AMBARI-634. Force redirect to the "upgrade progress" page to prevent any
+    other actions during Hadoop stack upgrade (yusaku)
+
     AMBARI-628. hdp-nagios and hdp-monitoring has wrong configuration file
     location, also owner:group permissions are wrong.
 

Modified: incubator/ambari/trunk/hmc/html/_router.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/html/_router.php?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/html/_router.php (original)
+++ incubator/ambari/trunk/hmc/html/_router.php Thu Jul 12 23:41:07 2012
@@ -33,21 +33,11 @@ require_once $BASE_DIR.'/../php/util/loc
 require_once $BASE_DIR.'/../php/db/HMCDBAccessor.php';
 require_once $BASE_DIR.'/../php/util/clusterState.php';
 
-/*
- * Due to the way include files are scoped,
- * we return the string to be eval'd, rather than
- * executing them.
- */
-function redirectToPage($requestPage, $targetPage)
-{
+
+function redirectToPage($requestPage, $targetPage) {
   $bypassRouter = $GLOBALS['BYPASS_ROUTER'] || (isset($_GET['bypassRouter']) && $_GET['bypassRouter']);
   if (!$bypassRouter) {
-    // if the page is index.php or the root app directory, don't redirect... simply include
-    if ($requestPage != 'index.php' && $requestPage != 'html') {
-      return "header('Location: /hmc/html/$targetPage'); exit;";
-    } else {
-      return "require('$targetPage'); exit;";
-    }
+    return "header('Location: /hmc/html/$targetPage'); exit;";
   } else {
     // do not redirect/forward.  fall through
     return "";
@@ -85,7 +75,7 @@ if (sizeof($clusters) == 0) {
         break;
       case 'DEPLOYED':
         if ($state['context']['status']) {
-          if ($requestPage == 'initializeCluster.php') {
+          if ($requestPage == 'initializeCluster.php' || $requestPage == 'welcome.php') {
             eval(redirectToPage($requestPage, 'index.php'));
           }
           $clusterState = 'OPERATIONAL';
@@ -127,26 +117,10 @@ if (sizeof($clusters) == 0) {
         }
         $clusterState = 'UNINSTALL_FAILED';
         break;
+      case 'UPGRADE_STACK_STARTED':
       case 'UPGRADE_STACK_UNINSTALL_IN_PROGRESS':
-        if ($requestPage != 'upgradeStack/showUpgradeProgress.php') {
-          eval(redirectToPage($requestPage, 'upgradeStack/showUpgradeProgress.php'));
-        }
-        break;
       case 'UPGRADE_STACK_UNINSTALL_FAILED':
-        if ($requestPage != 'upgradeStack/showUpgradeProgress.php') {
-          eval(redirectToPage($requestPage, 'upgradeStack/showUpgradeProgress.php'));
-        }
-        break;
-      case 'UPGRADE_STACK_UNINSTALLED':
-        if ($requestPage != 'upgradeStack/showUpgradeProgress.php') {
-          eval(redirectToPage($requestPage, 'upgradeStack/showUpgradeProgress.php'));
-        }
-        break;
       case 'UPGRADE_STACK_DEPLOY_IN_PROGRESS':
-        if ($requestPage != 'upgradeStack/showUpgradeProgress.php') {
-          eval(redirectToPage($requestPage, 'upgradeStack/showUpgradeProgress.php'));
-        }
-        break;
       case 'UPGRADE_STACK_DEPLOY_FAILED':
         if ($requestPage != 'upgradeStack/showUpgradeProgress.php') {
           eval(redirectToPage($requestPage, 'upgradeStack/showUpgradeProgress.php'));

Modified: incubator/ambari/trunk/hmc/html/upgradeStack/index.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/html/upgradeStack/index.php?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/html/upgradeStack/index.php (original)
+++ incubator/ambari/trunk/hmc/html/upgradeStack/index.php Thu Jul 12 23:41:07 2012
@@ -37,9 +37,9 @@
       <div id="pageContent" style="margin:40px 0 0 40px">
         <fieldset>
           <form id="upgradeStackForm" enctype="multipart/form-data" method="post">
-            <input type="hidden" name="ClusterDeployUser" id="ClusterDeployUser" value="root">
-            <label for="clusterDeployUserIdentityFile"><?php echo $RES['common.sshPrivateKeyFile.label']
?></label>
-            <input type="file" name="clusterDeployUserIdentityFile" id="clusterDeployUserIdentityFile"
value="" placeholder="">
+            <input type="hidden" name="sshUser" id="sshUser" value="root">
+            <label for="sshPrivateKeyFile"><?php echo $RES['common.sshPrivateKeyFile.label']
?></label>
+            <input type="file" name="sshPrivateKeyFile" id="sshPrivateKeyFile" value=""
placeholder="">
             <div class="separator"></div>
             <div id="fileUploadWrapper">
               <iframe name="fileUploadTarget" id="fileUploadTarget" src="about:blank"
style="display:none"></iframe>

Modified: incubator/ambari/trunk/hmc/js/clustersList.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/clustersList.js?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/clustersList.js (original)
+++ incubator/ambari/trunk/hmc/js/clustersList.js Thu Jul 12 23:41:07 2012
@@ -154,7 +154,7 @@ function ClustersList() {
               var clusterName; var clusterInfo;
               for (clusterId in clusterListInfoJson) {
                 clusterName = clusterId;
-                clusterInfo = Y.JSON.parse(clusterListInfoJson[clusterName]);
+                clusterInfo = clusterListInfoJson[clusterName];
                 Y.log( "Cluster Info: " + Y.Lang.dump(clusterInfo.displayName));
               }
             }

Modified: incubator/ambari/trunk/hmc/js/upgradeStack/index.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/upgradeStack/index.js?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/upgradeStack/index.js (original)
+++ incubator/ambari/trunk/hmc/js/upgradeStack/index.js Thu Jul 12 23:41:07 2012
@@ -26,13 +26,13 @@
     var message = '';
     var errorCount = 0;
 
-    var fileName = $('#clusterDeployUserIdentityFile').val();
+    var fileName = $('#sshPrivateKeyFile').val();
     if (fileName == '') {
       message += 'SSH Private Key File not specified';
-      $('#clusterDeployUserIdentityFile').addClass('formInputError');
+      $('#sshPrivateKeyFile').addClass('formInputError');
       errorCount++;
     } else {
-      $('#clusterDeployUserIdentityFile').removeClass('formInputError');
+      $('#sshPrivateKeyFile').removeClass('formInputError');
     }
 
     if (errorCount > 0) {
@@ -64,8 +64,9 @@
 
         var form = $('#upgradeStackForm');
 
-        // addNodes.php handles ssh key upload and save
-        form.attr('action', '/hmc/php/frontend/addNodes.php?clusterName=' +
+        // upgradeStack.php handles ssh key upload and also triggers
+        // the upgrade process
+        form.attr('action', '/hmc/php/frontend/upgradeStack.php?clusterName=' +
           App.props.clusterName);
 
         form.attr('target', 'fileUploadTarget');

Modified: incubator/ambari/trunk/hmc/js/upgradeStack/showUpgradeProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/upgradeStack/showUpgradeProgress.js?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/upgradeStack/showUpgradeProgress.js (original)
+++ incubator/ambari/trunk/hmc/js/upgradeStack/showUpgradeProgress.js Thu Jul 12 23:41:07
2012
@@ -178,7 +178,36 @@
 
   }
 
-  uninstallStack();
+  function checkClusterState() {
+    $.ajax({
+      type: 'GET',
+      url: '/hmc/php/frontend/listClusters.php',
+      data: {},
+      dataType: 'json',
+      timeout: App.io.DEFAULT_AJAX_TIMEOUT_MS,
+      success: function (data) {
+        var clusterState = data.response[App.props.clusterName].state;
+        switch (clusterState) {
+          case 'UPGRADE_STACK_STARTED':
+          case 'UPGRADE_STACK_UNINSTALL_IN_PROGRESS':
+          case 'UPGRADE_STACK_UNINSTALL_FAILED':
+            uninstallStack();
+            break;
+          case 'UPGRADE_STACK_UNINSTALLED':
+          case 'UPGRADE_STACK_DEPLOY_IN_PROGRESS':
+          case 'UPGRADE_STACK_DEPLOY_FAILED':
+          case 'DEPLOYED':
+            deployStack();
+            break;
+        }
+      },
+      error: function (data) {
+        alert(App.io.DEFAULT_AJAX_ERROR_MESSAGE);
+      }
+    });
+  }
+
+  checkClusterState();
 
 })();
 

Modified: incubator/ambari/trunk/hmc/php/frontend/deployForUpgrade.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/frontend/deployForUpgrade.php?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/php/frontend/deployForUpgrade.php (original)
+++ incubator/ambari/trunk/hmc/php/frontend/deployForUpgrade.php Thu Jul 12 23:41:07 2012
@@ -87,12 +87,9 @@ if (($clusterState['state'] == 'UPGRADE_
   }
 }
 /* In case the deploy is already running or has ended, just return the txnId 
- * from the DB instead of kicking off a fresh deploy - this is so we can use
- * this entrypoint to show the cluster's deploy progress at any time in the
- * future, not just during a live deploy. 
+ * from the DB
  */
-elseif (($clusterState['state'] == 'UPGRADE_STACK_DEPLOY_IN_PROGRESS') ||
-        ($clusterState['state'] == 'DEPLOYED')) {
+else {
 
   $txnId = $clusterState['context']['txnId'];
 }

Modified: incubator/ambari/trunk/hmc/php/frontend/listClusters.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/frontend/listClusters.php?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/php/frontend/listClusters.php (original)
+++ incubator/ambari/trunk/hmc/php/frontend/listClusters.php Thu Jul 12 23:41:07 2012
@@ -45,7 +45,7 @@ if ($allClustersResult["result"] != 0) {
 
 foreach($allClustersResult["clusters"] as $clusterId => $value) {
   $logger->log_debug("Got cluster ".$clusterId.json_encode($value));
-  $listOfClusters[$value["clusterName"]] = $value["state"];
+  $listOfClusters[$value["clusterName"]] = json_decode($value["state"]);
 }
 
 $response["response"] = $listOfClusters;

Modified: incubator/ambari/trunk/hmc/php/frontend/uninstallForUpgrade.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/frontend/uninstallForUpgrade.php?rev=1361002&r1=1361001&r2=1361002&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/php/frontend/uninstallForUpgrade.php (original)
+++ incubator/ambari/trunk/hmc/php/frontend/uninstallForUpgrade.php Thu Jul 12 23:41:07 2012
@@ -54,10 +54,10 @@ if ($clusterStateResponse['result'] != 0
 
 $clusterState = json_decode($clusterStateResponse['state'], true);
 
-/* Run an actual uninstall for upgrade only if this cluster is in a deployed state
+/* Run uninstall for upgrade only if this cluster is in a deployed state
  * (regardless of whether the deploy was a success or failure). 
  */
-if ($clusterState['state'] == 'DEPLOYED') {
+if ($clusterState['state'] == 'UPGRADE_STACK_STARTED') {
 
   $logger->log_info("Uninstall invoked");
 
@@ -118,12 +118,9 @@ if ($clusterState['state'] == 'DEPLOYED'
   }
 }
 /* In case the uninstall is already running or has ended, just return the txnId 
- * and deployUser from the DB instead of kicking off a fresh uninstall - this 
- * is so we can use this entrypoint to show the cluster's uninstall progress at 
- * any time in the future, not just during a live uninstall. 
+ * and deployUser from the DB
  */
-elseif ($clusterState['state'] == 'UPGRADE_STACK_UNINSTALL_IN_PROGRESS') {
-
+else {
   $txnId = $clusterState['context']['txnId'];
   $deployUser = $clusterState['context']['deployUser'];
 }

Added: incubator/ambari/trunk/hmc/php/frontend/upgradeStack.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/frontend/upgradeStack.php?rev=1361002&view=auto
==============================================================================
--- incubator/ambari/trunk/hmc/php/frontend/upgradeStack.php (added)
+++ incubator/ambari/trunk/hmc/php/frontend/upgradeStack.php Thu Jul 12 23:41:07 2012
@@ -0,0 +1,75 @@
+<?php
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+
+include_once '../util/Logger.php';
+include_once '../conf/Config.inc';
+include_once 'localDirs.php';
+include_once "../util/lock.php";
+include_once '../db/HMCDBAccessor.php';
+include_once "../util/clusterState.php";
+include_once '../util/util.php';
+
+include_once './commandUtils.php';
+/*
+sleep(3);
+ */
+
+$logger = new HMCLogger("UpgradeStack");
+$dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+
+$clusterName = $_GET['clusterName'];
+
+// Remove the cluster directory before copying the files
+$clusterDir = getClusterDir($clusterName);
+rrmdir($clusterDir);
+if (!is_dir($clusterDir) && !mkdir($clusterDir, 0700, true)) {
+  print json_encode(array( "result" => 1, "error" => 'Failed to create directory...'));
+  return;
+}
+// end of directory removal
+
+$keyFileDestination = getSshKeyFilePath($clusterName);
+
+if (move_uploaded_file($_FILES['sshPrivateKeyFile']['tmp_name'], $keyFileDestination)) {
+    //echo "File is valid, and was successfully uploaded.\n";
+
+  // Set the permissions
+  chmod($keyFileDestination, 0400);
+  // TODO: Error conditions
+} else {
+  $logger->log_error("SSH key file copy to destination ".$keyFileDestination." failed");
+}
+
+$resp = updateClusterState($clusterName, 'UPGRADE_STACK_STARTED', 'Upgrade Stack - Started',
array());
+if ($resp['result'] != 0) {
+  print json_encode($resp);
+  return;
+}
+$clusterState = json_decode($resp['state'], true);
+$dbAccessor->
+
+header("Content-type: application/json");
+
+print (json_encode(array("result" => 0)));
+
+?>



Mime
View raw message