From 432f87ad6934ca64df0ce19db1f461fb1efc9d48 Mon Sep 17 00:00:00 2001 From: Joep van Delft Date: Wed, 6 Nov 2024 13:00:47 +0100 Subject: [PATCH 1/2] Get RHCOS to build on new host --- pyartcd/pyartcd/pipelines/build_rhcos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyartcd/pyartcd/pipelines/build_rhcos.py b/pyartcd/pyartcd/pipelines/build_rhcos.py index 5deab67f9..e3337940a 100644 --- a/pyartcd/pyartcd/pipelines/build_rhcos.py +++ b/pyartcd/pyartcd/pipelines/build_rhcos.py @@ -15,7 +15,7 @@ from typing import List, Dict, Tuple -JENKINS_BASE_URL = "https://jenkins-rhcos.apps.ocp-virt.prod.psi.redhat.com" +JENKINS_BASE_URL = "https://jenkins-rhcos--prod-pipeline.apps.int.prod-stable-spoke1-dc-iad2.itup.redhat.com" # lifted verbatim from # https://findwork.dev/blog/advanced-usage-python-requests-timeouts-retries-hooks/ From 35bde0ac1703e8ac4666a79e0b61582382de8411 Mon Sep 17 00:00:00 2001 From: Joep van Delft Date: Wed, 6 Nov 2024 14:52:50 +0100 Subject: [PATCH 2/2] rhcos: Only use new cluster for 4.12 - 4.14 --- pyartcd/pyartcd/pipelines/build_rhcos.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pyartcd/pyartcd/pipelines/build_rhcos.py b/pyartcd/pyartcd/pipelines/build_rhcos.py index e3337940a..75bbb8a72 100644 --- a/pyartcd/pyartcd/pipelines/build_rhcos.py +++ b/pyartcd/pyartcd/pipelines/build_rhcos.py @@ -15,8 +15,6 @@ from typing import List, Dict, Tuple -JENKINS_BASE_URL = "https://jenkins-rhcos--prod-pipeline.apps.int.prod-stable-spoke1-dc-iad2.itup.redhat.com" - # lifted verbatim from # https://findwork.dev/blog/advanced-usage-python-requests-timeouts-retries-hooks/ DEFAULT_TIMEOUT = 5 # seconds @@ -47,6 +45,9 @@ def __init__(self, runtime: Runtime, new_build: bool, ignore_running: bool, vers self.api_token = None self._stream = None # rhcos stream the version maps to self.dry_run = self.runtime.dry_run + self.jenkins_base_url = "https://jenkins-rhcos--prod-pipeline.apps.int.prod-stable-spoke1-dc-iad2.itup.redhat.com" + if self.version in ["4.15", "4.16", "4.17", "4.18", "4.19"]: + self.jenkins_base_url = 'https://jenkins-rhcos.apps.ocp-virt.prod.psi.redhat.com' self.request_session = requests.Session() retries = Retry( @@ -92,7 +93,7 @@ def retrieve_auth_token(self) -> str: if s.model.type == "kubernetes.io/service-account-token" and s.model.metadata.annotations["kubernetes.io/service-account.name"] == "jenkins" and s.model.metadata.annotations["kubernetes.io/service-account.uid"] == jenkins_uid: secret_maybe = base64.b64decode(s.model.data.token).decode('utf-8') r = self.request_session.get( - f"{JENKINS_BASE_URL}/me/api/json", + f"{self.jenkins_base_url}/me/api/json", headers={"Authorization": f"Bearer {secret_maybe}"}, ) if r.status_code == 200: @@ -114,9 +115,8 @@ def build_parameters(build: Dict[str, List[Dict]]) -> Dict: ), []) return {p["name"]: p["value"] for p in parameters} - @staticmethod - def build_url(job: str, number: int) -> str: - return f"{JENKINS_BASE_URL}/job/{job}/{number}/" + def build_url(self, job: str, number: int) -> str: + return f"{self.jenkins_base_url}/job/{job}/{number}/" def query_existing_builds(self) -> List[Dict]: """Check if there are any existing builds for the given version. Returns builds in progress.""" @@ -125,7 +125,7 @@ def query_existing_builds(self) -> List[Dict]: builds.extend( dict(**b, job=job, parameters=self.build_parameters(b), url=self.build_url(job, b["number"])) for b in self.request_session.get( - f"{JENKINS_BASE_URL}/job/{job}/api/json?tree=builds[number,description,result,actions[parameters[name,value]]]", + f"{self.jenkins_base_url}/job/{job}/api/json?tree=builds[number,description,result,actions[parameters[name,value]]]", ).json()["builds"] if b["result"] is None # build is still running when it has no status ) @@ -164,7 +164,7 @@ def start_build(self): params = dict(STREAM=self.stream, EARLY_ARCH_JOBS="false") if self.new_build: params["FORCE"] = "true" - job_url = f"{JENKINS_BASE_URL}/job/build/buildWithParameters" + job_url = f"{self.jenkins_base_url}/job/build/buildWithParameters" if self.dry_run: print(f"Would've started build at url={job_url} with params={params}", file=sys.stderr) return {} @@ -195,7 +195,7 @@ def build_result(self, job, number): description=b["description"] or "[no description yet]", result=b["result"], ) for b in self.request_session.get( - f"{JENKINS_BASE_URL}/job/{job}/api/json?tree=builds[number,description,result]" + f"{self.jenkins_base_url}/job/{job}/api/json?tree=builds[number,description,result]" ).json()["builds"] if b["number"] == number ), None)