Skip to content

Commit

Permalink
pkg/daemon: make force use the force
Browse files Browse the repository at this point in the history
force does 2 things mainly: skip validation and "force" update to the desiredConfig. That doesn't mean the MCD can't fail anymore, we're just forcing a rollout that wouldn't have normally happened. The usual cases are: pivot not booting into the right ostree, someone writes the force file and the update is retryed (but still can fail!) or somebody touches files on disk, use the force file to bring the system back to desiredConfig w/o validating (and degrading)

Signed-off-by: Antonio Murdaca <[email protected]>
  • Loading branch information
runcom committed Jul 2, 2020
1 parent fd75943 commit 0ec7a80
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ func (dn *Daemon) checkStateOnFirstRun() error {
if currentOnDisk != nil && state.currentConfig.GetName() != currentOnDisk.GetName() {
// The on disk state (if available) is always considered truth.
// We want to handle the case where etcd state was restored from a backup.
dn.logSystem("Disk currentConfig %s overrides node annotation %s", currentOnDisk.GetName(), state.currentConfig.GetName())
dn.logSystem("Disk currentConfig %s overrides node's currentConfig annotation %s", currentOnDisk.GetName(), state.currentConfig.GetName())
state.currentConfig = currentOnDisk
}

Expand All @@ -1048,6 +1048,7 @@ func (dn *Daemon) checkStateOnFirstRun() error {
glog.Infof("Validating against current config %s", state.currentConfig.GetName())
expectedConfig = state.currentConfig
}

if _, err := os.Stat(constants.MachineConfigDaemonForceFile); err != nil {
if err := dn.validateOnDiskState(expectedConfig); err != nil {
return fmt.Errorf("unexpected on-disk state validating against %s: %v", expectedConfig.GetName(), err)
Expand All @@ -1058,6 +1059,7 @@ func (dn *Daemon) checkStateOnFirstRun() error {
if err := os.Remove(constants.MachineConfigDaemonForceFile); err != nil {
return errors.Wrap(err, "failed to remove force validation file")
}
return dn.triggerUpdateWithMachineConfig(state.currentConfig, state.desiredConfig)
}

// We've validated our state. In the case where we had a pendingConfig,
Expand Down

0 comments on commit 0ec7a80

Please sign in to comment.