Skip to content

Commit

Permalink
Merge pull request #1809 from cgwalters/pivot-remove-reboot-code
Browse files Browse the repository at this point in the history
Remove pivot invocations of systemctl reboot
  • Loading branch information
openshift-merge-robot committed Jun 23, 2020
2 parents 85972a9 + dd50202 commit 135a7cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
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.
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

0 comments on commit 135a7cc

Please sign in to comment.