@@ -76,6 +76,7 @@ type Options struct {
7676 DriverLibraryPath string
7777 NvidiaSMIPath string
7878 NvidiaCDIHookPath string
79+ SystemdAvailable bool
7980 ReadonlyHost bool
8081}
8182
@@ -106,9 +107,15 @@ func New(ctx context.Context, clientset *kubernetes.Clientset, migPartedBinary [
106107 _ = os .Setenv ("DBUS_SYSTEM_BUS_ADDRESS" , hostSystemBusAddress )
107108 }
108109
109- systemdManager , err := systemd .NewManager (ctx )
110- if err != nil {
111- return nil , fmt .Errorf ("failed to initialize systemd manager: %w" , err )
110+ var systemdManager * systemd.Manager = nil
111+
112+ if opts .SystemdAvailable {
113+ mgr , err := systemd .NewManager (ctx )
114+ if err != nil {
115+ return nil , fmt .Errorf ("failed to initialize systemd manager: %w" , err )
116+ }
117+
118+ systemdManager = mgr
112119 }
113120
114121 return & Reconfigure {
@@ -300,11 +307,6 @@ func (r *Reconfigure) isConfigAlreadyApplied() bool {
300307
301308// persistConfigIfNeeded persists the configuration if needed
302309func (r * Reconfigure ) persistConfigIfNeeded () error {
303- if r .opts .ReadonlyHost {
304- log .Info ("Host root FS is mounted read-only, config cannot be persisted" )
305- return nil
306- }
307-
308310 if r .opts .HostRootMount == "" || r .opts .HostMigManagerStateFile == "" {
309311 return nil
310312 }
@@ -320,6 +322,11 @@ func (r *Reconfigure) persistConfigIfNeeded() error {
320322
321323// persistConfig persists the configuration to the state file
322324func (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+
323330 config := fmt .Sprintf (`[Service]
324331Environment="MIG_PARTED_SELECTED_CONFIG=%s"
325332` , r .opts .SelectedMigConfig )
@@ -331,6 +338,10 @@ Environment="MIG_PARTED_SELECTED_CONFIG=%s"
331338 return fmt .Errorf ("failed to write config to state file: %w" , err )
332339 }
333340
341+ if r .systemdManager == nil {
342+ return nil
343+ }
344+
334345 return r .systemdManager .ReloadDaemon ()
335346}
336347
@@ -420,6 +431,11 @@ func (r *Reconfigure) waitForPodsToBeDeleted() error {
420431
421432// shutdownHostGPUClients shuts down host GPU clients
422433func (r * Reconfigure ) shutdownHostGPUClients () error {
434+ if r .systemdManager == nil {
435+ log .Info ("No systemd manager available, not shutting down GPU clients on the host" )
436+ return nil
437+ }
438+
423439 log .Info ("Shutting down all GPU clients on the host by stopping their systemd services" )
424440
425441 services := strings .Split (r .opts .HostGPUClientServices , "," )
@@ -705,6 +721,11 @@ func (r *Reconfigure) createCDISpec() error {
705721}
706722
707723func (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+
708729 services := r .stoppedServices
709730 var restartServices []string
710731 if len (services ) == 0 {
0 commit comments