You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/12/02 20:26:10 UTC

[12/50] [abbrv] ambari git commit: AMBARI-19023. After adding an Atlas server the first restart command fails since stop doesn't have any configs; if no pid dir exists during stop, perform no-op (alejandro)

AMBARI-19023. After adding an Atlas server the first restart command fails since stop doesn't have any configs; if no pid dir exists during stop, perform no-op (alejandro)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/15f843bb
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/15f843bb
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/15f843bb

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 15f843bbb0679d93f836c0fa4a3b23370b1ae91c
Parents: 72b940e
Author: Alejandro Fernandez <af...@hortonworks.com>
Authored: Tue Nov 29 17:10:16 2016 -0800
Committer: Alejandro Fernandez <af...@hortonworks.com>
Committed: Wed Nov 30 13:48:07 2016 -0800

----------------------------------------------------------------------
 .../0.1.0.2.3/package/scripts/metadata_server.py  | 18 ++++++++++++++++++
 .../stacks/2.3/ATLAS/test_metadata_server.py      |  5 ++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/15f843bb/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py b/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
index a469ebb..36d990d 100644
--- a/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
+++ b/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
@@ -16,6 +16,10 @@ See the License for the specific language governing permissions and
 limitations under the License.
 
 """
+# Python Imports
+import os
+
+# Local Imports
 from metadata import metadata
 from resource_management import Fail
 from resource_management.libraries.functions import conf_select, stack_select
@@ -124,6 +128,20 @@ class MetadataServer(Script):
     env.set_params(params)
     daemon_cmd = format('source {params.conf_dir}/atlas-env.sh; {params.metadata_stop_script}')
 
+    # If the pid dir doesn't exist, this means either
+    # 1. The user just added Atlas service and issued a restart command (stop+start). So stop should be a no-op
+    # since there's nothing to stop.
+    # OR
+    # 2. The user changed the value of the pid dir config and incorrectly issued a restart command.
+    # In which case the stop command cannot do anything since Ambari doesn't know which process to kill.
+    # The start command will spawn another instance.
+    # The user should have issued a stop, changed the config, and then started it.
+    if not os.path.isdir(params.pid_dir):
+      Logger.info("*******************************************************************")
+      Logger.info("Will skip the stop command since this is the first time stopping/restarting Atlas "
+                  "and the pid dir does not exist, %s\n" % params.pid_dir)
+      return
+
     try:
       Execute(daemon_cmd,
               user=params.metadata_user,

http://git-wip-us.apache.org/repos/asf/ambari/blob/15f843bb/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py b/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
index 585dc94..f2fec70 100644
--- a/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
+++ b/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
@@ -366,7 +366,10 @@ class TestMetadataServer(RMFTestCase):
                               user = 'atlas',
     )
 
-  def test_stop_default(self):
+  @patch('os.path.isdir')
+  def test_stop_default(self, is_dir_mock):
+    is_dir_mock.return_value = True
+
     self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/metadata_server.py",
                        classname = "MetadataServer",
                        command = "stop",