Skip to content

cri: fix container_start_time_seconds unit conversion - #13897

Merged
mxpv merged 1 commit into
containerd:mainfrom
dgrisonnet:worktree-fix-start-time-nanos
Aug 5, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
dgrisonnet:worktree-fix-start-time-nanos

Conversation

@dgrisonnet

@dgrisonnet dgrisonnet commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

The container_start_time_seconds metric was reporting nanoseconds instead of Unix seconds. The CRI container status stores StartedAt as nanoseconds (per the CRI API spec), but the metric name and help text indicate seconds. Convert by dividing by time.Second.

@Chandan9112 found this bug by running kubernetes/kubernetes#140786 locally and noticed that container_start_time_seconds reported nanoseconds (~1.78e18) instead of Unix seconds (~1.78e9)

Fix container_start_time_seconds metric reporting nanoseconds instead of seconds

Copilot AI lite review requested due to automatic review settings August 3, 2026 14:43
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Aug 3, 2026
Copilot AI previously approved these changes Aug 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

The change is a correct, minimal unit conversion that aligns the exported metric with its documented seconds-based semantics.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Fixes the CRI container_start_time_seconds metric to report Unix time in seconds (as the metric name/help text indicate) instead of incorrectly reporting nanoseconds from the CRI StartedAt field.

Changes:

  • Convert container.Status.Get().StartedAt from nanoseconds to seconds by dividing by time.Second when exporting container_start_time_seconds.
File summaries
File Description
internal/cri/server/list_pod_sandbox_metrics_linux.go Convert container start time from nanoseconds to Unix seconds when populating container_start_time_seconds.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@dgrisonnet

Copy link
Copy Markdown
Contributor Author

cc @mikebrow

@mikebrow mikebrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
thanks!

The container_start_time_seconds metric was reporting nanoseconds
instead of Unix seconds. The CRI container status stores StartedAt
as nanoseconds (per the CRI API spec), but the metric name and help
text indicate seconds. Convert by dividing by time.Second.

Signed-off-by: Damien Grisonnet <[email protected]>
Copilot AI review requested due to automatic review settings August 4, 2026 14:29
@mikebrow
mikebrow force-pushed the worktree-fix-start-time-nanos branch from 2e5fc08 to 71bc89b Compare August 4, 2026 14:29
Copilot AI dismissed their stale review, a newer Copilot review was requested August 4, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

The change correctly aligns the metric’s reported unit with its documented semantics by converting nanoseconds to seconds.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@mikebrow

mikebrow commented Aug 4, 2026

Copy link
Copy Markdown
Member

/cc @dims

@kubernetes-prow
kubernetes-prow Bot requested a review from dims August 4, 2026 14:35
@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Aug 5, 2026
@mxpv
mxpv added this pull request to the merge queue Aug 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 5, 2026
@mikebrow
mikebrow added this pull request to the merge queue Aug 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 5, 2026
@mxpv
mxpv added this pull request to the merge queue Aug 5, 2026
Merged via the queue into containerd:main with commit 95f42a8 Aug 5, 2026
56 of 59 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Aug 5, 2026
@samuelkarp samuelkarp added impact/changelog area/cri Container Runtime Interface (CRI) and removed impact/changelog labels Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cri Container Runtime Interface (CRI) size/XS

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants