From 85309aa254fdc895f846078e0a1eb1fce5310219 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 30 2020 09:18:14 +0000 Subject: Log some messages as info by default This way when the toddler runs we can see what it did/changed. This should help diagnose any issue that may arise. Signed-off-by: Pierre-Yves Chibon --- diff --git a/toddlers.toml.example b/toddlers.toml.example index 03f06a4..2a6cb79 100644 --- a/toddlers.toml.example +++ b/toddlers.toml.example @@ -129,7 +129,7 @@ default_qa_contact = "extras-qa@fedoraproject.org" # Admin addresses to notify notify_admins = [ "root@localhost.localdomain", - ] +] # PDC types mapping for distgit_bugzilla_sync toddler [consumer_config.distgit_bugzilla_sync.pdc_types] diff --git a/toddlers/plugins/distgit_bugzilla_sync.py b/toddlers/plugins/distgit_bugzilla_sync.py index 29efb71..888520b 100644 --- a/toddlers/plugins/distgit_bugzilla_sync.py +++ b/toddlers/plugins/distgit_bugzilla_sync.py @@ -292,29 +292,28 @@ class DistgitBugzillaSync(ToddlerBase): mail_server, admin_email, notify_admins, report ) - if _log.isEnabledFor(logging.DEBUG): - times["end"] = time.time() + times["end"] = time.time() - _log.debug(" ----------") - _log.debug("Building the data structure") - delta = times["data structure end"] - times["start"] - _log.debug(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) + _log.info(" ----------") + _log.info("Building the data structure") + delta = times["data structure end"] - times["start"] + _log.info(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) - _log.debug("Building the FAS cache") - delta = times["FAS cache building end"] - times["data structure end"] - _log.debug(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) + _log.info("Building the FAS cache") + delta = times["FAS cache building end"] - times["data structure end"] + _log.info(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) - _log.debug("Building the bugzilla cache") - delta = times["BZ cache building end"] - times["FAS cache building end"] - _log.debug(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) + _log.info("Building the bugzilla cache") + delta = times["BZ cache building end"] - times["FAS cache building end"] + _log.info(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) - _log.debug("Interacting with bugzilla") - delta = times["end"] - times["BZ cache building end"] - _log.debug(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) + _log.info("Interacting with bugzilla") + delta = times["end"] - times["BZ cache building end"] + _log.info(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) - _log.debug("Total") - delta = times["end"] - times["start"] - _log.debug(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) + _log.info("Total") + delta = times["end"] - times["start"] + _log.info(" Ran on %2f seconds -- ie: %2f minutes", delta, delta / 60) def _get_pagure_projects( self, dist_git_url: str, project_list: list = None diff --git a/toddlers/utils/bugzilla_system.py b/toddlers/utils/bugzilla_system.py index 81289e1..7916eb2 100644 --- a/toddlers/utils/bugzilla_system.py +++ b/toddlers/utils/bugzilla_system.py @@ -226,26 +226,26 @@ def reassign_tickets_to_assignee( for bug in query_results: if bug.assigned_to == old_poc and bug.assigned_to != new_poc: - if _log.isEnabledFor(logging.DEBUG): - temp_old_poc = bug.assigned_to - temp_new_poc = new_poc - if print_fas_names: - if temp_old_poc in fas_users_info: - temp_old_poc = fas_users_info[old_poc] - else: - temp_old_poc = old_poc.split("@", 1)[0] + "@..." - if temp_new_poc in fas_users_info: - temp_new_poc = fas_users_info[new_poc] - else: - temp_new_poc = new_poc.split("@", 1)[0] + "@..." - _log.debug( - "%s/%s reassigning bug #%s from %s to %s", - product, - package, - bug.bug_id, - temp_old_poc, - temp_new_poc, - ) + + temp_old_poc = bug.assigned_to + temp_new_poc = new_poc + if print_fas_names: + if temp_old_poc in fas_users_info: + temp_old_poc = fas_users_info[old_poc] + else: + temp_old_poc = old_poc.split("@", 1)[0] + "@..." + if temp_new_poc in fas_users_info: + temp_new_poc = fas_users_info[new_poc] + else: + temp_new_poc = new_poc.split("@", 1)[0] + "@..." + _log.info( + "%s/%s reassigning bug #%s from %s to %s", + product, + package, + bug.bug_id, + temp_old_poc, + temp_new_poc, + ) if not dry_run: try: @@ -304,7 +304,7 @@ def add_component( """ server = get_bz() if retired: - _log.debug("[NOADD] %s/%s is retired", product, package) + _log.info("[NOADD] %s/%s is retired", product, package) return data = { @@ -318,47 +318,44 @@ def add_component( if cc_list: data["initialcclist"] = cc_list - if _log.isEnabledFor(logging.DEBUG): - for key in [ + for key in [ + "initialowner", + "description", + "initialqacontact", + "initialcclist", + "is_active", + ]: + if print_fas_names and key in [ "initialowner", - "description", "initialqacontact", "initialcclist", - "is_active", ]: - if print_fas_names and key in [ - "initialowner", - "initialqacontact", - "initialcclist", - ]: - if key == "initialowner": - # Print bugzilla e-mail if FAS name is not found - # This shouldn't happen, but to be safe - value = fas_users_info.get(owner, owner) - - if key == "initialqacontact": - # Print bugzilla e-mail if FAS name is not found - # This shouldn't happen, but to be safe - value = fas_users_info.get(qa_contact, qa_contact) - - if key == "initialcclist": - # Print bugzilla e-mail if FAS name is not found - # This shouldn't happen, but to be safe - value = [ - fas_users_info.get(cc_user, cc_user) for cc_user in cc_list - ] - - _log.debug( - "[ADDCOMP] %s/%s %s set to FAS name(s) `%s`", - product, - package, - key, - value, - ) - else: - _log.debug( - "[ADDCOMP] %s/%s %s set to `%s`", product, package, key, data[key] - ) + if key == "initialowner": + # Print bugzilla e-mail if FAS name is not found + # This shouldn't happen, but to be safe + value = fas_users_info.get(owner, owner) + + if key == "initialqacontact": + # Print bugzilla e-mail if FAS name is not found + # This shouldn't happen, but to be safe + value = fas_users_info.get(qa_contact, qa_contact) + + if key == "initialcclist": + # Print bugzilla e-mail if FAS name is not found + # This shouldn't happen, but to be safe + value = [fas_users_info.get(cc_user, cc_user) for cc_user in cc_list] + + _log.info( + "[ADDCOMP] %s/%s %s set to FAS name(s) `%s`", + product, + package, + key, + value, + ) + else: + _log.info( + "[ADDCOMP] %s/%s %s set to `%s`", product, package, key, data[key] + ) if not dry_run: try: @@ -449,68 +446,67 @@ def edit_component( data["product"] = product data["component"] = package - if _log.isEnabledFor(logging.DEBUG): - for key in [ + for key in [ + "initialowner", + "description", + "initialqacontact", + "initialcclist", + "is_active", + ]: + if data.get(key) is not None: + old_value = component[key] + if isinstance(old_value, list): + old_value = sorted(old_value) + new_value = data.get(key) + if isinstance(new_value, list): + new_value = sorted(new_value) + + if print_fas_names and key in [ "initialowner", - "description", "initialqacontact", "initialcclist", - "is_active", ]: + if key == "initialowner": + # Print bugzilla e-mail if FAS name is not found + # This shouldn't happen, but to be safe + old_value = fas_users_info.get(component[key], component[key]) + new_value = fas_users_info.get(owner, owner) + + if key == "initialqacontact": + # Print bugzilla e-mail if FAS name is not found + # This shouldn't happen, but to be safe + old_value = fas_users_info.get(component[key], component[key]) + new_value = fas_users_info.get(qa_contact, qa_contact) + + if key == "initialcclist": + # Print bugzilla e-mail if FAS name is not found + # This shouldn't happen, but to be safe + old_value = [ + fas_users_info.get(cc_user, cc_user) + for cc_user in component[key] + ] + new_value = [ + fas_users_info.get(cc_user, cc_user) for cc_user in cc_list + ] + + _log.info( + "[EDITCOMP] %s/%s %s changed from `%s` to FAS name(s) `%s`", + product, + package, + key, + old_value, + new_value, + ) + else: if data.get(key) is not None: - old_value = component[key] - if isinstance(old_value, list): - old_value = sorted(old_value) - new_value = data.get(key) - if isinstance(new_value, list): - new_value = sorted(new_value) - - if print_fas_names and key in [ - "initialowner", - "initialqacontact", - "initialcclist", - ]: - if key == "initialowner": - # Print bugzilla e-mail if FAS name is not found - # This shouldn't happen, but to be safe - old_value = fas_users_info.get(component[key], component[key]) - new_value = fas_users_info.get(owner, owner) - - if key == "initialqacontact": - # Print bugzilla e-mail if FAS name is not found - # This shouldn't happen, but to be safe - old_value = fas_users_info.get(component[key], component[key]) - new_value = fas_users_info.get(qa_contact, qa_contact) - - if key == "initialcclist": - # Print bugzilla e-mail if FAS name is not found - # This shouldn't happen, but to be safe - old_value = [ - fas_users_info.get(cc_user, cc_user) - for cc_user in component[key] - ] - new_value = [ - fas_users_info.get(cc_user, cc_user) for cc_user in cc_list - ] - - _log.debug( - "[EDITCOMP] %s/%s %s changed from `%s` to FAS name(s) `%s`", + _log.info( + "[EDITCOMP] %s/%s %s changed from `%s` to `%s`", product, package, key, old_value, new_value, ) - else: - if data.get(key) is not None: - _log.debug( - "[EDITCOMP] %s/%s %s changed from `%s` to `%s`", - product, - package, - key, - old_value, - new_value, - ) owner_changed = "initialowner" in data # FIXME: initialowner has been made mandatory for some @@ -542,7 +538,7 @@ def edit_component( else: if print_no_change: - _log.debug("[NOCHANGE] %s/%s", product, package) + _log.info("[NOCHANGE] %s/%s", product, package) def execute_bugzilla_call(