From 9036d641ce09990d778d00cdfdc6a51d2043a8ef Mon Sep 17 00:00:00 2001 From: Peng Lu Date: Fri, 8 Nov 2024 10:08:47 +0800 Subject: [PATCH 1/3] There will be failure when executing shell.py --- .../src/main/python/resource_management/core/shell.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ambari-common/src/main/python/resource_management/core/shell.py b/ambari-common/src/main/python/resource_management/core/shell.py index 045ce383cc1..e24df14e832 100644 --- a/ambari-common/src/main/python/resource_management/core/shell.py +++ b/ambari-common/src/main/python/resource_management/core/shell.py @@ -105,7 +105,7 @@ def checked_call(command, quiet=False, logoutput=None, stdout=subprocess.PIPE,st @log_function_call def call(command, quiet=False, logoutput=None, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, cwd=None, env=None, preexec_fn=preexec_fn, user=None, wait_for_finish=True, timeout=None, on_timeout=None, - path=None, sudo=False, on_new_line=None, tries=1, try_sleep=0, timeout_kill_strategy=TerminateStrategy.TERMINATE_PARENT, returns=[0]): + path=None, sudo=False, on_new_line=None, tries=1, try_sleep=0, timeout_kill_strategy=TerminateStrategy.TERMINATE_PARENT, shell=True, returns=[0]): """ Execute the shell command despite failures. @return: return_code, output @@ -213,11 +213,8 @@ def _call(command, logoutput=None, throw_on_failure=True, stdout=subprocess.PIPE # replace placeholder from as_sudo / as_user if present env_str = _get_environment_str(env) for placeholder, replacement in PLACEHOLDERS_TO_STR.items(): - command = command.replace(placeholder, replacement.format(env_str=env_str)) subprocess_command = [cmd.replace(placeholder, replacement.format(env_str=env_str)) for cmd in subprocess_command] - # --noprofile is used to preserve PATH set for ambari-agent - subprocess_command = ["/bin/bash","--login","--noprofile","-c", command] if shell: # --noprofile is used to preserve PATH set for ambari-agent subprocess_command = ["/bin/bash","--login","--noprofile","-c"] + subprocess_command From 4df579db7f2b457e82ccfa8945d513b4de1c5725 Mon Sep 17 00:00:00 2001 From: Peng Lu Date: Fri, 8 Nov 2024 15:27:44 +0800 Subject: [PATCH 2/3] Wrong order of imports for WidgetResourceProvider.java --- .../server/controller/internal/WidgetResourceProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java index 3b4b5c90695..f29b2c0c5c3 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java @@ -56,10 +56,10 @@ import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonSerializer; import com.google.gson.JsonElement; -import com.google.gson.JsonSerializationContext; import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; import com.google.inject.Inject; /** From a5438f296fac0f2f546fd141accfe0f5ea6b7e16 Mon Sep 17 00:00:00 2001 From: Peng Lu Date: Fri, 8 Nov 2024 18:03:55 +0800 Subject: [PATCH 3/3] Fix issue of test failure --- .../src/main/resources/custom_actions/scripts/check_host.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 3e0871727c4..1f5eac7acfd 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 @@ -454,7 +454,10 @@ def execute_db_connection_check(self, config, tmp_dir): db_connection_check_command = "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{0}{1} {2}".format(agent_cache_dir, LIBS_PATH_IN_ARCHIVE_SQLA, db_connection_check_command) - code, out = shell.call(split(db_connection_check_command, comments=True), shell=False) + if isinstance(db_connection_check_command, str): + code, out = shell.call(split(db_connection_check_command, comments=True), shell=False) + else: + code, out = shell.call(db_connection_check_command, shell=False) if code == 0: db_connection_check_structured_output = {"exit_code" : 0, "message": "DB connection check completed successfully!" }