]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephadm: support to pull stable branch compiled cephadm
authorAdam King <adking@redhat.com>
Wed, 16 Aug 2023 23:56:38 +0000 (19:56 -0400)
committerAdam King <adking@redhat.com>
Mon, 8 Jan 2024 14:51:52 +0000 (09:51 -0500)
This is to allow us to pull the latest build of
cephadm off of a stable branch (currently the only
valid option for that is reef, although this hopefully
will work with squid, T release, etc. in the future).

This should allow us to bootstrap cliusters based on
those stable branches for use in upgrade testing

Signed-off-by: Adam King <adking@redhat.com>
qa/tasks/cephadm.py
qa/tasks/util/chacra.py

index 1fdf6ee012e3217085ff0138fb10ded38f4b34bf..9e386bbd5c29b258aa9a44be801e8b1a2ee87d66 100644 (file)
@@ -169,6 +169,8 @@ def download_cephadm(ctx, config, ref):
         # cephadm
         elif 'cephadm_git_url' in config and 'cephadm_branch' in config:
             _fetch_cephadm_from_github(ctx, config, ref)
+        elif 'compiled_cephadm_branch' in config:
+            _fetch_stable_branch_cephadm_from_chacra(ctx, config, cluster_name)
         else:
             _fetch_cephadm_from_chachra(ctx, config, cluster_name)
 
@@ -291,6 +293,55 @@ def _fetch_cephadm_from_chachra(ctx, config, cluster_name):
         ],
     )
 
+def _fetch_stable_branch_cephadm_from_chacra(ctx, config, cluster_name):
+    branch = config.get('compiled_cephadm_branch', 'reef')
+    flavor = config.get('flavor', 'default')
+
+    log.info(f'Downloading "compiled" cephadm from cachra for {branch}')
+
+    bootstrap_remote = ctx.ceph[cluster_name].bootstrap_remote
+    bp = packaging.get_builder_project()(
+        config.get('project', 'ceph'),
+        config,
+        ctx=ctx,
+        remote=bootstrap_remote,
+    )
+    log.info('builder_project result: %s' % (bp._result.json()))
+
+    # pull the cephadm binary from chacra
+    url = chacra.get_binary_url(
+            'cephadm',
+            project=bp.project,
+            distro=bp.distro.split('/')[0],
+            release=bp.distro.split('/')[1],
+            arch=bp.arch,
+            flavor=flavor,
+            branch=branch,
+    )
+    log.info("Discovered cachra url: %s", url)
+    ctx.cluster.run(
+        args=[
+            'curl', '--silent', '-L', url,
+            run.Raw('>'),
+            ctx.cephadm,
+            run.Raw('&&'),
+            'ls', '-l',
+            ctx.cephadm,
+        ],
+    )
+
+    # sanity-check the resulting file and set executable bit
+    cephadm_file_size = '$(stat -c%s {})'.format(ctx.cephadm)
+    ctx.cluster.run(
+        args=[
+            'test', '-s', ctx.cephadm,
+            run.Raw('&&'),
+            'test', run.Raw(cephadm_file_size), "-gt", run.Raw('1000'),
+            run.Raw('&&'),
+            'chmod', '+x', ctx.cephadm,
+        ],
+    )
+
 
 def _rm_cluster(ctx, cluster_name):
     log.info('Removing cluster...')
index ed9358a5974972900032727456563177107bdb64..52414c890f9c09d6ec45ceebc6d063edaab9ee59 100644 (file)
@@ -71,7 +71,15 @@ def get_binary_url(
     if len(result) == 0:
         raise RuntimeError(f'no results found at {resp.url}')
 
-    # TODO: filter the result down to the correct arch etc.?
+    # if arch was supplied, filter down to only results
+    # that include the desired arch
+    if arch:
+        result = [r for r in result if ('archs' in r and arch in r['archs'])]
+
+    # TODO: Is there any further filtering we should do beyond arch?
+    # We already use flavor, ref, etc. in our search.
+
+    # TODO: After filtering, does it matter which result we take?
     result = result[0]
 
     status = result['status']