From 683d1932ac0b2865d0b9db2d73f31e199d9a590e Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 21 Nov 2019 11:47:52 +1300 Subject: [PATCH] have replayed curtin runs create a log file too --- scripts/replay-curtin-log.py | 23 ++++++++++++++--------- subiquity/controllers/error.py | 4 +++- subiquity/controllers/installprogress.py | 10 +++++++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/scripts/replay-curtin-log.py b/scripts/replay-curtin-log.py index ee1f5baf..bcefea2c 100644 --- a/scripts/replay-curtin-log.py +++ b/scripts/replay-curtin-log.py @@ -9,6 +9,7 @@ from systemd import journal json_file = sys.argv[1] event_identifier = sys.argv[2] +log_location = sys.argv[3] scale_factor = float(os.environ.get('SUBIQUITY_REPLAY_TIMESCALE', "4")) @@ -17,7 +18,7 @@ def time_for_entry(e): rc = 0 -def report(e): +def report(e, log_file): global rc if e['SYSLOG_IDENTIFIER'].startswith("curtin_event"): e['SYSLOG_IDENTIFIER'] = event_identifier @@ -30,13 +31,17 @@ def report(e): rc = 1 elif e['SYSLOG_IDENTIFIER'].startswith("curtin_log") and scale_factor < 10: print(e['MESSAGE'], flush=True) + log_file.write(e['MESSAGE'] + '\n') + +with open(log_location, 'w') as fp: + prev_ev = None + for line in open(json_file): + ev = json.loads(line.strip()) + if prev_ev is not None: + report(prev_ev, fp) + delay = time_for_entry(ev) - time_for_entry(prev_ev) + time.sleep(min(delay, 8)/scale_factor) + prev_ev = ev + report(ev, fp) -prev_ev = None -for line in open(json_file): - ev = json.loads(line.strip()) - if prev_ev is not None: - report(prev_ev) - time.sleep(min((time_for_entry(ev) - time_for_entry(prev_ev)), 8)/scale_factor) - prev_ev = ev -report(ev) sys.exit(rc) diff --git a/subiquity/controllers/error.py b/subiquity/controllers/error.py index 080c092b..9b372268 100644 --- a/subiquity/controllers/error.py +++ b/subiquity/controllers/error.py @@ -208,7 +208,9 @@ class ErrorReport(metaclass=urwid.MetaSignals): uploader._bg_update(uploader.bytes_sent + chunk_size) def _bg_upload(): - for_upload = {} + for_upload = { + "Kind": self.kind.value + } for k, v in self.pr.items(): if len(v) < 1024 or k in {"Traceback", "ProcCpuinfoMinimal"}: for_upload[k] = v diff --git a/subiquity/controllers/installprogress.py b/subiquity/controllers/installprogress.py index 6505cb04..14741886 100644 --- a/subiquity/controllers/installprogress.py +++ b/subiquity/controllers/installprogress.py @@ -329,23 +329,27 @@ class InstallProgressController(BaseController): if self.opts.dry_run: config_location = os.path.join('.subiquity/', config_file_name) + log_location = '.subiquity/install.log' event_file = "examples/curtin-events.json" if 'install-fail' in self.debug_flags: event_file = "examples/curtin-events-fail.json" - curtin_cmd = ["python3", "scripts/replay-curtin-log.py", - event_file, self._event_syslog_identifier] + curtin_cmd = [ + "python3", "scripts/replay-curtin-log.py", event_file, + self._event_syslog_identifier, log_location, + ] else: config_location = os.path.join('/var/log/installer', config_file_name) curtin_cmd = [sys.executable, '-m', 'curtin', '--showtrace', '-c', config_location, 'install'] + log_location = INSTALL_LOG ident = self._event_syslog_identifier self._write_config(config_location, self.model.render(syslog_identifier=ident)) self.app.note_file_for_apport("CurtinConfig", config_location) - self.app.note_file_for_apport("CurtinLog", INSTALL_LOG) + self.app.note_file_for_apport("CurtinLog", log_location) self.app.note_file_for_apport("CurtinErrors", ERROR_TARFILE) return curtin_cmd