cilium/cilium · error
invalid clocksource: %s
Error message
invalid clocksource: %s
What it means
GetCTCurTime maps a clocksource mode (ktime, jiffies, etc.) to the right kernel-clock read (e.g. probes.Jiffies for jiffies mode). If clockSource.Mode is not one of the known modes, the switch falls through to default and returns this error rather than producing a wrong timestamp. It indicates an unsupported or misspelled clocksource mode value.
Source
Thrown at pkg/maps/timestamp/timestamp.go:94
// Returns current time in units that are used for timestamps in CT and NAT
// maps (seconds for ClockSourceModeKtime and scaled jiffies for
// ClockSourceModeJiffies).
func GetCTCurTime(clockSource *models.ClockSource) (uint64, error) {
switch clockSource.Mode {
case models.ClockSourceModeKtime:
t, err := bpf.GetMtime()
if err != nil {
return 0, err
}
return t / 1000000000, nil
case models.ClockSourceModeJiffies:
j, err := probes.Jiffies()
if err != nil {
return 0, err
}
return j >> bpfMonoScaler, nil
default:
return 0, fmt.Errorf("invalid clocksource: %s", clockSource.Mode)
}
}
type TimestampConverter func(timestamp uint64) uint64
// Returns a function that converts a CT timestamp from clocksource units into
// seconds.
func NewCTTimeToSecConverter(clockSource *models.ClockSource) (TimestampConverter, error) {
if clockSource == nil {
return nil, fmt.Errorf("clockSource is nil")
}
switch clockSource.Mode {
case models.ClockSourceModeKtime:
converter := func(timestamp uint64) uint64 {
return timestamp
}
return converter, nil
case models.ClockSourceModeJiffies:View on GitHub (pinned to ac7b90affa)
Solutions
- Use only supported modes: models.ClockSourceModeKtime or models.ClockSourceModeJiffies
- Re-fetch the clocksource from the agent health endpoint or fix the agent config file to a valid mode
- Align library and agent versions so both support the reported mode
- Log the received Mode value to identify what unexpected value is being passed
Defensive patterns
Strategy: validation
Validate before calling
// Validate mode before calling GetCTCurTime
if cs.Mode != models.ClockSourceModeKtime && cs.Mode != models.ClockSourceModeJiffies {
return fmt.Errorf("unsupported clocksource mode: %s", cs.Mode)
} Type guard
func isSupportedMode(m models.ClockSourceMode) bool {
return m == models.ClockSourceModeKtime || m == models.ClockSourceModeJiffies
} Try / catch
// Go: handle and surface the invalid mode
sec, err := GetCTCurTime(clockSource)
if err != nil {
if strings.HasPrefix(err.Error(), "invalid clocksource") {
logger.Error("unsupported clocksource mode", "mode", clockSource.Mode)
}
return err
} Prevention
- Only feed ClockSource values obtained from the agent API or validated config
- Keep this library and the agent on compatible versions
- Reject empty Mode strings at config-parse time
- Add a startup assertion that the reported mode is one of the two constants
When it happens
Trigger: Calling GetCTCurTime with a models.ClockSource whose Mode is an unrecognized string — e.g. a new mode added in a newer agent, a typo, or an empty Mode from a malformed health/config payload.
Common situations: Version skew where the agent reports a mode this library doesn't know; hand-edited config with an invalid mode; empty clocksource parsed from YAML producing Mode:"".
Related errors
- invalid clock Hertz value (0)
- certificate and private key are both required, but only one
- bpf-lb-dsr-dispatch ipip creates IPIP tunnels that aren't co
- BIG TCP in tunneling mode requires pending kernel support
- BIG TCP with bpf-lb-dsr-dispatch geneve requires pending ker
AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31).
Data as JSON: /api/errors/489fe3db06b6d23d.
Report an issue: GitHub.