You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by wu...@apache.org on 2022/11/19 17:01:24 UTC

[ambari] branch trunk updated: AMBARI-25518: DB connection details in API calls (#3531)

This is an automated email from the ASF dual-hosted git repository.

wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 778752c959 AMBARI-25518: DB connection details in API calls (#3531)
778752c959 is described below

commit 778752c95911b282f018ce6275fdad25f5219f02
Author: Yu Hou <52...@qq.com>
AuthorDate: Sun Nov 20 01:01:17 2022 +0800

    AMBARI-25518: DB connection details in API calls (#3531)
---
 ambari-agent/src/main/python/ambari_agent/HostInfo.py   |  1 -
 .../apache/ambari/server/agent/AgentResourceTest.java   |  5 ++---
 ambari-server/src/test/python/TestSetupSso.py           | 17 +++++++++--------
 .../app/mixins/main/host/details/actions/check_host.js  | 16 ++++++----------
 4 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 7bb4ac1b58..27329d095d 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -262,7 +262,6 @@ class HostInfoLinux(HostInfo):
             for filter in self.PROC_FILTER:
               if filter in cmd:
                 metrics['hadoop'] = True
-            metrics['command'] = unicode(cmd.strip(), errors='ignore')
             for line in open(os.path.join('/proc', pid, 'status')):
               if line.startswith('Uid:'):
                 uid = int(line.split()[1])
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
index fbcc7c88b7..acc1168070 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
@@ -236,8 +236,8 @@ public class AgentResourceTest extends RandomPortJerseyTest {
     String PackageDetailJSON = "[{name:'abc', version:'2.3', repoName:'HDP'},{name:'abc', version:'3.3', repoName:'HDP-epel'}]";
     String ExistingUserJSON = "[{name:'hdfs', homeDir:'/var/lib/hadoop', status:''}, " +
             "{name:'ambari_qa', homeDir:'/var/home/ambari_qa',status:'None'}]";
-    String JavaProcJSON = "[{user:'root', pid:'355', hadoop:'True', command:'cmd'}, " +
-            "{user:'hdfs', pid:'325', hadoop:'False', command:'cmd = 2'}]";
+    String JavaProcJSON = "[{user:'root', pid:'355', hadoop:'True'}, " +
+            "{user:'hdfs', pid:'325', hadoop:'False'}]";
     String AlternativeJSON = "[{name:'/etc/alternatives/hdfs-conf', target:'/etc/hadoop/conf.dist'}, " +
             "{name:'abc', target:'def'}]";
     String AgentEnvJSON = "{\"alternatives\": " + AlternativeJSON +
@@ -266,7 +266,6 @@ public class AgentResourceTest extends RandomPortJerseyTest {
         JavaProcJSON, AgentEnv.JavaProc[].class);
     Assert.assertEquals("root", procs[0].getUser());
     Assert.assertEquals(355, procs[0].getPid());
-    Assert.assertEquals("cmd = 2", procs[1].getCommand());
     Assert.assertEquals(false, procs[1].isHadoop());
 
     AgentEnv.Alternative[] alternatives = getJsonFormString(
diff --git a/ambari-server/src/test/python/TestSetupSso.py b/ambari-server/src/test/python/TestSetupSso.py
index b708587426..54b745b38f 100644
--- a/ambari-server/src/test/python/TestSetupSso.py
+++ b/ambari-server/src/test/python/TestSetupSso.py
@@ -64,14 +64,15 @@ with patch.object(platform, "linux_distribution", return_value = MagicMock(retur
       with patch.object(os_utils, "parse_log4j_file", return_value={'ambari.log.dir': '/var/log/ambari-server'}):
         with patch("platform.linux_distribution", return_value = os_distro_value):
           with patch("os.symlink"):
-            with patch("glob.glob", return_value = ['/etc/init.d/postgresql-9.3']):
-              _ambari_server_ = __import__('ambari-server')
-              with patch("__builtin__.open"):
-                from ambari_commons.exceptions import FatalException, NonFatalException
-                from ambari_server.properties import Properties
-                from ambari_server.setupSso import setup_sso, AMBARI_SSO_AUTH_ENABLED, \
-                  SSO_PROVIDER_URL, SSO_CERTIFICATE, JWT_COOKIE_NAME, JWT_AUDIENCES, \
-                  SSO_ENABLED_SERVICES, SSO_MANAGE_SERVICES
+            with patch.object(os_utils, "is_service_exist", return_value = True):
+              with patch("glob.glob", return_value = ['/etc/init.d/postgresql-9.3']):
+                _ambari_server_ = __import__('ambari-server')
+                with patch("__builtin__.open"):
+                  from ambari_commons.exceptions import FatalException, NonFatalException
+                  from ambari_server.properties import Properties
+                  from ambari_server.setupSso import setup_sso, AMBARI_SSO_AUTH_ENABLED, \
+                    SSO_PROVIDER_URL, SSO_CERTIFICATE, JWT_COOKIE_NAME, JWT_AUDIENCES, \
+                    SSO_ENABLED_SERVICES, SSO_MANAGE_SERVICES
 
 class TestSetupSso(unittest.TestCase):
   @patch("ambari_server.setupSso.is_server_runing")
diff --git a/ambari-web/app/mixins/main/host/details/actions/check_host.js b/ambari-web/app/mixins/main/host/details/actions/check_host.js
index 5eff19f31e..604adde7af 100644
--- a/ambari-web/app/mixins/main/host/details/actions/check_host.js
+++ b/ambari-web/app/mixins/main/host/details/actions/check_host.js
@@ -617,17 +617,15 @@ App.CheckHostMixin = Em.Mixin.create({
             warning.hosts.push(hostName);
             warning.hostsLong.push(hostName);
           } else {
+            var command = 'pid=' + process.pid + ', user=' + process.user;
             warningCategories.processesWarnings[process.pid] = warning = {
-              name: (process.command.substr(0, 35) + '...'),
+              name: command.length > 36 ? (command.substr(0, 35) + '...') : command,
               hosts: [hostName],
               hostsLong: [hostName],
               category: 'processes',
               user: process.user,
               pid: process.pid,
-              command: '<table><tr><td style="word-break: break-all;">' +
-              ((process.command.length < 500) ? process.command : process.command.substr(0, 230) + '...' +
-              '<p style="text-align: center">................</p>' +
-              '...' + process.command.substr(-230)) + '</td></tr></table>'
+              command: command
             };
           }
           host.warnings.push(warning);
@@ -851,17 +849,15 @@ App.CheckHostMixin = Em.Mixin.create({
             warning.hosts.push(_host.Hosts.host_name);
             warning.hostsLong.push(_host.Hosts.host_name);
           } else {
+            var command = 'pid=' + process.pid + ', user=' + process.user;
             warningCategories.processesWarnings[process.pid] = warning = {
-              name: (process.command.substr(0, 35) + '...'),
+              name: command.length > 36 ? (command.substr(0, 35) + '...') : command,
               hosts: [_host.Hosts.host_name],
               hostsLong: [_host.Hosts.host_name],
               category: 'processes',
               user: process.user,
               pid: process.pid,
-              command: '<table><tr><td style="word-break: break-all;">' +
-              ((process.command.length < 500) ? process.command : process.command.substr(0, 230) + '...' +
-              '<p style="text-align: center">................</p>' +
-              '...' + process.command.substr(-230)) + '</td></tr></table>'
+              command: command
             };
           }
           host.warnings.push(warning);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ambari.apache.org
For additional commands, e-mail: commits-help@ambari.apache.org