Skip to content

Commit e0d64ff

Browse files
committed
Move systemd checks
1 parent ef1a73d commit e0d64ff

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

pkg/mig/reconfigure/reconfigure.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,6 @@ func (r *Reconfigure) isConfigAlreadyApplied() bool {
307307

308308
// persistConfigIfNeeded persists the configuration if needed
309309
func (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
329324
func (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]
331331
Environment="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
504508
func (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

724723
func (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

Comments
 (0)