Skip to content

Commit

Permalink
Fix error handling when Agent has no sudo access (DataDog#8470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florimond Manca authored Jan 27, 2021
1 parent 0123c38 commit effeb0f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions glusterfs/datadog_checks/glusterfs/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def __init__(self, name, init_config, instances):

def check(self, _):
if self.use_sudo:
test_sudo, err, rcode = get_subprocess_output(['sudo', '-ln', self.gstatus_cmd], self.log)
if rcode != 0:
raise Exception('The dd-agent user does not have sudo access: %s', err or test_sudo)
test_sudo, err, rcode = get_subprocess_output(
['sudo', '-ln', self.gstatus_cmd], self.log, raise_on_empty_output=False
)
if rcode != 0 or not test_sudo:
raise Exception('The dd-agent user does not have sudo access: {!r}'.format(err or test_sudo))
gluster_args = 'sudo {}'.format(self.gstatus_cmd)
else:
gluster_args = self.gstatus_cmd
Expand Down

0 comments on commit effeb0f

Please sign in to comment.