Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions cmd/machine-config-daemon/pivot.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (

// flag storage
var keep bool
var reboot bool
var fromEtcPullSpec bool

const (
etcPivotFile = "/etc/pivot/image-pullspec"
runPivotRebootFile = "/run/pivot/reboot-needed"
// etcPivotFile is used for 4.1 bootimages and is how the MCD
// currently communicated with this service.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: currently communicated would've made my English teacher's stomach turn 😆
Is it currently communicates or previously communicated (previously as in before this PR)?

etcPivotFile = "/etc/pivot/image-pullspec"
// File containing kernel arg changes for tuning
kernelTuningFile = "/etc/pivot/kernel-args"
cmdLineFile = "/proc/cmdline"
Expand All @@ -51,7 +51,6 @@ var pivotCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(pivotCmd)
pivotCmd.PersistentFlags().BoolVarP(&keep, "keep", "k", false, "Do not remove container image")
pivotCmd.PersistentFlags().BoolVarP(&reboot, "reboot", "r", false, "Reboot if changed")
pivotCmd.PersistentFlags().BoolVarP(&fromEtcPullSpec, "from-etc-pullspec", "P", false, "Parse /etc/pivot/image-pullspec")
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
}
Expand Down Expand Up @@ -232,29 +231,8 @@ func run(_ *cobra.Command, args []string) error {

if !changed {
glog.Info("No changes; already at target oscontainer, no kernel args provided")
return nil
}

if reboot {
glog.Infof("Rebooting as requested by cmdline flag")
} else {
// Otherwise see if it's specified by the file
_, err = os.Stat(runPivotRebootFile)
if err != nil && !os.IsNotExist(err) {
return errors.Wrapf(err, "Checking %s", runPivotRebootFile)
}
if err == nil {
glog.Infof("Rebooting due to %s", runPivotRebootFile)
reboot = true
}
}
if reboot {
// Reboot the machine if asked to do so
err := exec.Command("systemctl", "reboot").Run()
if err != nil {
return errors.Wrapf(err, "rebooting")
}
}
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/daemon/rpm-ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ func (r *RpmOstreeClient) RunPivot(osImageURL string) error {
defer close(journalStopCh)
go followPivotJournalLogs(journalStopCh)

// This is written by code injected by the MCS, but we always want the MCD to be in control of reboots
// This is written by code injected by the MCS for compatibility with 4.1 bootimages,
// remove it to clean things up.
if err := os.Remove("/run/pivot/reboot-needed"); err != nil && !os.IsNotExist(err) {
return errors.Wrap(err, "deleting pivot reboot-needed file")
}
Expand Down