From 74a550ecd3823cd3a6a7a19d90a9b244e9fc2fcb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 20 Aug 2020 12:54:51 +0200 Subject: [PATCH] Only report namespace mis-configuration once and not always Basically, instead of reporting that the namespace did not exist for every package/component in that namespace, we now only report it once per namespace (but we still print the full info in the logs if verbose is enabled). Then, instead of always emailing the admins for mis-configurations, we'll only email them if there are other errors then these which will happen all the time due to the flatpaks and tests namespaces which do not exist in PDC and bugzilla. Signed-off-by: Pierre-Yves Chibon --- distgit_bugzilla_sync/script.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/distgit_bugzilla_sync/script.py b/distgit_bugzilla_sync/script.py index 8d545f5..00d3d26 100644 --- a/distgit_bugzilla_sync/script.py +++ b/distgit_bugzilla_sync/script.py @@ -937,11 +937,16 @@ class DistgitBugzillaSync: if project["namespace"] not in self.env["pdc_types"]: project["branches"] = [] project["products"] = [] - self.errors["configuration"].append( - f'Namespace `{project["namespace"]}` not found in the pdc_type ' - f'configuration key, project {project["namespace"]}/{project["name"]} ' - "ignored" - ) + error = f'Namespace `{project["namespace"]}` not found in the pdc_type ' \ + f'configuration key -- ignoring it' + if not error in self.errors["configuration"]: + self.errors["configuration"].append(error) + if self.env["verbose"]: + print( + f'Namespace `{project["namespace"]}` not found in the pdc_type ' + f'configuration key, project {project["namespace"]}/{project["name"]} ' + "ignored" + ) continue pdc_type = self.env["pdc_types"][project["namespace"]] @@ -1156,7 +1161,10 @@ class DistgitBugzillaSync: if self.env["verbose"] or self.env["dryrun"]: print("*" * 80) print("\n".join(report)) - if not self.env["dryrun"]: + + # Do not send the email in dryrun or when the error only relates to + # configuration (which will always happen for flatpaks and tests) + if not self.env["dryrun"] and list(self.errors.keys()) != ["configuration"]: self.send_email( self.env["email"]["from"], self.env["email"]["notify_admins"],