mgr/cephadm: When create osd which include db, _create_daemon will be executed twice. So we should filter the db type

Signed-off-by: jianglong01 <jianglong01@qianxin.com>
This commit is contained in:
jianglong01 2021-06-08 14:00:48 +08:00
parent 7fc07dd728
commit ca52b49351
2 changed files with 38 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

@ -1221,7 +1221,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', {
@ -1239,7 +1239,41 @@ 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)
assert cephadm_module._osd_activate(
['test']).stdout == "Created osd(s) 1 on host 'test'"
@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)