disable minikube-scheduled-stop.service until a user schedules a stop

pull/10548/head
Jiefeng He 2021-02-21 00:12:31 -08:00
parent 413cdf6e5b
commit 1921801b69
3 changed files with 7 additions and 9 deletions

View File

@ -8,10 +8,6 @@ define SCHEDULED_STOP_INSTALL_INIT_SYSTEMD
$(INSTALL) -D -m 644 \
$(SCHEDULED_STOP_PKGDIR)/minikube-scheduled-stop.service \
$(TARGET_DIR)/usr/lib/systemd/system/minikube-scheduled-stop.service
mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
ln -fs /usr/lib/systemd/system/minikube-scheduled-stop.service \
$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/minikube-scheduled-stop.service
endef
define SCHEDULED_STOP_INSTALL_TARGET_CMDS

View File

@ -155,9 +155,7 @@ RUN ln -fs /usr/lib/systemd/system/minikube-automount.service \
# scheduled stop service
COPY scheduled-stop/minikube-scheduled-stop /var/lib/minikube/scheduled-stop/minikube-scheduled-stop
COPY scheduled-stop/minikube-scheduled-stop.service /usr/lib/systemd/system/minikube-scheduled-stop.service
RUN ln -fs /usr/lib/systemd/system/minikube-scheduled-stop.service \
/etc/systemd/system/multi-user.target.wants/minikube-scheduled-stop.service && \
chmod +x /var/lib/minikube/scheduled-stop/minikube-scheduled-stop
RUN chmod +x /var/lib/minikube/scheduled-stop/minikube-scheduled-stop
# disable non-docker runtimes by default
RUN systemctl disable containerd && systemctl disable crio && rm /etc/crictl.yaml

View File

@ -100,8 +100,12 @@ func startSystemdService(profile string, duration time.Duration) error {
return errors.Wrap(err, "copying scheduled stop env file")
}
// restart scheduled stop service in container
sysManger := sysinit.New(runner)
return sysManger.Restart(constants.ScheduledStopSystemdService)
sysManager := sysinit.New(runner)
// enable scheduled stop service
if err := sysManager.Enable(constants.ScheduledStopSystemdService); err != nil {
return err
}
return sysManager.Restart(constants.ScheduledStopSystemdService)
}
// return the contents of the environment file for minikube-scheduled-stop systemd service