Merge pull request #41746 from strenuous-life/wip-cephadm-osd-create

mgr/cephadm: When create osd which include db, _create_daemon will be…

Reviewed-by: Sebastian Wagner <sewagner@redhat.com>
This commit is contained in:
Kefu Chai 2021-06-13 23:26:46 +08:00 committed by GitHub
commit 3a84d3e5d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 2 deletions

View File

@ -112,6 +112,8 @@ class OSDService(CephService):
created = []
for osd_id, osds in osds_elems.items():
for osd in osds:
if osd['type'] == 'db':
continue
if osd['tags']['ceph.cluster_fsid'] != fsid:
logger.debug('mismatched fsid, skipping %s' % osd)
continue

View File

@ -1255,7 +1255,7 @@ Traceback (most recent call last):
]
@mock.patch("cephadm.serve.CephadmServe._run_cephadm")
def test_osd_activate(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
def test_osd_activate_datadevice(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
_run_cephadm.return_value = ('{}', '', 0)
with with_host(cephadm_module, 'test', refresh_hosts=False):
cephadm_module.mock_store_set('_ceph_get', 'osd_map', {
@ -1273,9 +1273,61 @@ Traceback (most recent call last):
'tags': {
'ceph.cluster_fsid': cephadm_module._cluster_fsid,
'ceph.osd_fsid': 'uuid'
}
},
'type': 'data'
}]
}
_run_cephadm.return_value = (json.dumps(ceph_volume_lvm_list), '', 0)
_run_cephadm.reset_mock()
assert cephadm_module._osd_activate(
['test']).stdout == "Created osd(s) 1 on host 'test'"
assert _run_cephadm.mock_calls == [
mock.call('test', 'osd', 'ceph-volume',
['--', 'lvm', 'list', '--format', 'json'], no_fsid=False, image=''),
mock.call('test', 'osd.1', 'deploy',
['--name', 'osd.1', '--meta-json', mock.ANY,
'--config-json', '-', '--osd-fsid', 'uuid'],
stdin=mock.ANY, image=''),
]
@mock.patch("cephadm.serve.CephadmServe._run_cephadm")
def test_osd_activate_datadevice_dbdevice(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
_run_cephadm.return_value = ('{}', '', 0)
with with_host(cephadm_module, 'test', refresh_hosts=False):
cephadm_module.mock_store_set('_ceph_get', 'osd_map', {
'osds': [
{
'osd': 1,
'up_from': 0,
'uuid': 'uuid'
}
]
})
ceph_volume_lvm_list = {
'1': [{
'tags': {
'ceph.cluster_fsid': cephadm_module._cluster_fsid,
'ceph.osd_fsid': 'uuid'
},
'type': 'data'
}, {
'tags': {
'ceph.cluster_fsid': cephadm_module._cluster_fsid,
'ceph.osd_fsid': 'uuid'
},
'type': 'db'
}]
}
_run_cephadm.return_value = (json.dumps(ceph_volume_lvm_list), '', 0)
_run_cephadm.reset_mock()
assert cephadm_module._osd_activate(
['test']).stdout == "Created osd(s) 1 on host 'test'"
assert _run_cephadm.mock_calls == [
mock.call('test', 'osd', 'ceph-volume',
['--', 'lvm', 'list', '--format', 'json'], no_fsid=False, image=''),
mock.call('test', 'osd.1', 'deploy',
['--name', 'osd.1', '--meta-json', mock.ANY,
'--config-json', '-', '--osd-fsid', 'uuid'],
stdin=mock.ANY, image=''),
]