Skip to content

Commit 0baf2e4

Browse files
qa/tasks: add a new cephadm_from_container feature to cephadm task
The cephadm_from_container allows one to do a single container build and then point teuthology at that image as the "single source of truth". I find this extremely convenient when running teuthology locally and I keep carrying this patch around - I figure having it upstream will simplify my workflow. Maybe someday it'll benefit others too. To use it I set up a yaml overrides file with the following content: ```yaml overrides: cephadm: image: "quay.io/phlogistonjohn/ceph:dev" cephadm_from_container: true verify_ceph_hash: false verify_ceph_hash: false ``` This let's me test my custom builds fairly easily! Signed-off-by: John Mulligan <[email protected]>
1 parent bc103d8 commit 0baf2e4

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

qa/tasks/cephadm.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ def normalize_hostnames(ctx):
209209
def download_cephadm(ctx, config, ref):
210210
cluster_name = config['cluster']
211211

212-
if 'cephadm_binary_url' in config:
212+
if 'cephadm_from_container' in config:
213+
_fetch_cephadm_from_container(ctx, config)
214+
elif 'cephadm_binary_url' in config:
213215
url = config['cephadm_binary_url']
214216
_download_cephadm(ctx, url)
215217
elif config.get('cephadm_mode') != 'cephadm-package':
@@ -232,6 +234,36 @@ def download_cephadm(ctx, config, ref):
232234
_rm_cephadm(ctx)
233235

234236

237+
def _fetch_cephadm_from_container(ctx, config):
238+
image = config['image']
239+
cengine = 'podman'
240+
try:
241+
log.info("Testing if podman is available")
242+
ctx.cluster.run(args=['sudo', cengine, '--help'])
243+
except CommandFailedError:
244+
log.info("Failed to find podman. Using docker")
245+
cengine = 'docker'
246+
247+
ctx.cluster.run(args=['sudo', cengine, 'pull', image])
248+
ctx.cluster.run(args=[
249+
'sudo', cengine, 'run', '--rm', '--entrypoint=cat', image, '/usr/sbin/cephadm',
250+
run.Raw('>'),
251+
ctx.cephadm,
252+
])
253+
254+
# sanity-check the resulting file and set executable bit
255+
cephadm_file_size = '$(stat -c%s {})'.format(ctx.cephadm)
256+
ctx.cluster.run(
257+
args=[
258+
'test', '-s', ctx.cephadm,
259+
run.Raw('&&'),
260+
'test', run.Raw(cephadm_file_size), "-gt", run.Raw('1000'),
261+
run.Raw('&&'),
262+
'chmod', '+x', ctx.cephadm,
263+
],
264+
)
265+
266+
235267
def _fetch_cephadm_from_rpm(ctx):
236268
log.info("Copying cephadm installed from an RPM package")
237269
# cephadm already installed from redhat.install task

0 commit comments

Comments
 (0)