From e256a7985ff99fbf8c0238def7dd9c784b260591 Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Tue, 21 Jun 2022 16:23:15 +0200 Subject: [PATCH] Preserve the original inhibitor detection valid for now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we substituted Tags and Flags with Groups recently, it has impact on original detection of inhibitor inside leapp-repository which is not compatible with the new reporting implementation. As it could happen that new framework and old leapp-repository could be installed on the system, the consequence in such a case is that inhibitors will not be caught and user running: # leapp upgrade --reboot could hit various serious issues. This change make sure we keep the original functionality working, until we drop flags & tags completely, providing enough time to everyone to adapt to new changes. Co-authored-by: Michal Hečko Co-authored-by: Ina Vasilevskaya --- leapp/reporting/__init__.py | 6 ++++++ leapp/utils/report.py | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/leapp/reporting/__init__.py b/leapp/reporting/__init__.py index 0bcf482af..be5e72b70 100644 --- a/leapp/reporting/__init__.py +++ b/leapp/reporting/__init__.py @@ -326,6 +326,12 @@ def _create_report_object(entries): _sanitize_entries(entries) for entry in entries: entry.apply(report) + if Groups.INHIBITOR in report.get('groups', []): + # Before removing Flags, the original inhibitor detection worked + # by checking the `flags` field; keep the `flags` field until we drop Flags completely + # Currently we know that 'flags' does not exist otherwise so it's + # safe to just set it + report['flags'] = [Groups.INHIBITOR] return Report(report=report) diff --git a/leapp/utils/report.py b/leapp/utils/report.py index ad641a062..3efb14cac 100644 --- a/leapp/utils/report.py +++ b/leapp/utils/report.py @@ -139,4 +139,15 @@ def generate_report_file(messages_to_report, context, path, report_schema='1.1.0 groups = msg.pop('groups', []) msg['flags'] = [g for g in groups if g in _DEPRECATION_FLAGS] msg['tags'] = [g for g in groups if g not in _DEPRECATION_FLAGS] + if report_schema_tuple == (1, 2, 0): + # DEPRECATED: flags, tags + # NOTE(pstodulk): This is a temporary solution to ensure that + # flags are not present in the JSON output as we need to re-introduce + # flags internally to ensure that any inhibitor checks will not + # be negatively affected until we drop flags and tags completely. + messages_to_report = list(messages_to_report) + for msg in messages_to_report: + # NOTE(ivasilev) As flags field is created only if there is an inhibitor + # a default value to pop has to be specified not to end up with a KeyError + msg.pop('flags', None) json.dump({'entries': messages_to_report, 'leapp_run_id': context}, f, indent=2)