Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
logging: Add further log fields on error
Browse files Browse the repository at this point in the history
Supplement the existing logs when errors occur with further structured
log fields.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Mar 22, 2018
1 parent 712d846 commit 44ccd8f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ksm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"sync"
"syscall"
"time"

"github.com/sirupsen/logrus"
)

type ksmSetting struct {
Expand Down Expand Up @@ -286,8 +288,9 @@ func (k *ksm) throttle() {
// We got kicked, this means a new VM has been created.
// We will enter the aggressive setting until we throttle down.
_ = throttleTimer.Stop()
if err := k.tune(ksmSettings[ksmAggressive]); err != nil {
throttlerLog.WithError(err).Error("kick failed to tune")
mode := ksmAggressive
if err := k.tune(ksmSettings[mode]); err != nil {
throttlerLog.WithError(err).WithField("ksm-mode", mode).Error("kick failed to tune")
continue
}

Expand All @@ -313,10 +316,14 @@ func (k *ksm) throttle() {
continue
}

nextKnob := ksmThrottleIntervals[k.currentKnob].nextKnob
interval := ksmThrottleIntervals[k.currentKnob].interval
currentKnob := k.currentKnob
nextKnob := ksmThrottleIntervals[currentKnob].nextKnob
interval := ksmThrottleIntervals[currentKnob].interval
if err := k.tune(ksmSettings[nextKnob]); err != nil {
throttlerLog.WithError(err).Error("timer failed to tune")
throttlerLog.WithError(err).WithFields(logrus.Fields{
"current-ksm-mode": currentKnob,
"next-ksm-mode": nextKnob,
}).Error("timer failed to tune")
continue
}

Expand Down

0 comments on commit 44ccd8f

Please sign in to comment.