Skip to content

Commit 6399168

Browse files
authored
Merge pull request ceph#59421 from phlogistonjohn/jjm-teuth-cephadm-from-ctr
qa/tasks: add a new cephadm_from_container feature to cephadm task Reviewed-by: Adam King <[email protected]>
2 parents dc8d75f + 0baf2e4 commit 6399168

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)