Skip to content

Commit

Permalink
Merge pull request #1216 from SUSE/wip-migrate
Browse files Browse the repository at this point in the history
Reuse OSD ID in migrations, support replace.osds
  • Loading branch information
jschmid1 authored Aug 23, 2018
2 parents 01b51e0 + 31e9478 commit 4b426b2
Show file tree
Hide file tree
Showing 72 changed files with 4,074 additions and 158 deletions.
52 changes: 50 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ copy-files:
install -d -m 755 $(DESTDIR)/srv/salt/ceph/tests/quiescent/timeout
install -m 644 srv/salt/ceph/tests/quiescent/*.sls $(DESTDIR)/srv/salt/ceph/tests/quiescent
install -m 644 srv/salt/ceph/tests/quiescent/timeout/*.sls $(DESTDIR)/srv/salt/ceph/tests/quiescent/timeout
install -d -m 755 $(DESTDIR)/srv/salt/ceph/tests/migrate
install -m 644 srv/salt/ceph/tests/migrate/*.sls $(DESTDIR)/srv/salt/ceph/tests/migrate
install -d -m 755 $(DESTDIR)/srv/salt/ceph/tests/remove
install -m 644 srv/salt/ceph/tests/remove/*.sls $(DESTDIR)/srv/salt/ceph/tests/remove
install -d -m 755 $(DESTDIR)/srv/salt/ceph/tests/replace
install -m 644 srv/salt/ceph/tests/replace/*.sls $(DESTDIR)/srv/salt/ceph/tests/replace
install -d -m 755 $(DESTDIR)/srv/salt/ceph/tests/restart
install -d -m 755 $(DESTDIR)/srv/salt/ceph/tests/restart/mon
install -d -m 755 $(DESTDIR)/srv/salt/ceph/tests/restart/mon/change
Expand Down Expand Up @@ -147,6 +153,41 @@ copy-files:
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/tuned/off
install -m 644 srv/salt/ceph/functests/1node/tuned/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/tuned
install -m 644 srv/salt/ceph/functests/1node/tuned/off/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/tuned/off
# functests/1node
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node
install -m 644 srv/salt/ceph/functests/1node/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/apparmor
install -m 644 srv/salt/ceph/functests/1node/apparmor/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/apparmor
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/keyrings
install -m 644 srv/salt/ceph/functests/1node/keyrings/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/keyrings
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/macros
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/macros/os_switch
install -m 644 srv/salt/ceph/functests/1node/macros/os_switch/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/macros/os_switch
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/openstack
install -m 644 srv/salt/ceph/functests/1node/openstack/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/openstack
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/quiescent
install -m 644 srv/salt/ceph/functests/1node/quiescent/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/quiescent
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/migrate
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/filestore
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/filestore2
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/bluestore
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/bluestore2
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/bluestore3
install -m 644 srv/salt/ceph/functests/1node/migrate/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/migrate
install -m 644 srv/salt/ceph/functests/1node/migrate/filestore/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/filestore
install -m 644 srv/salt/ceph/functests/1node/migrate/filestore2/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/filestore2
install -m 644 srv/salt/ceph/functests/1node/migrate/bluestore/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/bluestore
install -m 644 srv/salt/ceph/functests/1node/migrate/bluestore2/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/bluestore2
install -m 644 srv/salt/ceph/functests/1node/migrate/bluestore3/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/migrate/bluestore3
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/replace
install -m 644 srv/salt/ceph/functests/1node/replace/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/replace
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/remove
install -m 644 srv/salt/ceph/functests/1node/remove/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/remove
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/restart
install -m 644 srv/salt/ceph/functests/1node/restart/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/restart
install -d -m 755 $(DESTDIR)/srv/salt/ceph/functests/1node/tuned/off
install -m 644 srv/salt/ceph/functests/1node/tuned/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/tuned
install -m 644 srv/salt/ceph/functests/1node/tuned/off/*.sls $(DESTDIR)/srv/salt/ceph/functests/1node/tuned/off
# docs
install -d -m 755 $(DESTDIR)$(DOCDIR)/deepsea
install -m 644 LICENSE $(DESTDIR)$(DOCDIR)/deepsea/
Expand Down Expand Up @@ -196,6 +237,11 @@ copy-files:
# modules
install -d -m 755 $(DESTDIR)/srv/salt/_modules
install -m 644 srv/salt/_modules/*.py* $(DESTDIR)/srv/salt/_modules/
# state modules
install -d -m 755 $(DESTDIR)/srv/salt/_states
install -d -m 755 $(DESTDIR)/srv/salt/_states/__pycache__
install -m 644 srv/salt/_states/__pycache__/*.pyc $(DESTDIR)/srv/salt/_states/__pycache__
install -m 644 srv/salt/_states/*.py* $(DESTDIR)/srv/salt/_states/
# state files
install -d -m 755 $(DESTDIR)/srv/salt/ceph/admin
install -m 644 srv/salt/ceph/admin/*.sls $(DESTDIR)/srv/salt/ceph/admin/
Expand Down Expand Up @@ -529,8 +575,10 @@ copy-files:
install -m 644 srv/salt/ceph/remove/igw/auth/*.sls $(DESTDIR)/srv/salt/ceph/remove/igw/auth/
install -d -m 755 $(DESTDIR)/srv/salt/ceph/remove/mds
install -m 644 srv/salt/ceph/remove/mds/*.sls $(DESTDIR)/srv/salt/ceph/remove/mds/
install -d -m 755 $(DESTDIR)/srv/salt/ceph/remove/migrated
install -m 644 srv/salt/ceph/remove/migrated/*.sls $(DESTDIR)/srv/salt/ceph/remove/migrated/
install -d -m 755 $(DESTDIR)/srv/salt/ceph/remove/destroyed
install -m 644 srv/salt/ceph/remove/destroyed/*.sls $(DESTDIR)/srv/salt/ceph/remove/destroyed/
# Renamed for deprecation
ln -sf destroyed $(DESTDIR)/srv/salt/ceph/remove/migrated
install -d -m 755 $(DESTDIR)/srv/salt/ceph/remove/mgr
install -m 644 srv/salt/ceph/remove/mgr/*.sls $(DESTDIR)/srv/salt/ceph/remove/mgr/
install -d -m 755 $(DESTDIR)/srv/salt/ceph/remove/mon
Expand Down
11 changes: 8 additions & 3 deletions deepsea.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ systemctl try-restart salt-api > /dev/null 2>&1 || :
%dir %attr(0755, salt, salt) /srv/pillar/ceph/benchmarks/fio
%dir %attr(0755, salt, salt) /srv/pillar/ceph/benchmarks/templates
%dir /srv/salt/_modules
%dir /srv/salt/_states
%dir /srv/salt/_states/__pycache__
%dir /srv/modules
%dir /srv/modules/modules
%dir /srv/modules/runners
Expand Down Expand Up @@ -242,13 +244,13 @@ systemctl try-restart salt-api > /dev/null 2>&1 || :
%dir /srv/salt/ceph/redeploy/osds
%dir /srv/salt/ceph/redeploy/nodes
%dir /srv/salt/ceph/remove
%dir /srv/salt/ceph/remove/destroyed
%dir /srv/salt/ceph/remove/ganesha
%dir /srv/salt/ceph/remove/igw
%dir /srv/salt/ceph/remove/igw/auth
%dir /srv/salt/ceph/remove/mon
%dir /srv/salt/ceph/remove/mds
%dir /srv/salt/ceph/remove/mgr
%dir /srv/salt/ceph/remove/migrated
%dir /srv/salt/ceph/remove/rgw
%dir /srv/salt/ceph/remove/storage
%dir /srv/salt/ceph/remove/storage/drain
Expand Down Expand Up @@ -408,6 +410,7 @@ systemctl try-restart salt-api > /dev/null 2>&1 || :
%config(noreplace) %attr(-, salt, salt) /etc/salt/master.d/*.conf
/srv/modules/modules/*.py*
/srv/modules/runners/*.py*
%exclude /srv/modules/runners/smoketests.py
/srv/modules/utils/*.py*
%config %attr(-, salt, salt) /srv/pillar/top.sls
%config %attr(-, salt, salt) /srv/pillar/ceph/init.sls
Expand All @@ -419,6 +422,8 @@ systemctl try-restart salt-api > /dev/null 2>&1 || :
%config(noreplace) %attr(-, salt, salt) /srv/pillar/ceph/deepsea_minions.sls
%config %attr(-, salt, salt) /srv/pillar/ceph/stack/stack.cfg
/srv/salt/_modules/*.py*
/srv/salt/_states/*.py*
/srv/salt/_states/__pycache__/*.py*
%config /srv/salt/ceph/admin/*.sls
%config /srv/salt/ceph/admin/files/*.j2
%config /srv/salt/ceph/admin/key/*.sls
Expand Down Expand Up @@ -565,7 +570,8 @@ systemctl try-restart salt-api > /dev/null 2>&1 || :
%config /srv/salt/ceph/remove/igw/auth/*.sls
%config /srv/salt/ceph/remove/mon/*.sls
%config /srv/salt/ceph/remove/mds/*.sls
%config /srv/salt/ceph/remove/migrated/*.sls
%config /srv/salt/ceph/remove/destroyed/*.sls
%config /srv/salt/ceph/remove/migrated
%config /srv/salt/ceph/remove/mgr/*.sls
%config /srv/salt/ceph/remove/openattic/*.sls
%config /srv/salt/ceph/remove/rgw/*.sls
Expand Down Expand Up @@ -747,5 +753,4 @@ the README for more information.
%{_libexecdir}/deepsea/qa
/srv/salt/ceph/functests
/srv/salt/ceph/tests

%changelog
60 changes: 60 additions & 0 deletions srv/modules/runners/advise.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,63 @@ def networks():
__func_alias__ = {
'help_': 'help',
}


def osds():
"""
Inform the admin of pending changes and appropriate actions
Note: I went with the mapping here such as 'unconfigured' implies
'deploy'. This is more about communicating with the maintainers
although picking the "best" name and propogating may be a solution.
The deploy and redeploy are osd methods.
"""
local = salt.client.LocalClient()
report = local.cmd('I@roles:storage', 'osd.report',
['human=False'], tgt_type="compound")

bold = '\033[1m'
endc = '\033[0m'

unconfigured = _tidy('unconfigured', report)
changed = _tidy('changed', report)
unmounted = _tidy('unmounted', report)

messages = {'deploy': {'header': '\nThese devices will be deployed',
'footer': "Run 'salt-run state.orch ceph.stage.3'"},
'redeploy': {'header': "\nThe devices will be redeployed",
'footer': "Run 'salt-run state.orch ceph.migrate.osds'"},
'stale': {'header': "\nVerify that these devices are in the desired state",
'footer': "Run 'salt MINION osd.delete_grain ID' for a stale entry"}}

if unconfigured:
print(messages['deploy']['header'])
print("{}{}{}".format(bold, unconfigured, endc))
print(messages['deploy']['footer'])

if changed:
print(messages['redeploy']['header'])
print("{}{}{}".format(bold, changed, endc))
print(messages['redeploy']['footer'])

if unmounted:
print(messages['stale']['header'])
print("{}{}{}".format(bold, unmounted, endc))
print(messages['stale']['footer'])

return ""


def _tidy(key, report):
"""
Return a line of minion followed by comma separated devices if present
"""
line = ""
for minion in sorted(report):
if report[minion][key]:
if len(minion) + len(", ".join(report[minion][key])) < 80:
line += "{}: {}\n".format(minion, ", ".join(sorted(report[minion][key])))
else:
line += "\n{}:\n {}\n".format(minion, "\n ".join(sorted(report[minion][key])))
return line
12 changes: 12 additions & 0 deletions srv/modules/runners/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ def proposal(filename="/srv/pillar/ceph/proposals/policy.cfg", dryrun=False):
return True


def organize(filename="/srv/pillar/ceph/proposals/policy.cfg"):
"""
Read the passed filename, organize the files with common subdirectories
"""
if not os.path.isfile(filename):
log.warning("{} is missing".format(filename))
return ""
pillar_data = PillarData()
common = pillar_data.organize(filename)
return common


def convert(filename="/srv/pillar/ceph/proposals/policy.cfg"):
"""
Convert the hardware profiles that policy.cfg is using and update
Expand Down
71 changes: 19 additions & 52 deletions srv/modules/runners/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,72 +18,39 @@ def help_():
"""
Usage
"""
usage = ('salt-run remove.osd id:\n\n'
usage = ('salt-run remove.osd id [id ...][force=True]:\n\n'
' Removes an OSD\n'
'\n\n')
print(usage)
return ""


def osd(id_, drain=False):
def osd(*args, **kwargs):
"""
Removes an OSD gracefully
Remove an OSD gracefully or forcefully. Always attempt to remove
ID from Ceph even if OSD has been removed from the minion.
"""
runner_cli = salt.runner.RunnerClient(
salt.config.client_config('/etc/salt/master'))
result = __salt__['replace.osd'](*args, called=True, **kwargs)

if not runner_cli.cmd('disengage.check'):
log.error(('Safety is not disengaged...refusing to remove OSD',
' run "salt-run disengage.safety" first'
' THIS WILL CAUSE DATA LOSS.'))
return False
# Replace OSD exited early
if not result:
return ""

if id_ < 0:
log.error('Bogus id supplied...OSDs have IDs >= 0')
return False
master_minion = result['master_minion']
osds = result['osds']

local_cli = salt.client.LocalClient()
local = salt.client.LocalClient()

osds = local_cli.cmd('I@roles:storage', 'osd.list', tgt_type='compound')
for osd_id in osds:
cmds = ['ceph osd crush remove osd.{}'.format(osd_id),
'ceph auth del osd.{}'.format(osd_id),
'ceph osd rm {}'.format(osd_id)]

host = ''
for _osd in osds:
if '{}'.format(id_) in osds[_osd]:
host = _osd
break
else:
log.error('No OSD with ID {} found...giving up'.format(id_))
return False
print("Removing osd {} from Ceph".format(osd_id))
for cmd in cmds:
local.cmd(master_minion, 'cmd.run', [cmd], tgt_type='compound')

master_minion = list(local_cli.cmd('I@roles:master', 'pillar.get',
['master_minion'],
tgt_type='compound').items())[0][1]

if drain:
log.info('Draining OSD {} now'.format(id_))
ret = local_cli.cmd(host, 'osd.zero_weight', [id_])

log.info('Setting OSD {} out'.format(id_))

ret = local_cli.cmd(master_minion, 'cmd.run',
['ceph osd out {}'.format(id_)])

log.info('Stopping and wiping OSD {} now'.format(id_))

ret = local_cli.cmd(host, 'osd.remove', [id_])
log.info(ret)

ret = local_cli.cmd(master_minion, 'cmd.run',
['ceph osd crush remove osd.{}'.format(id_)])
log.info(ret)
ret = local_cli.cmd(master_minion, 'cmd.run',
['ceph auth del osd.{}'.format(id_)])
log.info(ret)
ret = local_cli.cmd(master_minion, 'cmd.run',
['ceph osd rm {}'.format(id_)])
log.info(ret)

return True
return ""

__func_alias__ = {
'help_': 'help',
Expand Down
Loading

0 comments on commit 4b426b2

Please sign in to comment.