1616
1717from .builders import build_builder_args , get_builder_uris
1818from .cache import check_cache_connectivity , copy_to_cache , get_substituter_args
19- from .constants import CSI_GCROOTS , CSI_VOLUMES , NIX_BUILD_TIMEOUT
19+ from .constants import CSI_GCROOTS , CSI_SOCKET_PATH , CSI_VOLUMES , NIX_BUILD_TIMEOUT
2020from .identityservicer import IdentityServicer
2121from .nix import build_flake_ref , build_nix_expr , build_store_path , get_current_system
22- from .store import extract_store_paths
23- from .volume import cleanup_failed_volume , is_mount , mount_volume , prepare_volume , unmount
22+ from .store import extract_store_paths_set
23+ from .volume import (
24+ cleanup_failed_volume ,
25+ is_mount ,
26+ mount_volume ,
27+ prepare_volume ,
28+ unmount ,
29+ )
2430
2531logger = logging .getLogger ("nix-csi" )
2632
@@ -81,7 +87,7 @@ async def _build_pod_packages(
8187 )
8288
8389 package_paths = []
84- pod_store_paths = set ( extract_store_paths ( pod .raw ) )
90+ pod_store_paths = extract_store_paths_set ( pod .raw )
8591
8692 for package_path in pod_store_paths :
8793 logger .debug (f"{ package_path = } " )
@@ -155,7 +161,13 @@ async def NodePublishVolume(self, stream):
155161 if request is None :
156162 raise GRPCError (Status .INVALID_ARGUMENT , "NodePublishVolumeRequest is None" )
157163
158- logger .info (f"Publish { request .target_path } " )
164+ logger .info (
165+ "Publishing volume" ,
166+ extra = {
167+ "volume_id" : request .volume_id ,
168+ "target_path" : request .target_path ,
169+ },
170+ )
159171
160172 if not request .volume_context .get ("csi.storage.k8s.io/ephemeral" ):
161173 raise GRPCError (
@@ -230,7 +242,13 @@ async def NodeUnpublishVolume(self, stream):
230242 if request is None :
231243 raise ValueError ("NodeUnpublishVolumeRequest is None" )
232244
233- logger .info (f"Unpublish { request .target_path } " )
245+ logger .info (
246+ "Unpublishing volume" ,
247+ extra = {
248+ "volume_id" : request .volume_id ,
249+ "target_path" : request .target_path ,
250+ },
251+ )
234252
235253 async with self .volumeLocks [request .volume_id ]:
236254 target_path = Path (request .target_path )
@@ -262,9 +280,7 @@ async def NodeUnpublishVolume(self, stream):
262280 shutil .rmtree (gc_root , ignore_errors = True )
263281 logger .debug (f"unlinked { gc_root = } " )
264282 except Exception as ex :
265- raise GRPCError (
266- Status .INTERNAL , f"unlinking { target_path = } failed" , ex
267- )
283+ raise GRPCError (Status .INTERNAL , f"unlinking { gc_root = } failed" , ex )
268284
269285 # Remove hardlink farm
270286 volume_path = CSI_VOLUMES / request .volume_id
@@ -274,7 +290,7 @@ async def NodeUnpublishVolume(self, stream):
274290 logger .debug (f"removed { volume_path = } " )
275291 except Exception as ex :
276292 raise GRPCError (
277- Status .INTERNAL , f"recursive removing { target_path = } failed" , ex
293+ Status .INTERNAL , f"removing { volume_path = } failed" , ex
278294 )
279295
280296 await stream .send_message (csi_pb2 .NodeUnpublishVolumeResponse ())
@@ -313,7 +329,7 @@ async def NodeUnstageVolume(self, stream):
313329
314330
315331async def serve ():
316- sock_path = "/csi/csi.sock"
332+ sock_path = CSI_SOCKET_PATH
317333 Path (sock_path ).unlink (missing_ok = True )
318334
319335 identityServicer = IdentityServicer ()
0 commit comments