Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-28647: tuned: operand: add support for deferred updates #1019

Merged
merged 19 commits into from
Jul 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion pkg/tuned/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ type Change struct {
// Do we need to update Tuned Profile status?
profileStatus bool

// is this Change caused by a node restart?
nodeRestart bool

// The following keys are set when profile == true.
// Was debugging set in Profile k8s object?
debug bool
Expand Down Expand Up @@ -845,6 +848,34 @@ func GetBootcmdline() (string, error) {
return responseString, nil
}

// changeSyncerPostNodeRestart syncronizes the daemon status after a node restart
func (c *Controller) changeSyncerPostNodeRestart(change Change) {
if !change.nodeRestart {
return
}

klog.V(2).Infof("changeSyncerPostNodeRestart(%#v)", change)
defer klog.V(2).Infof("changeSyncerPostNodeRestart(%#v) done", change)

profiles, recommended, err := profilesRepackPath(tunedRecommendFile, tunedProfilesDirCustom)
if err != nil {
// keep going, immediate updates are expected to work as usual
// and we expect the vast majority of updates to be immediate anyway
klog.Errorf("error repacking the profile: %v", err)
klog.Infof("deferred updates likely broken")
}

profileFP := profilesFingerprint(profiles, recommended)
if (c.daemon.status & scApplied) == 0 {
klog.Infof("changeSyncerPostNodeRestart(): profile not applied after tuned reload")
return
}

klog.V(2).Infof("changeSyncerPostNodeRestart(): current effective profile fingerprint %q -> %q", c.daemon.profileFingerprintEffective, profileFP)
c.daemon.profileFingerprintEffective = profileFP
c.daemon.status &= ^scDeferred // force clear even if it was never set.
}

func (c *Controller) changeSyncerProfileStatus(change Change) (synced bool) {
klog.V(2).Infof("changeSyncerProfileStatus(%#v)", change)
defer klog.V(2).Infof("changeSyncerProfileStatus(%#v) done", change)
Expand Down Expand Up @@ -972,7 +1003,11 @@ func (c *Controller) changeSyncerRestartOrReloadTuneD() error {
// reloads as needed. Returns indication whether the change was successfully
// synced and an error. Only critical errors are returned, as non-nil errors
// will cause restart of the main control loop -- the changeWatcher() method.
func (c *Controller) changeSyncer(change Change) (synced bool, err error) {
func (c *Controller) changeSyncer(change Change) (bool, error) {
klog.V(2).Infof("changeSyncer(%#v)", change)
ffromani marked this conversation as resolved.
Show resolved Hide resolved
defer klog.V(2).Infof("changeSyncer(%#v) done", change)
// Sync internal status after a TuneD reload
c.changeSyncerPostNodeRestart(change)
// Sync k8s Profile status if/when needed.
if !c.changeSyncerProfileStatus(change) {
return false, nil
Expand Down