Skip to content

timex: filter unreasonable offset values from kernel adjtimex() overflow - #3766

Open
dongjiang1989 wants to merge 1 commit into
prometheus:masterfrom
dongjiang1989:fix-time-offset
Open

timex: filter unreasonable offset values from kernel adjtimex() overflow#3766
dongjiang1989 wants to merge 1 commit into
prometheus:masterfrom
dongjiang1989:fix-time-offset

Conversation

@dongjiang1989

@dongjiang1989 dongjiang1989 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3764

On KVM/pvclock guests, a race condition in the kernel NTP PLL can cause adjtimex() to return 2^32 ns (4.294967296s) as a transient overflow value, triggering false-positive NodeClockSkewDetected alerts hundreds of times per day despite NTP being correctly synchronized.

This PR applies defense-in-depth at two layers:

  • Collector layer (collector/timex.go): values exceeding ±1.0s are discarded (set to 0) with a warning log. Real NTP synchronization never produces offsets of this magnitude.
  • Alert rule layer (docs/node-mixin/alerts/alerts.libsonnet): NodeClockSkewDetected expression gains an upper bound check (< 1.0 / > -1.0) so the overflow artifact no longer passes the threshold filter even if the collector still emits it.

Why ±1.0s?

  • Normal NTP sync keeps offset well below 100ms
  • MAXPHASE in the kernel is 500ms
  • 1.0s leaves generous headroom while cleanly excluding the 4.29s overflow artifact

On KVM/pvclock guests, a race condition in the kernel NTP PLL can cause
adjtimex() to return 2^32 ns (4.294967296s) as a transient overflow value,
triggering false-positive NodeClockSkewDetected alerts hundreds of times
per day despite NTP being correctly synchronized.

Add a ±1.0s sanity bound in the timex collector: values exceeding this
threshold are discarded (set to 0) with a warning log, as real NTP sync
never produces offsets of this magnitude. Apply the same bound in the
NodeClockSkewDetected alert expression to provide defense-in-depth at
the rule layer.

Fixes prometheus#3764

Signed-off-by: dongjiang <dongjiang1989@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NodeClockSkewDetected false-positives on 2^32 ns overflow from kernel adjtimex() (OpenStack/KVM)

1 participant