Skip to content

Commit

Permalink
Fix: scripts: health: failed to extract report when it is compressed …
Browse files Browse the repository at this point in the history
…in bz2 (#1595)
  • Loading branch information
liangxin1300 authored Oct 28, 2024
2 parents 45c1225 + 8039ac6 commit 94635ab
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scripts/health/hahealth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3
import glob
import os
import crm_script as crm

Expand All @@ -22,16 +23,24 @@ def create_report():


if not create_report():
crm.exit_fail({'status': 'Failed to create report'})
crm.exit_fail('Failed to create report')


def extract_report():
rc, out, err = crm.call(['tar', 'xzf', 'health-report.tar.gz'], shell=False)
path = None
compressed_tars = glob.glob('health-report.tar.*')
if compressed_tars:
path = compressed_tars[0]
elif os.access('health-report.tar', os.F_OK | os.R_OK):
path = 'health-report.tar'
else:
crm.exit_fail('Failed to extract report: file not found.')
rc, out, err = crm.call(['tar', '-xf', path], shell=False)
return rc == 0


if not extract_report():
crm.exit_fail({'status': 'Failed to extract report'})
crm.exit_fail('Failed to extract report')

analysis = ''
if os.path.isfile('health-report/analysis.txt'):
Expand Down

0 comments on commit 94635ab

Please sign in to comment.