Skip to content

Commit

Permalink
tuned: controller: align to left
Browse files Browse the repository at this point in the history
Simplify the flow aligning code to the left.
No intended changes in behavior.

xref: openshift#1019 (comment)

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Jul 23, 2024
1 parent aeebf6f commit b7b6c39
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkg/tuned/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1406,30 +1406,27 @@ func (c *Controller) storeDeferredUpdate(deferredFP string) (derr error) {
// If the file is absent, a node restart is assumed and true is returned.
// - Error if any.
func (c *Controller) recoverAndClearDeferredUpdate() (string, bool, error) {
isReboot := false

deferredFP, err := os.ReadFile(tunedDeferredUpdatePersistentFilePath)
if err != nil {
if os.IsNotExist(err) {
klog.Infof("recover: no pending deferred change")
return "", isReboot, nil
return "", false, nil
}
klog.Infof("recover: failed to restore pending deferred change: %v", err)
return "", isReboot, err
return "", false, err
}
pendingFP := strings.TrimSpace(string(deferredFP))
err = os.Remove(tunedDeferredUpdatePersistentFilePath)
klog.Infof("recover: found pending deferred update: %q", pendingFP)

if _, errEph := os.Stat(tunedDeferredUpdateEphemeralFilePath); errEph != nil {
if os.IsNotExist(errEph) {
isReboot = true
} else {
klog.Infof("recover: failed to detect node restart, assuming not: %v", err)
return "", false, errEph
return pendingFP, true, err
}
klog.Infof("recover: failed to detect node restart, assuming not: %v", err)
return "", false, errEph
}
return pendingFP, isReboot, err
return pendingFP, false, err
}

func (c *Controller) informerEventHandler(workqueueKey wqKeyKube) cache.ResourceEventHandlerFuncs {
Expand Down

0 comments on commit b7b6c39

Please sign in to comment.