Skip to content

Commit

Permalink
daemon: fix rebootless SIGTERM handling
Browse files Browse the repository at this point in the history
The machine-config-daemon gets stuck blocking SIGTERM on rebootless
updatesbecause it only removes its SIGTERM protection when it reboots
or when it encounters an error in the triggerUpdateWithmachineConfig->
update->performPostConfigChangeAction cycle.

This changes the behavior such that it will remove the protection on
a successful rebootless update and adds some logging messages so it's
more clear when it starts and stops protecting itself.
  • Loading branch information
jkyros authored and openshift-cherrypick-robot committed Jun 23, 2021
1 parent 3f6db24 commit a7ef54f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,9 @@ func (dn *Daemon) update(oldConfig, newConfig *mcfgv1.MachineConfig) (retErr err

dn.catchIgnoreSIGTERM()
defer func() {
if retErr != nil {
dn.cancelSIGTERM()
}
// now that we do rebootless updates, we need to turn off our SIGTERM protection
// regardless of how we leave the "update loop"
dn.cancelSIGTERM()
}()

oldConfigName := oldConfig.GetName()
Expand Down Expand Up @@ -1893,13 +1893,15 @@ func (dn *Daemon) catchIgnoreSIGTERM() {
if dn.updateActive {
return
}
glog.Info("Adding SIGTERM protection")
dn.updateActive = true
}

func (dn *Daemon) cancelSIGTERM() {
dn.updateActiveLock.Lock()
defer dn.updateActiveLock.Unlock()
if dn.updateActive {
glog.Info("Removing SIGTERM protection")
dn.updateActive = false
}
}
Expand Down

0 comments on commit a7ef54f

Please sign in to comment.