Skip to content

Commit f2edb72

Browse files
authored
Merge pull request ceph#62728 from adk3798/cephadm-core-status-update-no-cinfo
cephadm: still set keep_container_info key in CoreStatusUpdater when cinfo is None Reviewed-by: John Mulligan <[email protected]>
2 parents 6d7d671 + 4940596 commit f2edb72

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

src/cephadm/cephadmlib/container_lookup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ def infer_local_ceph_image(
134134
images_in_use_by_daemon = set(
135135
d.image_id for d, n in matching_daemons if n == daemon_name
136136
)
137-
images_in_use = set(d.image_id for d, _ in matching_daemons)
137+
images_in_use = set(
138+
d.image_id for d, _ in matching_daemons if d is not None
139+
)
138140

139141
# prioritize images
140142
def _keyfunc(image: ImageInfo) -> Tuple[bool, bool, str]:

src/cephadm/cephadmlib/listing_updaters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def update(
5959
data_dir, identity.fsid, identity.daemon_name
6060
)
6161
cinfo = get_container_stats(ctx, identity)
62+
if self.keep_container_info:
63+
val[self.keep_container_info] = cinfo
6264
if cinfo:
63-
if self.keep_container_info:
64-
val[self.keep_container_info] = cinfo
6565
container_id = cinfo.container_id
6666
image_name = cinfo.image_name
6767
image_id = cinfo.image_id

src/cephadm/tests/test_cephadm.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,30 @@ def test_infer_local_ceph_image(self, params, funkypatch):
877877
image = _cephadm.infer_local_ceph_image(ctx, ctx.container_engine)
878878
assert image == expected
879879

880+
def test_infer_local_ceph_image_no_cinfo(self, funkypatch):
881+
ctx = _cephadm.CephadmContext()
882+
ctx.fsid = '00000000-0000-0000-0000-0000deadbeez'
883+
ctx.container_engine = mock_podman()
884+
885+
out = """quay.ceph.io/ceph-ci/ceph@sha256:d6d1f4ab7148145467d9b632efc89d75710196434cba00aec5571b01e15b8a99|1b58ca4f6df|test|2025-01-21 16:54:41 +0000 UTC
886+
quay.ceph.io/ceph-ci/ceph@sha256:8eb43767c40d3e2d8cdb7577904f5f0b94373afe2dde29672c2b0001bd098789|c17226ffd482|test|2025-01-22 16:54:41 +0000 UTC"""
887+
funkypatch.patch('cephadmlib.call_wrappers.call').return_value = (
888+
out,
889+
'',
890+
0,
891+
)
892+
funkypatch.patch(
893+
'cephadmlib.listing_updaters.CoreStatusUpdater'
894+
)().expand.side_effect = lambda ctx, v: v
895+
funkypatch.patch(
896+
'cephadmlib.listing.daemons_matching'
897+
).return_value = [
898+
{'_container_info': None, 'name': 'mon.vm-00'},
899+
{'_container_info': None, 'name': 'mgr.vm-00.cdjeee'}
900+
]
901+
image = _cephadm.infer_local_ceph_image(ctx, ctx.container_engine)
902+
assert image == 'quay.ceph.io/ceph-ci/ceph@sha256:8eb43767c40d3e2d8cdb7577904f5f0b94373afe2dde29672c2b0001bd098789'
903+
880904
@pytest.mark.parametrize('daemon_filter, by_name, daemon_list, container_stats, output',
881905
[
882906
# get container info by type ('mon')

src/cephadm/tests/test_listing.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,28 @@ def _fake_call(ctx, cmd, *args, **kwargs):
229229
edl.assert_checked_all()
230230

231231

232+
def test_core_status_update_no_cinfo(cephadm_fs, funkypatch):
233+
_cephadm = import_cephadm()
234+
235+
_get_container_stats = funkypatch.patch('cephadmlib.container_types.get_container_stats')
236+
_get_container_stats.return_value = None
237+
238+
fsid = 'dc93cfee-ddc5-11ef-a056-525400220000'
239+
_cinfo_key = '_keep_container_info'
240+
241+
updater = _cephadm.CoreStatusUpdater(keep_container_info=_cinfo_key)
242+
d_id = _cephadm.DaemonIdentity(
243+
fsid = fsid,
244+
daemon_type = 'mon',
245+
daemon_id = 'host1',
246+
)
247+
val = {}
248+
with with_cephadm_ctx([], mock_cephadm_call_fn=False) as ctx:
249+
updater.update(val, ctx, d_id, f'/var/lib/ceph/{fsid}')
250+
assert _cinfo_key in val
251+
assert val[_cinfo_key] is None
252+
253+
232254
def test_list_daemons_detail_mgrnotrunning(cephadm_fs, funkypatch):
233255
_cephadm = import_cephadm()
234256
_call = funkypatch.patch('cephadmlib.call_wrappers.call')

0 commit comments

Comments
 (0)