Skip to content

Commit f3cbe49

Browse files
committed
Verify CRI connectivity at NRI startup
Call list_container_ids during _nri_run() init to fail fast if the CRI socket is unreachable. Without CRI access, garbage collection of stale volumes won't work and the node will fill up.
1 parent 486636d commit f3cbe49

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

pkgs/nixkube/src/nri/server.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
NRI_PLUGIN_NAME,
3131
NRI_RUNTIME_SOCKET,
3232
)
33-
from ..cri import get_cri_socket
33+
from ..cri import get_cri_socket, list_container_ids
3434
from ..events import report_event
3535
from ..nix import build_packages, get_build_args, get_closure_paths, get_current_system
3636
from ..store import extract_store_paths
@@ -705,8 +705,11 @@ async def _nri_run() -> None:
705705
zmq_server = ZeroMQServer()
706706
await zmq_server.initialize()
707707

708-
# Discover CRI socket for garbage collection
708+
# Discover CRI socket and verify connectivity. Without CRI access, garbage
709+
# collection of stale volumes won't work and the node will fill up.
709710
cri_socket = await get_cri_socket()
711+
containers = await list_container_ids(Path("/host") / cri_socket.relative_to("/"))
712+
logger.info(f"CRI connectivity verified: {len(containers)} containers")
710713

711714
plugin = NriPlugin(zmq_server, cri_socket)
712715
mapping = plugin.__mapping__()

0 commit comments

Comments
 (0)