Skip to content

fix: add --timeout flag to container commit to allow configurable lease timeout - #5108

Open
Turbo-Jiaxxx789 wants to merge 1 commit into
containerd:mainfrom
Turbo-Jiaxxx789:fix/commit-timeout-flag
Open

fix: add --timeout flag to container commit to allow configurable lease timeout#5108
Turbo-Jiaxxx789 wants to merge 1 commit into
containerd:mainfrom
Turbo-Jiaxxx789:fix/commit-timeout-flag

Conversation

@Turbo-Jiaxxx789

@Turbo-Jiaxxx789 Turbo-Jiaxxx789 commented Jul 29, 2026

Copy link
Copy Markdown

…se expiration

The hardcoded 1-hour lease expiration in nerdctl container commit can cause failures for containers with large filesystem deltas (e.g., many packages installed). When the diff.Compare operation exceeds 1 hour, the containerd GC cleans up the expired lease and its ingest data, resulting in 'context deadline exceeded' errors.

Changes:

  • Add Timeout field to ContainerCommitOptions and commit.Opts (default: 1h)
  • Modify Commit() to use configurable lease expiration:
  • --timeout<=0 → use containerd's default 24h lease
  • --timeout > 0 → use user spec lease

Fixes: #5107

@Turbo-Jiaxxx789 Turbo-Jiaxxx789 changed the title fix: add --timeout flag to container commit to allow configurable lea… fix: add --timeout flag to container commit to allow configurable lease timeout Jul 29, 2026
@Turbo-Jiaxxx789
Turbo-Jiaxxx789 force-pushed the fix/commit-timeout-flag branch 7 times, most recently from 4a0997b to 2024864 Compare July 29, 2026 03:42
cmd.Flags().Bool("zstdchunked", false, "Convert the committed layer to zstd:chunked for lazy pulling")
cmd.Flags().Int("zstdchunked-compression-level", 3, "zstd:chunked compression level")
cmd.Flags().Int("zstdchunked-chunk-size", 0, "zstd:chunked chunk size")
cmd.Flags().Duration("timeout", 1*time.Hour, "Maximum duration for the commit operation (default 1h, 0 for containerd's default 24h)")

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The hardcoded 1-hour lease expiration in nerdctl container commit can
cause failures for containers with large filesystem deltas (e.g., many
packages installed). When the diff.Compare operation exceeds 1 hour,
the containerd GC cleans up the expired lease and its ingest data,
resulting in 'context deadline exceeded' errors.

Changes:
- Add Timeout field to ContainerCommitOptions and commit.Opts
- Modify Commit() to use configurable lease expiration:
  * --timeout=0 (or negative): use containerd's default 24h lease
  * --timeout>0: use the specified duration
  * --timeout defaults to 1h for backward compatibility
- Add --timeout CLI flag (default: 1h)
- Add tests for --timeout flag

Usage:
  nerdctl container commit mycontainer myimage:tag        # default 1h
  nerdctl container commit --timeout=4h ...                # 4h timeout
  nerdctl container commit --timeout=0 ...                 # 24h (containerd default)

Signed-off-by: Turbo Jia <turbo@example.com>
@Turbo-Jiaxxx789
Turbo-Jiaxxx789 force-pushed the fix/commit-timeout-flag branch from 2024864 to d92459e Compare July 29, 2026 10:46
var done func(context.Context) error
if opts.Timeout <= 0 {
// Use containerd's default lease expiration (24h)
ctx, done, err = client.WithLease(ctx, leases.WithRandomID())

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.

--timeout=0 creates a lease that never expires. containerd's client.WithLease only applies the 24h default when no opts are passed at all:
https://github.com/containerd/containerd/blob/e3692f42d2220498e6b80a853b512cd21cda0fd4/client/lease.go#L37-L43

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.

nerdctl container commit has a hardcoded 1-hour lease that causes failure for large container diffs?what about make it as flag

3 participants