@@ -207,13 +207,11 @@ func run(ctx context.Context, cancel context.CancelFunc, flags *Flags) error {
207207 // this node's state in the CD object.
208208 if flags .cliqueID == "" {
209209 klog .Infof ("no cliqueID: register with ComputeDomain, but do not run IMEX daemon" )
210- } else {
211- // Render and write the IMEX daemon config with the current pod IP. Only
212- // required when actually starting the IMEX daemon. Fails when
213- // /etc/nvidia-imex is not mounted in.
214- if err := writeIMEXConfig (flags .podIP ); err != nil {
215- return fmt .Errorf ("writeIMEXConfig failed: %w" , err )
216- }
210+ }
211+
212+ // Render and write the IMEX daemon config with the current pod IP
213+ if err := writeIMEXConfig (flags .podIP ); err != nil {
214+ return fmt .Errorf ("writeIMEXConfig failed: %w" , err )
217215 }
218216
219217 // Prepare IMEX daemon process manager (not invoking the process yet).
@@ -308,7 +306,7 @@ func IMEXDaemonUpdateLoopWithIPs(ctx context.Context, controller *Controller, cl
308306
309307 if cliqueID == "" {
310308 klog .V (1 ).Infof ("empty cliqueID: do not start IMEX daemon" )
311- continue
309+ break
312310 }
313311
314312 klog .Infof ("Got update, (re)start IMEX daemon" )
@@ -342,7 +340,7 @@ func IMEXDaemonUpdateLoopWithDNSNames(ctx context.Context, controller *Controlle
342340
343341 if dnsNameManager .cliqueID == "" {
344342 klog .V (1 ).Infof ("empty cliqueID: do not start IMEX daemon" )
345- continue
343+ break
346344 }
347345
348346 fresh , err := processManager .EnsureStarted ()
@@ -358,7 +356,7 @@ func IMEXDaemonUpdateLoopWithDNSNames(ctx context.Context, controller *Controlle
358356 // addresses compared to the old set (then we don't need to force
359357 // the daemon to re-resolve & re-connect).
360358 if ! updated || fresh {
361- continue
359+ break
362360 }
363361
364362 // Actively ask the IMEX daemon to re-read its config and to
@@ -419,6 +417,12 @@ func writeIMEXConfig(podIP string) error {
419417 return fmt .Errorf ("error executing template: %w" , err )
420418 }
421419
420+ // Ensure the directory exists
421+ dir := filepath .Dir (imexConfigPath )
422+ if err := os .MkdirAll (dir , 0755 ); err != nil {
423+ return fmt .Errorf ("failed to create directory %s: %w" , dir , err )
424+ }
425+
422426 if err := os .WriteFile (imexConfigPath , configFile .Bytes (), 0644 ); err != nil {
423427 return fmt .Errorf ("error writing config file %v: %w" , imexConfigPath , err )
424428 }
0 commit comments