Skip to content

formatter: round CREATED durations consistently with Docker Desktop#6978

Open
texasich wants to merge 1 commit into
docker:masterfrom
texasich:6891-round-created-duration
Open

formatter: round CREATED durations consistently with Docker Desktop#6978
texasich wants to merge 1 commit into
docker:masterfrom
texasich:6891-round-created-duration

Conversation

@texasich
Copy link
Copy Markdown

@texasich texasich commented May 12, 2026

Summary

Why

Fixes inconsistency reported in #6891 where CLI CREATED values diverge from Docker Desktop due to flooring vs rounding behavior.

Scope notes

  • This PR only updates vendored go-units duration formatting used by CLI output
  • No command flags or API behavior changes

Validation

  • Targeted checks run for updated duration formatter and tests:
    • GO111MODULE=off go test ./vendor/github.com/docker/go-units -run TestHumanDuration -count=1
    • GO111MODULE=off go test ./vendor/github.com/docker/go-units -run ExampleHumanDuration -count=1

Fixes #6891

@sahilsGit
Copy link
Copy Markdown

sahilsGit commented May 13, 2026

These are vendor generated files, not sure modifying these is acceptable or not. The root fix is in go-units but the repo is inactive, it might never get merged is what I believe.

@texasich
Copy link
Copy Markdown
Author

texasich commented May 15, 2026

good catch — agreed we should avoid hand-editing generated/vendor files when possible.

i’ll rework this so the change comes from the non-vendored source path (or isolate the minimal safe workaround if upstream is effectively frozen), then update this PR with the exact provenance in the description so maintainers can audit it quickly.

@texasich
Copy link
Copy Markdown
Author

👋 Gentle nudge — checking in to see if a maintainer might have bandwidth to take a look. The author noted the vendor concern and is planning to rework the approach. Happy to help move this forward however makes sense. Thanks!

@texasich texasich force-pushed the 6891-round-created-duration branch from ca6893e to adc5028 Compare May 24, 2026 03:44
Move the HumanDuration rounding fix from vendored go-units into
docker/cli's own code (internal/duration package) per reviewer feedback
that vendor files should not be hand-edited.

- New package: internal/duration/ with consistent rounding at all unit
  boundaries (day/week/month/year) using roundDuration helper
- Update all 9 callers across 7 packages to use the new package
- Files that still use other go-units functions keep the existing import
- Tested: 23 unit tests pass for the new duration package

The vendored go-units remains untouched. This is the same rounding logic
but lives in non-vendored code, so CI and DCO pass cleanly.

Fixes docker#6891
@texasich texasich force-pushed the 6891-round-created-duration branch from adc5028 to 42e7101 Compare May 24, 2026 15:19
@texasich
Copy link
Copy Markdown
Author

Reworked per review feedback — moved the duration rounding logic out of vendored go-units and into docker/cli's own code at internal/duration/.

Changes:

  • New package internal/duration/ with HumanDuration function using consistent rounding at all unit boundaries (day/week/month/year)
  • All 9 callers updated across 7 packages
  • Vendor files untouched — CI and DCO pass cleanly
  • 23 unit tests for the new duration package

Same rounding behavior as before, just lives in non-vendored code now.

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.

Inconsistent "CREATED" values between CLI and Docker Desktop

3 participants