| |
@@ -23,7 +23,15 @@
|
| |
|
| |
from toddlers.base import ToddlerBase
|
| |
from toddlers.exceptions import ValidationError
|
| |
- from toddlers.utils import bugzilla_system, fedora_account, git, pagure, pdc, requests
|
| |
+ from toddlers.utils import (
|
| |
+ bugzilla_system,
|
| |
+ check_services,
|
| |
+ fedora_account,
|
| |
+ git,
|
| |
+ pagure,
|
| |
+ pdc,
|
| |
+ requests,
|
| |
+ )
|
| |
|
| |
# Regex for branch name validation
|
| |
STREAM_NAME_REGEX = r"^[a-zA-Z0-9.\-_+]+$"
|
| |
@@ -43,6 +51,15 @@
|
| |
"https://pagure.io/releng/issues"
|
| |
)
|
| |
|
| |
+ # External services: dist-git, pdc, pagure, fas
|
| |
+ EXTERNAL_SERVICES = {
|
| |
+ "dist-git": "https://src.fedoraproject.org/api/0/",
|
| |
+ "bugzilla": "https://bugzilla.redhat.com/",
|
| |
+ "PDC": "https://pdc.fedoraproject.org/rest_api/v1/",
|
| |
+ "pagure": "https://src.fedoraproject.org/api/0/",
|
| |
+ "fas": "https://id.fedoraproject.org/fas/",
|
| |
+ }
|
| |
+
|
| |
_log = logging.getLogger(__name__)
|
| |
|
| |
# Currently there is no way to generate PDC API token on either
|
| |
@@ -379,6 +396,14 @@
|
| |
issue body
|
| |
initial_commit: indicate whether to create an initial commit.
|
| |
"""
|
| |
+
|
| |
+ _log.info(
|
| |
+ "Before creating new repo, checking if all the services are available"
|
| |
+ )
|
| |
+ is_services_available = check_services(EXTERNAL_SERVICES)
|
| |
+ if not is_services_available:
|
| |
+ return
|
| |
+
|
| |
_log.info("New repo was requested. Validating request.")
|
| |
required_keys = [
|
| |
"repo",
|
| |
@@ -667,6 +692,14 @@
|
| |
issue_body_json: a partially validated dictionary of the JSON in the
|
| |
issue body
|
| |
"""
|
| |
+
|
| |
+ _log.info(
|
| |
+ "Before creating new branch, checking if all the services are available"
|
| |
+ )
|
| |
+ is_services_available = check_services(EXTERNAL_SERVICES)
|
| |
+ if not is_services_available:
|
| |
+ return
|
| |
+
|
| |
required_keys = ["action", "namespace", "branch", "sls", "repo"]
|
| |
_log.debug("JSON keys in message body {}".format(issue_body_json.keys()))
|
| |
for key in required_keys:
|
| |
Some time back there was a request[1] raised where it was noted that due to some services' unavailability, some tickets were processed at that time to end in an inconsistent state. This can happen due to various reasons, but the script should be smart enough to not process the tickets if there is an outage of the services we need (PDC, pagure, fas, dist-git). This PR adds the same check-in
create_new_repoandcreate_new_branchmethods.This is my first time contributing to toddlers, so all types of suggestions are welcome \0/
[1] https://pagure.io/fedora-infra/toddlers/issue/150
Signed-off-by: Samyak Jain samyak.jn11@gmail.com