@@ -307,11 +307,6 @@ func (r *Reconfigure) isConfigAlreadyApplied() bool {
307307
308308// persistConfigIfNeeded persists the configuration if needed
309309func (r * Reconfigure ) persistConfigIfNeeded () error {
310- if r .opts .ReadonlyHost {
311- log .Info ("Host root FS is mounted read-only, config cannot be persisted" )
312- return nil
313- }
314-
315310 if r .opts .HostRootMount == "" || r .opts .HostMigManagerStateFile == "" {
316311 return nil
317312 }
@@ -327,6 +322,11 @@ func (r *Reconfigure) persistConfigIfNeeded() error {
327322
328323// persistConfig persists the configuration to the state file
329324func (r * Reconfigure ) persistConfig () error {
325+ if r .opts .ReadonlyHost {
326+ log .Info ("Host root FS is mounted read-only, config cannot be persisted" )
327+ return nil
328+ }
329+
330330 config := fmt .Sprintf (`[Service]
331331Environment="MIG_PARTED_SELECTED_CONFIG=%s"
332332` , r .opts .SelectedMigConfig )
@@ -338,6 +338,10 @@ Environment="MIG_PARTED_SELECTED_CONFIG=%s"
338338 return fmt .Errorf ("failed to write config to state file: %w" , err )
339339 }
340340
341+ if r .systemdManager == nil {
342+ return nil
343+ }
344+
341345 return r .systemdManager .ReloadDaemon ()
342346}
343347
@@ -502,11 +506,6 @@ func (r *Reconfigure) handleCDI() error {
502506
503507// restartHostGPUClients restarts host GPU clients
504508func (r * Reconfigure ) restartHostGPUClients () error {
505- if r .systemdManager == nil {
506- log .Info ("No systemd manager available, not restarting down GPU clients on the host" )
507- return nil
508- }
509-
510509 log .Info ("Restarting all GPU clients previously shutdown on the host by restarting their systemd services" )
511510
512511 NoRestartHostSystemdServicesOnExit = true
@@ -722,6 +721,11 @@ func (r *Reconfigure) createCDISpec() error {
722721}
723722
724723func (r * Reconfigure ) hostStartSystemdServices () error {
724+ if r .systemdManager == nil {
725+ log .Info ("No systemd manager available, not starting anything via systemd" )
726+ return nil
727+ }
728+
725729 services := r .stoppedServices
726730 var restartServices []string
727731 if len (services ) == 0 {
0 commit comments