]>
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
)
213 @contextlib.contextmanager
214 def build_ceph_cluster(ctx
, config
):
215 """Build a ceph cluster"""
217 # Expect to find ceph_admin on the first mon by ID, same place that the download task
218 # puts it. Remember this here, because subsequently IDs will change from those in
219 # the test config to those that ceph-deploy invents.
221 (ceph_admin
,) = ctx
.cluster
.only('mon.a').remotes
.iterkeys()
223 def execute_ceph_deploy(cmd
):
224 """Remotely execute a ceph_deploy command"""
225 return ceph_admin
.run(
228 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
236 log
.info('Building ceph cluster using ceph-deploy...')
237 testdir
= teuthology
.get_testdir(ctx
)
239 if config
.get('branch') is not None:
240 cbranch
= config
.get('branch')
241 for var
, val
in cbranch
.iteritems():
242 ceph_branch
= '--{var}={val}'.format(var
=var
, val
=val
)
243 all_nodes
= get_all_nodes(ctx
, config
)
244 mds_nodes
= get_nodes_using_role(ctx
, 'mds')
245 mds_nodes
= " ".join(mds_nodes
)
246 mon_node
= get_nodes_using_role(ctx
, 'mon')
247 mon_nodes
= " ".join(mon_node
)
248 # skip mgr based on config item
249 # this is needed when test uses latest code to install old ceph
251 skip_mgr
= config
.get('skip-mgr', False)
253 mgr_nodes
= get_nodes_using_role(ctx
, 'mgr')
254 mgr_nodes
= " ".join(mgr_nodes
)
255 new_mon
= './ceph-deploy new' + " " + mon_nodes
257 mgr_create
= './ceph-deploy mgr create' + " " + mgr_nodes
258 mon_hostname
= mon_nodes
.split(' ')[0]
259 mon_hostname
= str(mon_hostname
)
260 gather_keys
= './ceph-deploy gatherkeys' + " " + mon_hostname
261 deploy_mds
= './ceph-deploy mds create' + " " + mds_nodes
264 if mon_nodes
is None:
265 raise RuntimeError("no monitor nodes in the config file")
267 estatus_new
= execute_ceph_deploy(new_mon
)
269 raise RuntimeError("ceph-deploy: new command failed")
271 log
.info('adding config inputs...')
272 testdir
= teuthology
.get_testdir(ctx
)
273 conf_path
= '{tdir}/ceph-deploy/ceph.conf'.format(tdir
=testdir
)
275 if config
.get('conf') is not None:
276 confp
= config
.get('conf')
277 for section
, keys
in confp
.iteritems():
278 lines
= '[{section}]\n'.format(section
=section
)
279 teuthology
.append_lines_to_file(ceph_admin
, conf_path
, lines
,
281 for key
, value
in keys
.iteritems():
282 log
.info("[%s] %s = %s" % (section
, key
, value
))
283 lines
= '{key} = {value}\n'.format(key
=key
, value
=value
)
284 teuthology
.append_lines_to_file(
285 ceph_admin
, conf_path
, lines
, sudo
=True)
288 dev_branch
= ctx
.config
['branch']
289 branch
= '--dev={branch}'.format(branch
=dev_branch
)
294 install_nodes
= './ceph-deploy install ' + option
+ " " + all_nodes
295 estatus_install
= execute_ceph_deploy(install_nodes
)
296 if estatus_install
!= 0:
297 raise RuntimeError("ceph-deploy: Failed to install ceph")
298 # install ceph-test package too
299 install_nodes2
= './ceph-deploy install --tests ' + option
+ \
301 estatus_install
= execute_ceph_deploy(install_nodes2
)
302 if estatus_install
!= 0:
303 raise RuntimeError("ceph-deploy: Failed to install ceph-test")
305 mon_create_nodes
= './ceph-deploy mon create-initial'
306 # If the following fails, it is OK, it might just be that the monitors
307 # are taking way more than a minute/monitor to form quorum, so lets
308 # try the next block which will wait up to 15 minutes to gatherkeys.
309 execute_ceph_deploy(mon_create_nodes
)
311 # create-keys is explicit now
312 # http://tracker.ceph.com/issues/16036
313 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
314 for remote
in mons
.remotes
.iterkeys():
315 remote
.run(args
=['sudo', 'ceph-create-keys', '--cluster', 'ceph',
316 '--id', remote
.shortname
])
318 estatus_gather
= execute_ceph_deploy(gather_keys
)
321 execute_ceph_deploy(mgr_create
)
324 estatus_mds
= execute_ceph_deploy(deploy_mds
)
326 raise RuntimeError("ceph-deploy: Failed to deploy mds")
328 if config
.get('test_mon_destroy') is not None:
329 for d
in range(1, len(mon_node
)):
330 mon_destroy_nodes
= './ceph-deploy mon destroy' + \
332 estatus_mon_d
= execute_ceph_deploy(mon_destroy_nodes
)
333 if estatus_mon_d
!= 0:
334 raise RuntimeError("ceph-deploy: Failed to delete monitor")
336 node_dev_list
= get_dev_for_osd(ctx
, config
)
337 for d
in node_dev_list
:
340 zap
= './ceph-deploy disk zap ' + node
+ ':' + disk
341 estatus
= execute_ceph_deploy(zap
)
343 raise RuntimeError("ceph-deploy: Failed to zap osds")
344 osd_create_cmd
= './ceph-deploy osd create '
345 # first check for filestore, default is bluestore with ceph-deploy
346 if config
.get('filestore') is not None:
347 osd_create_cmd
+= '--filestore '
348 elif config
.get('bluestore') is not None:
349 osd_create_cmd
+= '--bluestore '
350 if config
.get('dmcrypt') is not None:
351 osd_create_cmd
+= '--dmcrypt '
352 osd_create_cmd
+= ":".join(d
)
353 estatus_osd
= execute_ceph_deploy(osd_create_cmd
)
355 log
.info('successfully created osd')
358 raise RuntimeError("ceph-deploy: Failed to create osds")
360 if config
.get('wait-for-healthy', True) and no_of_osds
>= 2:
361 is_healthy(ctx
=ctx
, config
=None)
363 log
.info('Setting up client nodes...')
364 conf_path
= '/etc/ceph/ceph.conf'
365 admin_keyring_path
= '/etc/ceph/ceph.client.admin.keyring'
366 first_mon
= teuthology
.get_first_mon(ctx
, config
)
367 (mon0_remote
,) = ctx
.cluster
.only(first_mon
).remotes
.keys()
368 conf_data
= teuthology
.get_file(
373 admin_keyring
= teuthology
.get_file(
375 path
=admin_keyring_path
,
379 clients
= ctx
.cluster
.only(teuthology
.is_type('client'))
380 for remot
, roles_for_host
in clients
.remotes
.iteritems():
381 for id_
in teuthology
.roles_of_type(roles_for_host
, 'client'):
383 '/etc/ceph/ceph.client.{id}.keyring'.format(id=id_
)
387 '{tdir}'.format(tdir
=testdir
),
389 'sudo', 'bash', '-c',
390 run
.Raw('"'), 'ceph',
393 'client.{id}'.format(id=id_
),
402 key_data
= teuthology
.get_file(
407 teuthology
.sudo_write_file(
413 teuthology
.sudo_write_file(
415 path
=admin_keyring_path
,
419 teuthology
.sudo_write_file(
427 log
.info('Configuring CephFS...')
428 Filesystem(ctx
, create
=True)
429 elif not config
.get('only_mon'):
431 "The cluster is NOT operational due to insufficient OSDs")
436 "Error encountered, logging exception before tearing down ceph-deploy")
437 log
.info(traceback
.format_exc())
440 if config
.get('keep_running'):
442 log
.info('Stopping ceph...')
443 ctx
.cluster
.run(args
=['sudo', 'stop', 'ceph-all', run
.Raw('||'),
444 'sudo', 'service', 'ceph', 'stop', run
.Raw('||'),
445 'sudo', 'systemctl', 'stop', 'ceph.target'])
447 # Are you really not running anymore?
448 # try first with the init tooling
449 # ignoring the status so this becomes informational only
452 'sudo', 'status', 'ceph-all', run
.Raw('||'),
453 'sudo', 'service', 'ceph', 'status', run
.Raw('||'),
454 'sudo', 'systemctl', 'status', 'ceph.target'],
457 # and now just check for the processes themselves, as if upstart/sysvinit
458 # is lying to us. Ignore errors if the grep fails
459 ctx
.cluster
.run(args
=['sudo', 'ps', 'aux', run
.Raw('|'),
460 'grep', '-v', 'grep', run
.Raw('|'),
461 'grep', 'ceph'], check_status
=False)
463 if ctx
.archive
is not None:
464 # archive mon data, too
465 log
.info('Archiving mon data...')
466 path
= os
.path
.join(ctx
.archive
, 'data')
468 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
469 for remote
, roles
in mons
.remotes
.iteritems():
471 if role
.startswith('mon.'):
472 teuthology
.pull_directory_tarball(
475 path
+ '/' + role
+ '.tgz')
477 log
.info('Compressing logs...')
500 log
.info('Archiving logs...')
501 path
= os
.path
.join(ctx
.archive
, 'remote')
503 for remote
in ctx
.cluster
.remotes
.iterkeys():
504 sub
= os
.path
.join(path
, remote
.shortname
)
506 teuthology
.pull_directory(remote
, '/var/log/ceph',
507 os
.path
.join(sub
, 'log'))
509 # Prevent these from being undefined if the try block fails
510 all_nodes
= get_all_nodes(ctx
, config
)
511 purge_nodes
= './ceph-deploy purge' + " " + all_nodes
512 purgedata_nodes
= './ceph-deploy purgedata' + " " + all_nodes
514 log
.info('Purging package...')
515 execute_ceph_deploy(purge_nodes
)
516 log
.info('Purging data...')
517 execute_ceph_deploy(purgedata_nodes
)
520 @contextlib.contextmanager
521 def cli_test(ctx
, config
):
523 ceph-deploy cli to exercise most commonly use cli's and ensure
524 all commands works and also startup the init system.
527 log
.info('Ceph-deploy Test')
531 conf_dir
= teuthology
.get_testdir(ctx
) + "/cdtest"
533 def execute_cdeploy(admin
, cmd
, path
):
534 """Execute ceph-deploy commands """
535 """Either use git path or repo path """
536 args
= ['cd', conf_dir
, run
.Raw(';')]
538 args
.append('{path}/ceph-deploy/ceph-deploy'.format(path
=path
))
540 args
.append('ceph-deploy')
541 args
.append(run
.Raw(cmd
))
542 ec
= admin
.run(args
=args
, check_status
=False).exitstatus
545 "failed during ceph-deploy cmd: {cmd} , ec={ec}".format(cmd
=cmd
, ec
=ec
))
547 if config
.get('rhbuild'):
550 path
= teuthology
.get_testdir(ctx
)
551 # test on branch from config eg: wip-* , master or next etc
552 # packages for all distro's should exist for wip*
553 if ctx
.config
.get('branch'):
554 branch
= ctx
.config
.get('branch')
555 test_branch
= ' --dev={branch} '.format(branch
=branch
)
556 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
557 for node
, role
in mons
.remotes
.iteritems():
559 admin
.run(args
=['mkdir', conf_dir
], check_status
=False)
560 nodename
= admin
.shortname
561 system_type
= teuthology
.get_system_type(admin
)
562 if config
.get('rhbuild'):
563 admin
.run(args
=['sudo', 'yum', 'install', 'ceph-deploy', '-y'])
564 log
.info('system type is %s', system_type
)
565 osds
= ctx
.cluster
.only(teuthology
.is_type('osd'))
567 for remote
, roles
in osds
.remotes
.iteritems():
568 devs
= teuthology
.get_scratch_devices(remote
)
569 log
.info("roles %s", roles
)
572 'Test needs minimum of 3 devices, only found %s',
574 raise RuntimeError("Needs minimum of 3 devices ")
576 conf_path
= '{conf_dir}/ceph.conf'.format(conf_dir
=conf_dir
)
577 new_cmd
= 'new ' + nodename
578 execute_cdeploy(admin
, new_cmd
, path
)
579 if config
.get('conf') is not None:
580 confp
= config
.get('conf')
581 for section
, keys
in confp
.iteritems():
582 lines
= '[{section}]\n'.format(section
=section
)
583 teuthology
.append_lines_to_file(admin
, conf_path
, lines
,
585 for key
, value
in keys
.iteritems():
586 log
.info("[%s] %s = %s" % (section
, key
, value
))
587 lines
= '{key} = {value}\n'.format(key
=key
, value
=value
)
588 teuthology
.append_lines_to_file(admin
, conf_path
, lines
,
590 new_mon_install
= 'install {branch} --mon '.format(
591 branch
=test_branch
) + nodename
592 new_mgr_install
= 'install {branch} --mgr '.format(
593 branch
=test_branch
) + nodename
594 new_osd_install
= 'install {branch} --osd '.format(
595 branch
=test_branch
) + nodename
596 new_admin
= 'install {branch} --cli '.format(branch
=test_branch
) + nodename
597 create_initial
= 'mon create-initial '
598 # either use create-keys or push command
599 push_keys
= 'admin ' + nodename
600 execute_cdeploy(admin
, new_mon_install
, path
)
601 execute_cdeploy(admin
, new_mgr_install
, path
)
602 execute_cdeploy(admin
, new_osd_install
, path
)
603 execute_cdeploy(admin
, new_admin
, path
)
604 execute_cdeploy(admin
, create_initial
, path
)
605 execute_cdeploy(admin
, push_keys
, path
)
608 zap_disk
= 'disk zap ' + "{n}:{d}".format(n
=nodename
, d
=devs
[i
])
609 prepare
= 'osd prepare ' + "{n}:{d}".format(n
=nodename
, d
=devs
[i
])
610 execute_cdeploy(admin
, zap_disk
, path
)
611 execute_cdeploy(admin
, prepare
, path
)
613 log
.info("list files for debugging purpose to check file permissions")
614 admin
.run(args
=['ls', run
.Raw('-lt'), conf_dir
])
615 remote
.run(args
=['sudo', 'ceph', '-s'], check_status
=False)
616 r
= remote
.run(args
=['sudo', 'ceph', 'health'], stdout
=StringIO())
617 out
= r
.stdout
.getvalue()
618 log
.info('Ceph health: %s', out
.rstrip('\n'))
619 log
.info("Waiting for cluster to become healthy")
620 with contextutil
.safe_while(sleep
=10, tries
=6,
621 action
='check health') as proceed
:
623 r
= remote
.run(args
=['sudo', 'ceph', 'health'], stdout
=StringIO())
624 out
= r
.stdout
.getvalue()
625 if (out
.split(None, 1)[0] == 'HEALTH_OK'):
627 rgw_install
= 'install {branch} --rgw {node}'.format(
631 rgw_create
= 'rgw create ' + nodename
632 execute_cdeploy(admin
, rgw_install
, path
)
633 execute_cdeploy(admin
, rgw_create
, path
)
634 log
.info('All ceph-deploy cli tests passed')
638 log
.info("cleaning up")
639 ctx
.cluster
.run(args
=['sudo', 'stop', 'ceph-all', run
.Raw('||'),
640 'sudo', 'service', 'ceph', 'stop', run
.Raw('||'),
641 'sudo', 'systemctl', 'stop', 'ceph.target'],
645 umount_dev
= "{d}1".format(d
=devs
[i
])
646 r
= remote
.run(args
=['sudo', 'umount', run
.Raw(umount_dev
)])
647 cmd
= 'purge ' + nodename
648 execute_cdeploy(admin
, cmd
, path
)
649 cmd
= 'purgedata ' + nodename
650 execute_cdeploy(admin
, cmd
, path
)
651 log
.info("Removing temporary dir")
658 if config
.get('rhbuild'):
659 admin
.run(args
=['sudo', 'yum', 'remove', 'ceph-deploy', '-y'])
662 @contextlib.contextmanager
663 def single_node_test(ctx
, config
):
665 - ceph-deploy.single_node_test: null
668 - ceph-deploy.single_node_test:
672 log
.info("Testing ceph-deploy on single node")
675 overrides
= ctx
.config
.get('overrides', {})
676 teuthology
.deep_merge(config
, overrides
.get('ceph-deploy', {}))
678 if config
.get('rhbuild'):
679 log
.info("RH Build, Skip Download")
680 with contextutil
.nested(
681 lambda: cli_test(ctx
=ctx
, config
=config
),
685 with contextutil
.nested(
686 lambda: install_fn
.ship_utilities(ctx
=ctx
, config
=None),
687 lambda: download_ceph_deploy(ctx
=ctx
, config
=config
),
688 lambda: cli_test(ctx
=ctx
, config
=config
),
693 @contextlib.contextmanager
694 def upgrade(ctx
, config
):
696 Upgrade using ceph-deploy
699 # to upgrade to specific branch, use
702 # to setup mgr node, use
704 # to wait for cluster to be healthy after all upgrade, use
705 wait-for-healthy: True
706 role: (upgrades the below roles serially)
711 roles
= config
.get('roles')
712 # get the roles that are mapped as per ceph-deploy
713 # roles are mapped for mon/mds eg: mon.a => mon.host_short_name
714 mapped_role
= ctx
.cluster
.mapped_role
715 if config
.get('branch'):
716 branch
= config
.get('branch')
717 (var
, val
) = branch
.items()[0]
718 ceph_branch
= '--{var}={val}'.format(var
=var
, val
=val
)
721 ceph_branch
= '--dev=master'
722 # get the node used for initial deployment which is mon.a
723 mon_a
= mapped_role
.get('mon.a')
724 (ceph_admin
,) = ctx
.cluster
.only(mon_a
).remotes
.iterkeys()
725 testdir
= teuthology
.get_testdir(ctx
)
726 cmd
= './ceph-deploy install ' + ceph_branch
728 # check if this role is mapped (mon or mds)
729 if mapped_role
.get(role
):
730 role
= mapped_role
.get(role
)
731 remotes_and_roles
= ctx
.cluster
.only(role
).remotes
732 for remote
, roles
in remotes_and_roles
.iteritems():
733 nodename
= remote
.shortname
734 cmd
= cmd
+ ' ' + nodename
735 log
.info("Upgrading ceph on %s", nodename
)
739 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
744 # restart all ceph services, ideally upgrade should but it does not
747 'sudo', 'systemctl', 'restart', 'ceph.target'
750 ceph_admin
.run(args
=['sudo', 'ceph', '-s'])
752 # workaround for http://tracker.ceph.com/issues/20950
753 # write the correct mgr key to disk
754 if config
.get('setup-mgr-node', None):
755 mons
= ctx
.cluster
.only(teuthology
.is_type('mon'))
756 for remote
, roles
in mons
.remotes
.iteritems():
759 run
.Raw('sudo ceph auth get client.bootstrap-mgr'),
762 run
.Raw('/var/lib/ceph/bootstrap-mgr/ceph.keyring')
766 if config
.get('setup-mgr-node', None):
767 mgr_nodes
= get_nodes_using_role(ctx
, 'mgr')
768 mgr_nodes
= " ".join(mgr_nodes
)
769 mgr_install
= './ceph-deploy install --mgr ' + ceph_branch
+ " " + mgr_nodes
770 mgr_create
= './ceph-deploy mgr create' + " " + mgr_nodes
775 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
777 run
.Raw(mgr_install
),
784 '{tdir}/ceph-deploy'.format(tdir
=testdir
),
789 ceph_admin
.run(args
=['sudo', 'ceph', '-s'])
790 if config
.get('wait-for-healthy', None):
791 wait_until_healthy(ctx
, ceph_admin
, use_sudo
=True)
795 @contextlib.contextmanager
796 def task(ctx
, config
):
798 Set up and tear down a Ceph cluster.
809 mon_initial_members: 1
810 ceph-deploy-branch: my-ceph-deploy-branch
813 # either choose bluestore or filestore, default is bluestore
817 # skip install of mgr for old release using below flag
818 skip-mgr: True ( default is False )
839 separate_journal_disk: yes
845 assert isinstance(config
, dict), \
846 "task ceph-deploy only supports a dictionary for configuration"
848 overrides
= ctx
.config
.get('overrides', {})
849 teuthology
.deep_merge(config
, overrides
.get('ceph-deploy', {}))
851 if config
.get('branch') is not None:
853 config
['branch'], dict), 'branch must be a dictionary'
855 log
.info('task ceph-deploy with config ' + str(config
))
857 with contextutil
.nested(
858 lambda: install_fn
.ship_utilities(ctx
=ctx
, config
=None),
859 lambda: download_ceph_deploy(ctx
=ctx
, config
=config
),
860 lambda: build_ceph_cluster(ctx
=ctx
, config
=config
),