Skip to content

Commit

Permalink
feat(pkg/daemon): leave backup copy of encapsulated MC
Browse files Browse the repository at this point in the history
Rename rather than remove the encapsulated MachineConfig file after processing
on firstboot. This allows users to check what data was processed on the node
after the mcd firstboot service has run successfully.
  • Loading branch information
EvB committed Nov 4, 2019
1 parent bd84695 commit 6e8b587
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/daemon/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const (
// non-Ignition fields such as the osImageURL and kernelArguments.
MachineConfigEncapsulatedPath = "/etc/ignition-machine-config-encapsulated.json"

// MachineConfigEncapsulatedBakPath defines the path where the machineconfigdaemom-firstboot.service
// will leave a copy of the encapsulated MachineConfig in MachineConfigEncapsulatedPath after
// processing for debugging and auditing purposes.
MachineConfigEncapsulatedBakPath = "/etc/ignition-machine-config-encapsulated.json.bak"

// MachineConfigDaemonForceFile if present causes the MCD to skip checking the validity of the
// "currentConfig" state. Create this file (empty contents is fine) if you wish the MCD
// to proceed and attempt to "reconcile" to the new "desiredConfig" state regardless.
Expand Down
4 changes: 2 additions & 2 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ func (dn *Daemon) RunFirstbootCompleteMachineconfig() error {
}

// Removing this file signals completion of the initial MC processing.
if err := os.Remove(constants.MachineConfigEncapsulatedPath); err != nil {
return errors.Wrapf(err, "failed to remove %s", constants.MachineConfigEncapsulatedPath)
if err := os.Rename(constants.MachineConfigEncapsulatedPath, constants.MachineConfigEncapsulatedBakPath); err != nil {
return errors.Wrap(err, "failed to rename encapsulated MachineConfig after processing on firstboot")
}

dn.skipReboot = false
Expand Down

0 comments on commit 6e8b587

Please sign in to comment.