From c506826a17573ec76de73ee72a50799592edf7f6 Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Sat, 7 Sep 2024 16:35:39 +0200 Subject: [PATCH] deferred: tuned: fix reload trigger when inplace update 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 --- pkg/tuned/controller.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/tuned/controller.go b/pkg/tuned/controller.go index eb26cdee8e..b3eec521e7 100644 --- a/pkg/tuned/controller.go +++ b/pkg/tuned/controller.go @@ -1031,7 +1031,6 @@ 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) @@ -1039,11 +1038,11 @@ func (c *Controller) changeSyncerTuneD(change Change) (synced bool, err error) { 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. @@ -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{