Skip to content

Commit

Permalink
Fix: utils: A workaround for the truncating issue (bsc#1205925)
Browse files Browse the repository at this point in the history
When python program calling cibsecret with a small terminal width,
the command `ps -ef | grep '[p]acemaker-controld'` will return 1

>>> cmd = "ps -ef | grep '[p]acemaker-controld' >/dev/null"
>>> # When terminal width is small
>>> subprocess.call(cmd, shell=True)
1
>>> # When terminal is big enough
>>> subprocess.call(cmd, shell=True)
0

Set a large terminal width could be a workaround

See also: ClusterLabs/pacemaker#3384
  • Loading branch information
liangxin1300 committed Mar 7, 2024
1 parent 21cbb9e commit b3dc359
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions crmsh/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@
REJOIN_COUNT = 60
REJOIN_INTERVAL = 10
DC_DEADTIME_DEFAULT = 20
TERMINAL_MAX_WIDTH = '500'

ADVISED_ACTION_LIST = ['monitor', 'start', 'stop', 'promote', 'demote']
ADVISED_KEY_LIST = ['timeout', 'interval', 'role']
Expand Down
4 changes: 3 additions & 1 deletion crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,9 @@ def ext_cmd(cmd, shell=True):
if options.regression_tests:
print(".EXT", cmd)
logger.debug("invoke: %s", cmd)
return subprocess.call(cmd, shell=shell)
env = os.environ.copy()
env["COLORTERM"] = constants.TERMINAL_MAX_WIDTH
return subprocess.call(cmd, shell=shell, env=env)


def ext_cmd_nosudo(cmd, shell=True):
Expand Down

0 comments on commit b3dc359

Please sign in to comment.