Skip to content

Commit

Permalink
deferred: tuned: fix reload trigger when inplace update
Browse files Browse the repository at this point in the history
There are conditions on which we should not set the
reload flag. This avoid regression in the test
"Profile deferred when applied should trigger changes when applied fist,
then deferred when edited, if tuned restart should be kept deferred"

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Sep 9, 2024
1 parent aa9b60a commit c506826
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/tuned/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,19 +1031,18 @@ func (c *Controller) changeSyncerTuneD(change Change) (synced bool, err error) {
// Cache the value written to tunedRecommendFile.
c.daemon.recommendedProfile = change.recommendedProfile
klog.V(1).Infof("recommended TuneD profile updated from %q to %q [inplaceUpdate=%v nodeRestart=%v]", prevRecommended, change.recommendedProfile, inplaceUpdate, change.nodeRestart)
changeRecommend = true

if change.deferredMode == util.DeferUpdate && !inplaceUpdate && c.daemon.recoveredRecommendedProfile == change.recommendedProfile {
klog.V(1).Infof("recommended TuneD profile changed; skip TuneD reload [deferred=%v recoveredRecommended=%v]", change.deferredMode, c.daemon.recoveredRecommendedProfile)
// Reset because we need only once the first time we process the TuneD k8s object. Let's avoid stale data.
c.daemon.recoveredRecommendedProfile = ""
} else {
klog.V(1).Infof("recommended TuneD profile changed; trigger TuneD reload [deferred=%v]", change.deferredMode)
reload = true
changeRecommend = true
}
} else if util.IsImmediateUpdate(change.deferredMode) && (c.daemon.status&scDeferred != 0) {
klog.V(1).Infof("detected deferred update changed to immediate after object update")
reload = true
changeRecommend = true
} else {
klog.V(1).Infof("recommended profile (%s) matches current configuration", c.daemon.recommendedProfile)
// We do not need to reload the TuneD daemon, however, someone may have tampered with the k8s Profile status for this node.
Expand Down Expand Up @@ -1743,10 +1742,10 @@ func RunInCluster(stopCh <-chan struct{}, version string) error {
deferredFP, isNodeReboot, err := c.recoverAndClearDeferredUpdate()
if err != nil {
klog.ErrorS(err, "unable to recover the pending update")
} else if deferredFP == "" {
klog.Infof("starting: no pending deferred update")
} else if !isNodeReboot {
klog.Infof("starting: does not seem a node reboot, but a daemon restart. Ignoring pending deferred updates (if any)")
} else if deferredFP == "" {
klog.Infof("starting: node reboot, but no pending deferred update")
} else {
klog.Infof("starting: recovered and cleared pending deferred update %q for %s (fingerprint=%q)", recommended, restartReason(isNodeReboot), deferredFP)
c.pendingChange = &Change{
Expand Down

0 comments on commit c506826

Please sign in to comment.