diff --git a/pkg/daemon/update.go b/pkg/daemon/update.go index 6fdaaa91b6..a041a56df6 100644 --- a/pkg/daemon/update.go +++ b/pkg/daemon/update.go @@ -622,6 +622,13 @@ func (dn *Daemon) deleteStaleData(oldConfig, newConfig *mcfgv1.MachineConfig) er for j := range u.Dropins { path := filepath.Join(pathSystemd, u.Name+".d", u.Dropins[j].Name) if _, ok := newDropinSet[path]; !ok { + if _, err := os.Stat(origFileName(path)); err == nil { + if err := os.Rename(origFileName(path), path); err != nil { + return err + } + glog.V(2).Infof("Restored dropoin %q", path) + continue + } glog.V(2).Infof("Deleting stale systemd dropin file: %s", path) if err := os.Remove(path); err != nil { newErr := fmt.Errorf("unable to delete %s: %s", path, err) @@ -696,6 +703,9 @@ func (dn *Daemon) writeUnits(units []igntypes.Unit) error { for i := range u.Dropins { glog.Infof("Writing systemd unit dropin %q", u.Dropins[i].Name) dpath := filepath.Join(pathSystemd, u.Name+".d", u.Dropins[i].Name) + if err := createOrigFile(dpath); err != nil { + return err + } if err := writeFileAtomicallyWithDefaults(dpath, []byte(u.Dropins[i].Contents)); err != nil { return fmt.Errorf("failed to write systemd unit dropin %q: %v", u.Dropins[i].Name, err) } diff --git a/templates/common/_base/files/etc-systemd-system-crio.service.d-10-default-env.conf.yaml b/templates/common/_base/files/etc-systemd-system-crio.service.d-10-default-env.conf.yaml index 52b9c9fd40..42482b07d8 100644 --- a/templates/common/_base/files/etc-systemd-system-crio.service.d-10-default-env.conf.yaml +++ b/templates/common/_base/files/etc-systemd-system-crio.service.d-10-default-env.conf.yaml @@ -1,6 +1,6 @@ filesystem: "root" mode: 0644 -path: "/etc/systemd/system/crio.service.d/10-default-env.conf" +path: "/etc/systemd/system/crio.service.d/10-mco-default-env.conf" contents: inline: | {{if .Proxy -}} diff --git a/templates/common/_base/files/etc-systemd-system-kubelet.service.d-10-default-env.conf.yaml b/templates/common/_base/files/etc-systemd-system-kubelet.service.d-10-default-env.conf.yaml index 227cca12e5..2334f248e9 100644 --- a/templates/common/_base/files/etc-systemd-system-kubelet.service.d-10-default-env.conf.yaml +++ b/templates/common/_base/files/etc-systemd-system-kubelet.service.d-10-default-env.conf.yaml @@ -1,6 +1,6 @@ filesystem: "root" mode: 0644 -path: "/etc/systemd/system/kubelet.service.d/10-default-env.conf" +path: "/etc/systemd/system/kubelet.service.d/10-mco-default-env.conf" contents: inline: | {{if .Proxy -}} diff --git a/templates/common/_base/files/etc-systemd-system-machine-config-daemon-host.service.d-10-default-env.conf.yaml b/templates/common/_base/files/etc-systemd-system-machine-config-daemon-host.service.d-10-default-env.conf.yaml index 01a376035c..7454598efe 100644 --- a/templates/common/_base/files/etc-systemd-system-machine-config-daemon-host.service.d-10-default-env.conf.yaml +++ b/templates/common/_base/files/etc-systemd-system-machine-config-daemon-host.service.d-10-default-env.conf.yaml @@ -1,6 +1,6 @@ filesystem: "root" mode: 0644 -path: "/etc/systemd/system/machine-config-daemon-host.service.d/10-default-env.conf" +path: "/etc/systemd/system/machine-config-daemon-host.service.d/10-mco-default-env.conf" contents: inline: | {{if .Proxy -}} diff --git a/templates/common/_base/files/etc-systemd-system-pivot.service.d-10-default-env.conf.yaml b/templates/common/_base/files/etc-systemd-system-pivot.service.d-10-default-env.conf.yaml index 524900b6f5..03cae632d0 100644 --- a/templates/common/_base/files/etc-systemd-system-pivot.service.d-10-default-env.conf.yaml +++ b/templates/common/_base/files/etc-systemd-system-pivot.service.d-10-default-env.conf.yaml @@ -1,6 +1,6 @@ filesystem: "root" mode: 0644 -path: "/etc/systemd/system/pivot.service.d/10-default-env.conf" +path: "/etc/systemd/system/pivot.service.d/10-mco-default-env.conf" contents: inline: | {{if .Proxy -}}