| |
@@ -17,25 +17,55 @@
|
| |
_log = logging.getLogger(__name__)
|
| |
|
| |
|
| |
- def blocking_issues(tags):
|
| |
+ def report_failure(project, token, env, workflow, monit_utils):
|
| |
+ """ Open a pagure ticket against the instance specified in the
|
| |
+ configuration file when something does not work.
|
| |
+ """
|
| |
+ url = f"https://pagure.io/api/0/{project}/new_issue"
|
| |
+ title = f"Failure in {env} of the {workflow} packager workflow"
|
| |
+ logs = "\n".join(monit_utils.logs)
|
| |
+ content = f"""A run of monitor-gating has just failed in {env} for the {workflow} workflow.
|
| |
+
|
| |
+ The suspects are '{", ".join(monit_utils.failed)}'.
|
| |
+
|
| |
+ Full log:
|
| |
+ ````
|
| |
+ {logs}
|
| |
+ ````
|
| |
+ """
|
| |
+ tag = env
|
| |
+
|
| |
+ data = {
|
| |
+ "title": title,
|
| |
+ "content": content,
|
| |
+ "tag": tag,
|
| |
+ }
|
| |
+ headers = {
|
| |
+ "Authorization": f"token {token}",
|
| |
+ }
|
| |
+
|
| |
+ req = requests.post(url, data=data, headers=headers)
|
| |
+ if not req.ok:
|
| |
+ print(f"Error when trying to open a ticket at: {url} to report the failure")
|
| |
+
|
| |
+
|
| |
+ def blocking_issues(project, tags):
|
| |
"""Lists blocking issues we track in the fedora-infrastructure project.
|
| |
"""
|
| |
if not tags:
|
| |
print(f"No tags to filter blocking issues by, returning empty.")
|
| |
return []
|
| |
- api = f"https://pagure.io/api/0/fedora-infrastructure/issues"
|
| |
- q = f"?status=Open&tags={tags[0]}"
|
| |
+
|
| |
+ api = f"https://pagure.io/api/0/{project}/issues?status=Open&tags={tags[0]}"
|
| |
issues = []
|
| |
try:
|
| |
- r = requests.get(api + q)
|
| |
+ r = requests.get(api)
|
| |
issues = r.json()["issues"]
|
| |
if tags:
|
| |
t = set(tags[1:])
|
| |
issues = [i for i in issues if t & set(i["tags"])]
|
| |
for i in issues:
|
| |
- print(
|
| |
- f"Found blocking issue https://pagure.io/fedora-infrastructure/issue/{i['id']}"
|
| |
- )
|
| |
+ print(f"Found blocking issue https://pagure.io/{project}/issue/{i['id']}")
|
| |
except Exception as e:
|
| |
print(f"Error when querying pagure for blocking issues: {e}")
|
| |
return issues
|
| |