Skip to content

Commit

Permalink
rhcos: Only use new cluster for 4.12 - 4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
joepvd committed Nov 6, 2024
1 parent 432f87a commit 35bde0a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pyartcd/pyartcd/pipelines/build_rhcos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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."""
Expand All @@ -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
)
Expand Down Expand Up @@ -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 {}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 35bde0a

Please sign in to comment.