Skip to content

Commit

Permalink
Add debug log for check-in miss (#5348)
Browse files Browse the repository at this point in the history
* Add debug log for check-in miss

Logging the time details to debug flaky tests
like #4203.

* fix errcheck linter

* Log with `logp.Logger`'s `Debugf` function
  • Loading branch information
andrzej-stencel authored Sep 4, 2024
1 parent 9ed3e3d commit f29717e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/component/runtime/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type procState struct {

// commandRuntime provides the command runtime for running a component as a subprocess.
type commandRuntime struct {
log *logger.Logger
logStd *logWriter
logErr *logWriter

Expand Down Expand Up @@ -108,6 +109,7 @@ type commandRuntime struct {
// newCommandRuntime creates a new command runtime for the provided component.
func newCommandRuntime(comp component.Component, log *logger.Logger, monitor MonitoringManager) (*commandRuntime, error) {
c := &commandRuntime{
log: log,
current: comp,
monitor: monitor,
ch: make(chan ComponentState),
Expand Down Expand Up @@ -238,6 +240,7 @@ func (c *commandRuntime) Run(ctx context.Context, comm Communicator) error {
c.missedCheckins = 0
} else {
c.missedCheckins++
c.log.Debugf("Last check-in was: %s, now is: %s. The diff %s is higher than allowed %s.", c.lastCheckin.Format(time.RFC3339Nano), now.Format(time.RFC3339Nano), now.Sub(c.lastCheckin), checkinPeriod)
}
if c.missedCheckins == 0 {
c.compState(client.UnitStateHealthy)
Expand Down

0 comments on commit f29717e

Please sign in to comment.