]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/ceph_deploy.py
2 Execute ceph-deploy as a task
4 from cStringIO
import StringIO
12 from teuthology
import misc
as teuthology
13 from teuthology
import contextutil
14 from teuthology
.config
import config
as teuth_config
15 from teuthology
.task
import install
as install_fn
16 from teuthology
.orchestra
import run
17 from tasks
.cephfs
.filesystem
import Filesystem
18 from teuthology
.misc
import wait_until_healthy
20 log
= logging
.getLogger(__name__
)
23 @contextlib.contextmanager
24 def download_ceph_deploy(ctx
, config
):
26 Downloads ceph-deploy from the ceph.com git mirror and (by default)
27 switches to the master branch. If the `ceph-deploy-branch` is specified, it
28 will use that instead. The `bootstrap` script is ran, with the argument
29 obtained from `python_version`, if specified.
31 # use mon.a for ceph_admin
32 (ceph_admin
,) = ctx
.cluster
.only('mon.a').remotes
.iterkeys()
35 py_ver
= str(config
['python_version'])
39 supported_versions
= ['2', '3']
40 if py_ver
not in supported_versions
:
41 raise ValueError("python_version must be: {}, not {}".format(
42 ' or '.join(supported_versions
), py_ver
45 log
.info("Installing Python")
46 system_type
= teuthology
.get_system_type(ceph_admin
)
48 if system_type
== 'rpm':
49 package
= 'python34' if py_ver
== '3' else 'python'
50 ctx
.cluster
.run(args
=[
51 'sudo', 'yum', '-y', 'install',
52 package
, 'python-virtualenv'
55 package
= 'python3' if py_ver
== '3' else 'python'
56 ctx
.cluster
.run(args
=[
57 'sudo', 'apt-get', '-y', '--force-yes', 'install',
58 package
, 'python-virtualenv'
61 log
.info('Downloading ceph-deploy...')
62 testdir
= teuthology
.get_testdir(ctx
)
63 ceph_deploy_branch
= config
.get('ceph-deploy-branch', 'master')
67 'git', 'clone', '-b', ceph_deploy_branch
,
68 teuth_config
.ceph_git_base_url
+ 'ceph-deploy.git',
69 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
74 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
79 args
.append(str(config
['python_version']))
82 ceph_admin
.run(args
=args
)
87 log
.info('Removing ceph-deploy ...')
92 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
97 def is_healthy(ctx
, config
):
98 """Wait until a Ceph cluster is healthy."""
99 testdir
= teuthology
.get_testdir(ctx
)
100 ceph_admin
= teuthology
.get_first_mon(ctx
, config
)
101 (remote
,) = ctx
.cluster
.only(ceph_admin
).remotes
.keys()
102 max_tries
= 90 # 90 tries * 10 secs --> 15 minutes
106 if tries
>= max_tries
:
107 msg
= "ceph health was unable to get 'HEALTH_OK' after waiting 15 minutes"
111 '{tdir}'.format(tdir
=testdir
),
117 raise RuntimeError(msg
)
122 '{tdir}'.format(tdir
=testdir
),
128 logger
=log
.getChild('health'),
130 out
= r
.stdout
.getvalue()
131 log
.info('Ceph health: %s', out
.rstrip('\n'))
132 if out
.split(None, 1)[0] == 'HEALTH_OK':
137 def get_nodes_using_role(ctx
, target_role
):
139 Extract the names of nodes that match a given role from a cluster, and modify the
140 cluster's service IDs to match the resulting node-based naming scheme that ceph-deploy
141 uses, such that if "mon.a" is on host "foo23", it'll be renamed to "mon.foo23".
144 # Nodes containing a service of the specified role
145 nodes_of_interest
= []
147 # Prepare a modified version of cluster.remotes with ceph-deploy-ized names
148 modified_remotes
= {}
149 ceph_deploy_mapped
= dict()
150 for _remote
, roles_for_host
in ctx
.cluster
.remotes
.iteritems():
151 modified_remotes
[_remote
] = []
152 for svc_id
in roles_for_host
:
153 if svc_id
.startswith("{0}.".format(target_role
)):
154 fqdn
= str(_remote
).split('@')[-1]
155 nodename
= str(str(_remote
).split('.')[0]).split('@')[1]
156 if target_role
== 'mon':
157 nodes_of_interest
.append(fqdn
)
159 nodes_of_interest
.append(nodename
)
160 mapped_role
= "{0}.{1}".format(target_role
, nodename
)
161 modified_remotes
[_remote
].append(mapped_role
)
162 # keep dict of mapped role for later use by tasks
163 # eg. mon.a => mon.node1
164 ceph_deploy_mapped
[svc_id
] = mapped_role
166 modified_remotes
[_remote
].append(svc_id
)
168 ctx
.cluster
.remotes
= modified_remotes
169 ctx
.cluster
.mapped_role
= ceph_deploy_mapped
171 return nodes_of_interest
174 def get_dev_for_osd(ctx
, config
):
175 """Get a list of all osd device names."""
177 for remote
, roles_for_host
in ctx
.cluster
.remotes
.iteritems():
178 host
= remote
.name
.split('@')[-1]
179 shortname
= host
.split('.')[0]
180 devs
= teuthology
.get_scratch_devices(remote
)
181 num_osd_per_host
= list(
182 teuthology
.roles_of_type(
183 roles_for_host
, 'osd'))
184 num_osds
= len(num_osd_per_host
)
185 if config
.get('separate_journal_disk') is not None:
186 num_devs_reqd
= 2 * num_osds
187 assert num_devs_reqd
<= len(
188 devs
), 'fewer data and journal disks than required ' + shortname
189 for dindex
in range(0, num_devs_reqd
, 2):
190 jd_index
= dindex
+ 1
191 dev_short
= devs
[dindex
].split('/')[-1]
192 jdev_short
= devs
[jd_index
].split('/')[-1]
193 osd_devs
.append((shortname
, dev_short
, jdev_short
))
195 assert num_osds
<= len(devs
), 'fewer disks than osds ' + shortname
196 for dev
in devs
[:num_osds
]:
197 dev_short
= dev
.split('/')[-1]
198 osd_devs
.append((shortname
, dev_short
))
202 def get_all_nodes(ctx
, config
):
203 """Return a string of node names separated by blanks"""
205 for t
, k
in ctx
.config
['targets'].iteritems():
206 host
= t
.split('@')[-1]
207 simple_host
= host
.split('.')[0]
208 nodelist
.append(simple_host
)
209 nodelist
= " ".join(nodelist
)
212 @contextlib.contextmanager
213 def build_ceph_cluster(ctx
, config
):
214 """Build a ceph cluster"""
216 # Expect to find ceph_admin on the first mon by ID, same place that the download task
217 # puts it. Remember this here, because subsequently IDs will change from those in
218 # the test config to those that ceph-deploy invents.
220 (ceph_admin
,) = ctx
.cluster
.only('mon.a').remotes
.iterkeys()
222 def execute_ceph_deploy(cmd
):
223 """Remotely execute a ceph_deploy command"""
224 return ceph_admin
.run(
227 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
234 def ceph_disk_osd_create(ctx
, config
):
235 node_dev_list
= get_dev_for_osd(ctx
, config
)
237 for d
in node_dev_list
:
240 zap
= './ceph-deploy disk zap ' + node
+ ':' + disk
241 estatus
= execute_ceph_deploy(zap
)
243 raise RuntimeError("ceph-deploy: Failed to zap osds")
244 osd_create_cmd
= './ceph-deploy osd create '
245 # first check for filestore, default is bluestore with ceph-deploy
246 if config
.get('filestore') is not None:
247 osd_create_cmd
+= '--filestore '
248 elif config
.get('bluestore') is not None:
249 osd_create_cmd
+= '--bluestore '
250 if config
.get('dmcrypt') is not None:
251 osd_create_cmd
+= '--dmcrypt '
252 osd_create_cmd
+= ":".join(d
)
253 estatus_osd
= execute_ceph_deploy(osd_create_cmd
)
255 log
.info('successfully created osd')
258 raise RuntimeError("ceph-deploy: Failed to create osds")
261 def ceph_volume_osd_create(ctx
, config
):
262 osds
= ctx
.cluster
.only(teuthology
.is_type('osd'))
264 for remote
in osds
.remotes
.iterkeys():
265 # all devs should be lvm
266 osd_create_cmd
= './ceph-deploy osd create --debug ' + remote
.shortname
+ ' '
267 # default is bluestore so we just need config item for filestore
268 roles
= ctx
.cluster
.remotes
[remote
]
269 dev_needed
= len([role
for role
in roles
270 if role
.startswith('osd')])
271 all_devs
= teuthology
.get_scratch_devices(remote
)
272 log
.info("node={n}, need_devs={d}, available={a}".format(
277 devs
= all_devs
[0:dev_needed
]
278 # rest of the devices can be used for journal if required
281 device_split
= device
.split('/')
282 lv_device
= device_split
[-2] + '/' + device_split
[-1]
283 if config
.get('filestore') is not None:
284 osd_create_cmd
+= '--filestore --data ' + lv_device
+ ' '
285 # filestore with ceph-volume also needs journal disk
287 jdevice
= all_devs
.pop(jdevs
)
289 raise RuntimeError("No device available for \
290 journal configuration")
291 jdevice_split
= jdevice
.split('/')
292 j_lv
= jdevice_split
[-2] + '/' + jdevice_split
[-1]
293 osd_create_cmd
+= '--journal ' + j_lv
295 osd_create_cmd
+= ' --data ' + lv_device
296 estatus_osd
= execute_ceph_deploy(osd_create_cmd
)
298 log
.info('successfully created osd')
301 raise RuntimeError("ceph-deploy: Failed to create osds")
305 log
.info('Building ceph cluster using ceph-deploy...')
306 testdir
= teuthology
.get_testdir(ctx
)
308 if config
.get('branch') is not None:
309 cbranch
= config
.get('branch')
310 for var
, val
in cbranch
.iteritems():
311 ceph_branch
= '--{var}={val}'.format(var
=var
, val
=val
)
312 all_nodes
= get_all_nodes(ctx
, config
)
313 mds_nodes
= get_nodes_using_role(ctx
, 'mds')
314 mds_nodes
= " ".join(mds_nodes
)
315 mon_node
= get_nodes_using_role(ctx
, 'mon')
316 mon_nodes
= " ".join(mon_node
)
317 # skip mgr based on config item
318 # this is needed when test uses latest code to install old ceph
320 skip_mgr
= config
.get('skip-mgr', False)
322 mgr_nodes
= get_nodes_using_role(ctx
, 'mgr')
323 mgr_nodes
= " ".join(mgr_nodes
)
324 new_mon
= './ceph-deploy new' + " " + mon_nodes
326 mgr_create
= './ceph-deploy mgr create' + " " + mgr_nodes
327 mon_hostname
= mon_nodes
.split(' ')[0]
328 mon_hostname
= str(mon_hostname
)
329 gather_keys
= './ceph-deploy gatherkeys' + " " + mon_hostname
330 deploy_mds
= './ceph-deploy mds create' + " " + mds_nodes
332 if mon_nodes
is None:
333 raise RuntimeError("no monitor nodes in the config file")
335 estatus_new
= execute_ceph_deploy(new_mon
)
337 raise RuntimeError("ceph-deploy: new command failed")
339 log
.info('adding config inputs...')
340 testdir
= teuthology
.get_testdir(ctx
)
341 conf_path
= '{tdir}/ceph-deploy/ceph.conf'.format(tdir
=testdir
)
343 if config
.get('conf') is not None:
344 confp
= config
.get('conf')
345 for section
, keys
in confp
.iteritems():
346 lines
= '[{section}]\n'.format(section
=section
)
347 teuthology
.append_lines_to_file(ceph_admin
, conf_path
, lines
,
349 for key
, value
in keys
.iteritems():
350 log
.info("[%s] %s = %s" % (section
, key
, value
))
351 lines
= '{key} = {value}\n'.format(key
=key
, value
=value
)
352 teuthology
.append_lines_to_file(
353 ceph_admin
, conf_path
, lines
, sudo
=True)
356 dev_branch
= ctx
.config
['branch']
357 branch
= '--dev={branch}'.format(branch
=dev_branch
)
362 install_nodes
= './ceph-deploy install ' + option
+ " " + all_nodes
363 estatus_install
= execute_ceph_deploy(install_nodes
)
364 if estatus_install
!= 0:
365 raise RuntimeError("ceph-deploy: Failed to install ceph")
366 # install ceph-test package too
367 install_nodes2
= './ceph-deploy install --tests ' + option
+ \
369 estatus_install
= execute_ceph_deploy(install_nodes2
)
370 if estatus_install
!= 0:
371 raise RuntimeError("ceph-deploy: Failed to install ceph-test")
373 mon_create_nodes
= './ceph-deploy mon create-initial'
374 # If the following fails, it is OK, it might just be that the monitors
375 # are taking way more than a minute/monitor to form quorum, so lets
376 # try the next block which will wait up to 15 minutes to gatherkeys.
377 execute_ceph_deploy(mon_create_nodes
)
379 # create-keys is explicit now
380 # http://tracker.ceph.com/issues/16036
381 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
382 for remote
in mons
.remotes
.iterkeys():
383 remote
.run(args
=['sudo', 'ceph-create-keys', '--cluster', 'ceph',
384 '--id', remote
.shortname
])
386 estatus_gather
= execute_ceph_deploy(gather_keys
)
387 if estatus_gather
!= 0:
388 raise RuntimeError("ceph-deploy: Failed during gather keys")
390 if config
.get('use-ceph-volume', False):
391 no_of_osds
= ceph_volume_osd_create(ctx
, config
)
393 # this method will only work with ceph-deploy v1.5.39 or older
394 no_of_osds
= ceph_disk_osd_create(ctx
, config
)
397 execute_ceph_deploy(mgr_create
)
400 estatus_mds
= execute_ceph_deploy(deploy_mds
)
402 raise RuntimeError("ceph-deploy: Failed to deploy mds")
404 if config
.get('test_mon_destroy') is not None:
405 for d
in range(1, len(mon_node
)):
406 mon_destroy_nodes
= './ceph-deploy mon destroy' + \
408 estatus_mon_d
= execute_ceph_deploy(mon_destroy_nodes
)
409 if estatus_mon_d
!= 0:
410 raise RuntimeError("ceph-deploy: Failed to delete monitor")
414 if config
.get('wait-for-healthy', True) and no_of_osds
>= 2:
415 is_healthy(ctx
=ctx
, config
=None)
417 log
.info('Setting up client nodes...')
418 conf_path
= '/etc/ceph/ceph.conf'
419 admin_keyring_path
= '/etc/ceph/ceph.client.admin.keyring'
420 first_mon
= teuthology
.get_first_mon(ctx
, config
)
421 (mon0_remote
,) = ctx
.cluster
.only(first_mon
).remotes
.keys()
422 conf_data
= teuthology
.get_file(
427 admin_keyring
= teuthology
.get_file(
429 path
=admin_keyring_path
,
433 clients
= ctx
.cluster
.only(teuthology
.is_type('client'))
434 for remot
, roles_for_host
in clients
.remotes
.iteritems():
435 for id_
in teuthology
.roles_of_type(roles_for_host
, 'client'):
437 '/etc/ceph/ceph.client.{id}.keyring'.format(id=id_
)
441 '{tdir}'.format(tdir
=testdir
),
443 'sudo', 'bash', '-c',
444 run
.Raw('"'), 'ceph',
447 'client.{id}'.format(id=id_
),
456 key_data
= teuthology
.get_file(
461 teuthology
.sudo_write_file(
467 teuthology
.sudo_write_file(
469 path
=admin_keyring_path
,
473 teuthology
.sudo_write_file(
481 log
.info('Configuring CephFS...')
482 Filesystem(ctx
, create
=True)
483 elif not config
.get('only_mon'):
485 "The cluster is NOT operational due to insufficient OSDs")
490 "Error encountered, logging exception before tearing down ceph-deploy")
491 log
.info(traceback
.format_exc())
494 if config
.get('keep_running'):
496 log
.info('Stopping ceph...')
497 ctx
.cluster
.run(args
=['sudo', 'stop', 'ceph-all', run
.Raw('||'),
498 'sudo', 'service', 'ceph', 'stop', run
.Raw('||'),
499 'sudo', 'systemctl', 'stop', 'ceph.target'])
501 # Are you really not running anymore?
502 # try first with the init tooling
503 # ignoring the status so this becomes informational only
506 'sudo', 'status', 'ceph-all', run
.Raw('||'),
507 'sudo', 'service', 'ceph', 'status', run
.Raw('||'),
508 'sudo', 'systemctl', 'status', 'ceph.target'],
511 # and now just check for the processes themselves, as if upstart/sysvinit
512 # is lying to us. Ignore errors if the grep fails
513 ctx
.cluster
.run(args
=['sudo', 'ps', 'aux', run
.Raw('|'),
514 'grep', '-v', 'grep', run
.Raw('|'),
515 'grep', 'ceph'], check_status
=False)
517 if ctx
.archive
is not None:
518 # archive mon data, too
519 log
.info('Archiving mon data...')
520 path
= os
.path
.join(ctx
.archive
, 'data')
522 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
523 for remote
, roles
in mons
.remotes
.iteritems():
525 if role
.startswith('mon.'):
526 teuthology
.pull_directory_tarball(
529 path
+ '/' + role
+ '.tgz')
531 log
.info('Compressing logs...')
554 log
.info('Archiving logs...')
555 path
= os
.path
.join(ctx
.archive
, 'remote')
557 for remote
in ctx
.cluster
.remotes
.iterkeys():
558 sub
= os
.path
.join(path
, remote
.shortname
)
560 teuthology
.pull_directory(remote
, '/var/log/ceph',
561 os
.path
.join(sub
, 'log'))
563 # Prevent these from being undefined if the try block fails
564 all_nodes
= get_all_nodes(ctx
, config
)
565 purge_nodes
= './ceph-deploy purge' + " " + all_nodes
566 purgedata_nodes
= './ceph-deploy purgedata' + " " + all_nodes
568 log
.info('Purging package...')
569 execute_ceph_deploy(purge_nodes
)
570 log
.info('Purging data...')
571 execute_ceph_deploy(purgedata_nodes
)
574 @contextlib.contextmanager
575 def cli_test(ctx
, config
):
577 ceph-deploy cli to exercise most commonly use cli's and ensure
578 all commands works and also startup the init system.
581 log
.info('Ceph-deploy Test')
585 conf_dir
= teuthology
.get_testdir(ctx
) + "/cdtest"
587 def execute_cdeploy(admin
, cmd
, path
):
588 """Execute ceph-deploy commands """
589 """Either use git path or repo path """
590 args
= ['cd', conf_dir
, run
.Raw(';')]
592 args
.append('{path}/ceph-deploy/ceph-deploy'.format(path
=path
))
594 args
.append('ceph-deploy')
595 args
.append(run
.Raw(cmd
))
596 ec
= admin
.run(args
=args
, check_status
=False).exitstatus
599 "failed during ceph-deploy cmd: {cmd} , ec={ec}".format(cmd
=cmd
, ec
=ec
))
601 if config
.get('rhbuild'):
604 path
= teuthology
.get_testdir(ctx
)
605 # test on branch from config eg: wip-* , master or next etc
606 # packages for all distro's should exist for wip*
607 if ctx
.config
.get('branch'):
608 branch
= ctx
.config
.get('branch')
609 test_branch
= ' --dev={branch} '.format(branch
=branch
)
610 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
611 for node
, role
in mons
.remotes
.iteritems():
613 admin
.run(args
=['mkdir', conf_dir
], check_status
=False)
614 nodename
= admin
.shortname
615 system_type
= teuthology
.get_system_type(admin
)
616 if config
.get('rhbuild'):
617 admin
.run(args
=['sudo', 'yum', 'install', 'ceph-deploy', '-y'])
618 log
.info('system type is %s', system_type
)
619 osds
= ctx
.cluster
.only(teuthology
.is_type('osd'))
621 for remote
, roles
in osds
.remotes
.iteritems():
622 devs
= teuthology
.get_scratch_devices(remote
)
623 log
.info("roles %s", roles
)
626 'Test needs minimum of 3 devices, only found %s',
628 raise RuntimeError("Needs minimum of 3 devices ")
630 conf_path
= '{conf_dir}/ceph.conf'.format(conf_dir
=conf_dir
)
631 new_cmd
= 'new ' + nodename
632 execute_cdeploy(admin
, new_cmd
, path
)
633 if config
.get('conf') is not None:
634 confp
= config
.get('conf')
635 for section
, keys
in confp
.iteritems():
636 lines
= '[{section}]\n'.format(section
=section
)
637 teuthology
.append_lines_to_file(admin
, conf_path
, lines
,
639 for key
, value
in keys
.iteritems():
640 log
.info("[%s] %s = %s" % (section
, key
, value
))
641 lines
= '{key} = {value}\n'.format(key
=key
, value
=value
)
642 teuthology
.append_lines_to_file(admin
, conf_path
, lines
,
644 new_mon_install
= 'install {branch} --mon '.format(
645 branch
=test_branch
) + nodename
646 new_mgr_install
= 'install {branch} --mgr '.format(
647 branch
=test_branch
) + nodename
648 new_osd_install
= 'install {branch} --osd '.format(
649 branch
=test_branch
) + nodename
650 new_admin
= 'install {branch} --cli '.format(branch
=test_branch
) + nodename
651 create_initial
= 'mon create-initial '
652 # either use create-keys or push command
653 push_keys
= 'admin ' + nodename
654 execute_cdeploy(admin
, new_mon_install
, path
)
655 execute_cdeploy(admin
, new_mgr_install
, path
)
656 execute_cdeploy(admin
, new_osd_install
, path
)
657 execute_cdeploy(admin
, new_admin
, path
)
658 execute_cdeploy(admin
, create_initial
, path
)
659 execute_cdeploy(admin
, push_keys
, path
)
662 zap_disk
= 'disk zap ' + "{n}:{d}".format(n
=nodename
, d
=devs
[i
])
663 prepare
= 'osd prepare ' + "{n}:{d}".format(n
=nodename
, d
=devs
[i
])
664 execute_cdeploy(admin
, zap_disk
, path
)
665 execute_cdeploy(admin
, prepare
, path
)
667 log
.info("list files for debugging purpose to check file permissions")
668 admin
.run(args
=['ls', run
.Raw('-lt'), conf_dir
])
669 remote
.run(args
=['sudo', 'ceph', '-s'], check_status
=False)
670 r
= remote
.run(args
=['sudo', 'ceph', 'health'], stdout
=StringIO())
671 out
= r
.stdout
.getvalue()
672 log
.info('Ceph health: %s', out
.rstrip('\n'))
673 log
.info("Waiting for cluster to become healthy")
674 with contextutil
.safe_while(sleep
=10, tries
=6,
675 action
='check health') as proceed
:
677 r
= remote
.run(args
=['sudo', 'ceph', 'health'], stdout
=StringIO())
678 out
= r
.stdout
.getvalue()
679 if (out
.split(None, 1)[0] == 'HEALTH_OK'):
681 rgw_install
= 'install {branch} --rgw {node}'.format(
685 rgw_create
= 'rgw create ' + nodename
686 execute_cdeploy(admin
, rgw_install
, path
)
687 execute_cdeploy(admin
, rgw_create
, path
)
688 log
.info('All ceph-deploy cli tests passed')
692 log
.info("cleaning up")
693 ctx
.cluster
.run(args
=['sudo', 'stop', 'ceph-all', run
.Raw('||'),
694 'sudo', 'service', 'ceph', 'stop', run
.Raw('||'),
695 'sudo', 'systemctl', 'stop', 'ceph.target'],
699 umount_dev
= "{d}1".format(d
=devs
[i
])
700 r
= remote
.run(args
=['sudo', 'umount', run
.Raw(umount_dev
)])
701 cmd
= 'purge ' + nodename
702 execute_cdeploy(admin
, cmd
, path
)
703 cmd
= 'purgedata ' + nodename
704 execute_cdeploy(admin
, cmd
, path
)
705 log
.info("Removing temporary dir")
712 if config
.get('rhbuild'):
713 admin
.run(args
=['sudo', 'yum', 'remove', 'ceph-deploy', '-y'])
716 @contextlib.contextmanager
717 def single_node_test(ctx
, config
):
719 - ceph-deploy.single_node_test: null
722 - ceph-deploy.single_node_test:
726 log
.info("Testing ceph-deploy on single node")
729 overrides
= ctx
.config
.get('overrides', {})
730 teuthology
.deep_merge(config
, overrides
.get('ceph-deploy', {}))
732 if config
.get('rhbuild'):
733 log
.info("RH Build, Skip Download")
734 with contextutil
.nested(
735 lambda: cli_test(ctx
=ctx
, config
=config
),
739 with contextutil
.nested(
740 lambda: install_fn
.ship_utilities(ctx
=ctx
, config
=None),
741 lambda: download_ceph_deploy(ctx
=ctx
, config
=config
),
742 lambda: cli_test(ctx
=ctx
, config
=config
),
747 @contextlib.contextmanager
748 def upgrade(ctx
, config
):
750 Upgrade using ceph-deploy
753 # to upgrade to specific branch, use
756 # to setup mgr node, use
758 # to wait for cluster to be healthy after all upgrade, use
759 wait-for-healthy: True
760 role: (upgrades the below roles serially)
765 roles
= config
.get('roles')
766 # get the roles that are mapped as per ceph-deploy
767 # roles are mapped for mon/mds eg: mon.a => mon.host_short_name
768 mapped_role
= ctx
.cluster
.mapped_role
769 if config
.get('branch'):
770 branch
= config
.get('branch')
771 (var
, val
) = branch
.items()[0]
772 ceph_branch
= '--{var}={val}'.format(var
=var
, val
=val
)
774 # default to wip-branch under test
775 dev_branch
= ctx
.config
['branch']
776 ceph_branch
= '--dev={branch}'.format(branch
=dev_branch
)
777 # get the node used for initial deployment which is mon.a
778 mon_a
= mapped_role
.get('mon.a')
779 (ceph_admin
,) = ctx
.cluster
.only(mon_a
).remotes
.iterkeys()
780 testdir
= teuthology
.get_testdir(ctx
)
781 cmd
= './ceph-deploy install ' + ceph_branch
783 # check if this role is mapped (mon or mds)
784 if mapped_role
.get(role
):
785 role
= mapped_role
.get(role
)
786 remotes_and_roles
= ctx
.cluster
.only(role
).remotes
787 for remote
, roles
in remotes_and_roles
.iteritems():
788 nodename
= remote
.shortname
789 cmd
= cmd
+ ' ' + nodename
790 log
.info("Upgrading ceph on %s", nodename
)
794 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
799 # restart all ceph services, ideally upgrade should but it does not
802 'sudo', 'systemctl', 'restart', 'ceph.target'
805 ceph_admin
.run(args
=['sudo', 'ceph', '-s'])
807 # workaround for http://tracker.ceph.com/issues/20950
808 # write the correct mgr key to disk
809 if config
.get('setup-mgr-node', None):
810 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
811 for remote
, roles
in mons
.remotes
.iteritems():
814 run
.Raw('sudo ceph auth get client.bootstrap-mgr'),
817 run
.Raw('/var/lib/ceph/bootstrap-mgr/ceph.keyring')
821 if config
.get('setup-mgr-node', None):
822 mgr_nodes
= get_nodes_using_role(ctx
, 'mgr')
823 mgr_nodes
= " ".join(mgr_nodes
)
824 mgr_install
= './ceph-deploy install --mgr ' + ceph_branch
+ " " + mgr_nodes
825 mgr_create
= './ceph-deploy mgr create' + " " + mgr_nodes
830 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
832 run
.Raw(mgr_install
),
839 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
844 ceph_admin
.run(args
=['sudo', 'ceph', '-s'])
845 if config
.get('wait-for-healthy', None):
846 wait_until_healthy(ctx
, ceph_admin
, use_sudo
=True)
850 @contextlib.contextmanager
851 def task(ctx
, config
):
853 Set up and tear down a Ceph cluster.
864 mon_initial_members: 1
865 ceph-deploy-branch: my-ceph-deploy-branch
868 # either choose bluestore or filestore, default is bluestore
872 # skip install of mgr for old release using below flag
873 skip-mgr: True ( default is False )
874 # to use ceph-volume instead of ceph-disk
875 # ceph-disk can only be used with old ceph-deploy release from pypi
876 use-ceph-volume: true
897 separate_journal_disk: yes
903 assert isinstance(config
, dict), \
904 "task ceph-deploy only supports a dictionary for configuration"
906 overrides
= ctx
.config
.get('overrides', {})
907 teuthology
.deep_merge(config
, overrides
.get('ceph-deploy', {}))
909 if config
.get('branch') is not None:
911 config
['branch'], dict), 'branch must be a dictionary'
913 log
.info('task ceph-deploy with config ' + str(config
))
915 # we need to use 1.5.39-stable for testing jewel or master branch with
917 if config
.get('use-ceph-volume', False) is False:
918 # check we are not testing specific branch
919 if config
.get('ceph-deploy-branch', False) is False:
920 config
['ceph-deploy-branch'] = '1.5.39-stable'
922 with contextutil
.nested(
923 lambda: install_fn
.ship_utilities(ctx
=ctx
, config
=None),
924 lambda: download_ceph_deploy(ctx
=ctx
, config
=config
),
925 lambda: build_ceph_cluster(ctx
=ctx
, config
=config
),