Skip to content

Commit 5e2132a

Browse files
committed
Adding check for shaman and chacra build validations
Signed-off-by: tintumathew10 <tmathew@redhat.com>
1 parent 78c036d commit 5e2132a

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

teuthology/suite/run.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pwd
66
import yaml
77
import re
8+
import requests
89
import time
910

1011
from pathlib import Path
@@ -103,6 +104,7 @@ def create_initial_config(self):
103104
self.choose_ceph_version(ceph_hash)
104105
suite_branch = self.choose_suite_branch()
105106
suite_hash = self.choose_suite_hash(suite_branch)
107+
self.verify_sha_id(ceph_hash, suite_branch)
106108
if self.args.suite_dir:
107109
self.suite_repo_path = self.args.suite_dir
108110
else:
@@ -251,6 +253,43 @@ def choose_ceph_version(self, ceph_hash):
251253
else:
252254
log.info('skipping ceph package verification')
253255

256+
def verify_sha_id(self, ceph_hash, ceph_branch):
257+
"""
258+
Verify if a given Ceph version (SHA1) exists in either Chacra or Shaman
259+
repositories for the specified branch.
260+
"""
261+
def fetch_url(url, expect_json=False):
262+
"""Fetch content from a URL, optionally parse JSON."""
263+
try:
264+
response = requests.get(url, timeout=10)
265+
response.raise_for_status()
266+
except requests.exceptions.RequestException as e:
267+
log.error(f"Failed to fetch {url}: {e}")
268+
return None
269+
270+
if expect_json:
271+
try:
272+
return response.json()
273+
except ValueError:
274+
log.error(f"Invalid JSON from {url}")
275+
return None
276+
return response.text
277+
278+
chacra_url = f"https://1.chacra.ceph.com/repos/ceph/{ceph_branch}/"
279+
chacra_data = fetch_url(chacra_url, expect_json=True)
280+
if chacra_data:
281+
if ceph_hash not in chacra_data:
282+
msg = f"Not found in Chacra for branch {ceph_branch}."
283+
util.schedule_fail(msg, self.name, dry_run=self.args.dry_run)
284+
285+
shaman_url = f"https://shaman.ceph.com/builds/ceph/{ceph_branch}/"
286+
shaman_html = fetch_url(shaman_url)
287+
if shaman_html:
288+
sha1s = set(re.findall(r"[0-9a-f]{40}", shaman_html))
289+
if ceph_hash not in sha1s:
290+
msg = f"Not found in Shaman for branch {ceph_branch}."
291+
util.schedule_fail(msg, self.name, dry_run=self.args.dry_run)
292+
254293
def choose_teuthology_branch(self):
255294
"""Select teuthology branch, check if it is present in repo and return
256295
tuple (branch, hash) where hash is commit sha1 corresponding

0 commit comments

Comments
 (0)