images_in_use_by_daemon = set(
d.image_id for d, n in matching_daemons if n == daemon_name
)
- images_in_use = set(d.image_id for d, _ in matching_daemons)
+ images_in_use = set(
+ d.image_id for d, _ in matching_daemons if d is not None
+ )
# prioritize images
def _keyfunc(image: ImageInfo) -> Tuple[bool, bool, str]:
data_dir, identity.fsid, identity.daemon_name
)
cinfo = get_container_stats(ctx, identity)
+ if self.keep_container_info:
+ val[self.keep_container_info] = cinfo
if cinfo:
- if self.keep_container_info:
- val[self.keep_container_info] = cinfo
container_id = cinfo.container_id
image_name = cinfo.image_name
image_id = cinfo.image_id
image = _cephadm.infer_local_ceph_image(ctx, ctx.container_engine)
assert image == expected
+ def test_infer_local_ceph_image_no_cinfo(self, funkypatch):
+ ctx = _cephadm.CephadmContext()
+ ctx.fsid = '00000000-0000-0000-0000-0000deadbeez'
+ ctx.container_engine = mock_podman()
+
+ out = """quay.ceph.io/ceph-ci/ceph@sha256:d6d1f4ab7148145467d9b632efc89d75710196434cba00aec5571b01e15b8a99|1b58ca4f6df|test|2025-01-21 16:54:41 +0000 UTC
+quay.ceph.io/ceph-ci/ceph@sha256:8eb43767c40d3e2d8cdb7577904f5f0b94373afe2dde29672c2b0001bd098789|c17226ffd482|test|2025-01-22 16:54:41 +0000 UTC"""
+ funkypatch.patch('cephadmlib.call_wrappers.call').return_value = (
+ out,
+ '',
+ 0,
+ )
+ funkypatch.patch(
+ 'cephadmlib.listing_updaters.CoreStatusUpdater'
+ )().expand.side_effect = lambda ctx, v: v
+ funkypatch.patch(
+ 'cephadmlib.listing.daemons_matching'
+ ).return_value = [
+ {'_container_info': None, 'name': 'mon.vm-00'},
+ {'_container_info': None, 'name': 'mgr.vm-00.cdjeee'}
+ ]
+ image = _cephadm.infer_local_ceph_image(ctx, ctx.container_engine)
+ assert image == 'quay.ceph.io/ceph-ci/ceph@sha256:8eb43767c40d3e2d8cdb7577904f5f0b94373afe2dde29672c2b0001bd098789'
+
@pytest.mark.parametrize('daemon_filter, by_name, daemon_list, container_stats, output',
[
# get container info by type ('mon')
edl.assert_checked_all()
+def test_core_status_update_no_cinfo(cephadm_fs, funkypatch):
+ _cephadm = import_cephadm()
+
+ _get_container_stats = funkypatch.patch('cephadmlib.container_types.get_container_stats')
+ _get_container_stats.return_value = None
+
+ fsid = 'dc93cfee-ddc5-11ef-a056-525400220000'
+ _cinfo_key = '_keep_container_info'
+
+ updater = _cephadm.CoreStatusUpdater(keep_container_info=_cinfo_key)
+ d_id = _cephadm.DaemonIdentity(
+ fsid = fsid,
+ daemon_type = 'mon',
+ daemon_id = 'host1',
+ )
+ val = {}
+ with with_cephadm_ctx([], mock_cephadm_call_fn=False) as ctx:
+ updater.update(val, ctx, d_id, f'/var/lib/ceph/{fsid}')
+ assert _cinfo_key in val
+ assert val[_cinfo_key] is None
+
+
def test_list_daemons_detail_mgrnotrunning(cephadm_fs, funkypatch):
_cephadm = import_cephadm()
_call = funkypatch.patch('cephadmlib.call_wrappers.call')