From 9810a671606dff6ed30814d3391c3ab7672166d4 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Mar 12 2022 15:50:12 +0000 Subject: [PATCH 1/3] Add FESCo ticket text Signed-off-by: Mattia Verga --- diff --git a/find_inactive_packagers.py b/find_inactive_packagers.py index 429ab63..2a3d4b2 100644 --- a/find_inactive_packagers.py +++ b/find_inactive_packagers.py @@ -70,6 +70,25 @@ BZ_API_KEY = getenv('BZ_API_KEY', None) # A list of system users that should never be removed from the packager group EXCLUDE_USERS = ['releng'] +PING_INACTIVE_TEXT = f'''Hello @{username}, + +during our periodic check as per the "Inactive packagers policy" +we detected no activity from you as a packager, nor in +other Fedora community places, like Bodhi or mailing lists. + + +In order to reduce security risks from possible accounts hijacking +we\'re trying to contact you to know if you\'re still reachable and +if your email set in Fedora Account System ({email}) is still valid. + + +Please, let us know if you\'re still intersted in participating +in Fedora and if you still need your account to be listed in the `packager` group. + +Without any reply from you, in two months we will proceed to remove +your account from the `packager` group. Your account will still be active. +''' + logging.basicConfig(level=logging.INFO, format='%(message)s', handlers=[ From 24e2feebd9899daa999b578ca5f15bb618c328c5 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Apr 14 2022 07:09:32 +0000 Subject: [PATCH 2/3] Open tickets for inactive packagers Signed-off-by: Mattia Verga --- diff --git a/find_inactive_packagers.py b/find_inactive_packagers.py index 2a3d4b2..c25c95c 100644 --- a/find_inactive_packagers.py +++ b/find_inactive_packagers.py @@ -67,10 +67,17 @@ from bugzilla import Bugzilla from fasjson_client import Client BZ_API_KEY = getenv('BZ_API_KEY', None) +PAGURE_API_KEY = getenv('PAGURE_API_KEY', None) +PAGURE_NEW_TICKET_URL = getenv('PAGURE_NEW_TICKET_URL', 'https://pagure.io/api/0/find-inactive-packagers/new_issue') +# A list of comma separated values to assign tags to the created ticket or empty string +PAGURE_NEW_TICKET_TAGS = getenv('PAGURE_NEW_TICKET_TAGS', 'inactive_packager') +# A username to whom assign the ticket by default or None +PAGURE_NEW_TICKET_ASSIGNEE = getenv('PAGURE_NEW_TICKET_ASSIGNEE', None) + # A list of system users that should never be removed from the packager group EXCLUDE_USERS = ['releng'] -PING_INACTIVE_TEXT = f'''Hello @{username}, +PING_INACTIVE_TEXT = '''Hello @{username}, during our periodic check as per the "Inactive packagers policy" we detected no activity from you as a packager, nor in @@ -265,3 +272,20 @@ if packager_email_map: emailstring = '|'.join(emails) logging.info(f'{user} - {emailstring if not args.privacy else "***"}') fout.write(f'{user},{emailstring}\n') + + # Open Pagure tickets + if PAGURE_API_KEY and PAGURE_NEW_TICKET_URL: + headers = {'Authorization': f'token {PAGURE_API_KEY}'} + for user, emails in newly_detected.items(): + data = {'title': f'Inactive packager detected for user {user}', + 'issue_content': PING_INACTIVE_TEXT.format(username = user, email = emails[0]), + 'tag': PAGURE_NEW_TICKET_TAGS.split(','), + 'assignee': PAGURE_NEW_TICKET_ASSIGNEE} + try: + resp = requests.post(PAGURE_NEW_TICKET_URL, data=data, headers=headers) + if resp.status_code == 401: + logging.error(f'Invalid or expired Pagure token, queue processing will stop immediately.') + break + except Exception: + logging.error(f'Error opening Pagure ticket for user {user}') + continue From c630c69aac0ed230040b00bfc6c80347be06a4b6 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Apr 15 2022 09:30:16 +0000 Subject: [PATCH 3/3] Update readme Signed-off-by: Mattia Verga --- diff --git a/README.md b/README.md index 2da7e81..aa2f6b1 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,9 @@ To run the script you'll need: - an active kerberos ticket to login to fasjson.fedoraproject.org - a bugzilla API key stored as OS env variable 'BZ_API_KEY' +Optionally, providing a Pagure repository URL and a token the script can automatically +open an issue ticket for each detected inactive packager. + ## Example usage ```