diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index c35f72fccb..51dd35a136 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -572,14 +572,23 @@ func (dn *Daemon) nodeStateSyncHandler() error { // or there is a new config we need to apply // When using systemd configuration we write the file if dn.useSystemdService { - r, err := systemd.WriteConfFile(latestState, dn.devMode, dn.platform) + systemdConfModified, err := systemd.WriteConfFile(latestState, dn.devMode, dn.platform) if err != nil { glog.Errorf("nodeStateSyncHandler(): failed to write configuration file for systemd mode: %v", err) return err } - reqDrain = reqDrain || r - reqReboot = reqReboot || r - glog.V(0).Infof("nodeStateSyncHandler(): systemd mode reqDrain %v, reqReboot %v disableDrain %v", r, r, dn.disableDrain) + if systemdConfModified { + // remove existing result file to make sure that we will not use outdated result, e.g. in case if + // systemd service was not triggered for some reason + err = systemd.RemoveSriovResult() + if err != nil { + glog.Errorf("nodeStateSyncHandler(): failed to remove result file for systemd mode: %v", err) + return err + } + } + reqDrain = reqDrain || systemdConfModified + reqReboot = reqReboot || systemdConfModified + glog.V(0).Infof("nodeStateSyncHandler(): systemd mode reqDrain %v, reqReboot %v disableDrain %v", systemdConfModified, systemdConfModified, dn.disableDrain) err = systemd.WriteSriovSupportedNics() if err != nil { diff --git a/pkg/systemd/systemd.go b/pkg/systemd/systemd.go index 504fcf3890..a38e83191b 100644 --- a/pkg/systemd/systemd.go +++ b/pkg/systemd/systemd.go @@ -204,6 +204,20 @@ func ReadSriovResult() (*SriovResult, error) { return result, err } +func RemoveSriovResult() error { + err := os.Remove(SriovHostSystemdResultPath) + if err != nil { + if os.IsNotExist(err) { + glog.V(2).Infof("RemoveSriovResult(): result file not found") + return nil + } + glog.Errorf("RemoveSriovResult(): failed to remove sriov result file on path %s: %v", SriovHostSystemdResultPath, err) + return err + } + glog.V(2).Infof("RemoveSriovResult(): result file removed") + return nil +} + func WriteSriovSupportedNics() error { _, err := os.Stat(sriovHostSystemdSupportedNicPath) if err != nil {