Skip to content

Commit

Permalink
AMBARI-25518: DB connection details in API calls (#3531)
Browse files Browse the repository at this point in the history
  • Loading branch information
timyuer committed Nov 19, 2022
1 parent c787037 commit 778752c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
1 change: 0 additions & 1 deletion ambari-agent/src/main/python/ambari_agent/HostInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ def javaProcs(self, list):
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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ public void deserializeClasses() {
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 +
Expand Down Expand Up @@ -266,7 +266,6 @@ public void deserializeClasses() {
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(
Expand Down
17 changes: 9 additions & 8 deletions ambari-server/src/test/python/TestSetupSso.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ def search_file_proxy(filename, searchpatch, pathsep=os.pathsep):
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")
Expand Down
16 changes: 6 additions & 10 deletions ambari-web/app/mixins/main/host/details/actions/check_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 778752c

Please sign in to comment.