Skip to content

Commit

Permalink
Ignore stdout/stderr messages before "yum history list"
Browse files Browse the repository at this point in the history
Yum stderr logs as "Warning: RPMDB modified outside of yum."
are appended to the SSH output which completely breaks the history parsing.
To solve this problem, we need to skip all log lines before transactions.

Signed-off-by: Ronan Abhamon <ronan.abhamon@vates.fr>
  • Loading branch information
Wescoeur authored and benjamreis committed Jul 31, 2023
1 parent 7bdde03 commit 81db96b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,19 @@ def get_last_yum_history_tid(self):
history_str = self.ssh(['yum', 'history', 'list', '--noplugins'])

history = history_str.splitlines()
line_index = None
for i in range(len(history)):
if history[i].startswith('--------'):
line_index = i
break

if line_index is None:
raise Exception('Unable to get yum transactions')

try:
return int(history[2].split()[0])
return int(history[line_index + 1].split()[0])
except ValueError:
raise Exception('Unable to parse correctly last yum history tid. Output\n:' + history_str)
raise Exception('Unable to parse correctly last yum history tid. Output:\n' + history_str)

def yum_install(self, packages, enablerepo=None):
logging.info('Install packages: %s on host %s' % (' '.join(packages), self))
Expand Down

0 comments on commit 81db96b

Please sign in to comment.