fix: add --timeout flag to container commit to allow configurable lease timeout - #5108
fix: add --timeout flag to container commit to allow configurable lease timeout#5108Turbo-Jiaxxx789 wants to merge 1 commit into
Conversation
4a0997b to
2024864
Compare
| 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)") |
There was a problem hiding this comment.
There was a problem hiding this comment.
2024864 to
d92459e
Compare
| 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()) |
There was a problem hiding this comment.
--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
There was a problem hiding this comment.
--timeout=0creates a lease that never expires. containerd'sclient.WithLeaseonly applies the 24h default when no opts are passed at all: https://github.com/containerd/containerd/blob/e3692f42d2220498e6b80a853b512cd21cda0fd4/client/lease.go#L37-L43
thanks,fixed it: https://github.com/containerd/nerdctl/pull/5108/changes#diff-1d466bdd2b916ae62c4674699a8edbfb81fa2e37ec093af99ef8826190dd98cc
a24aa11 to
85ec661
Compare
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>
85ec661 to
2aee304
Compare
…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:
--timeout<=0→ use containerd's default 24h lease--timeout > 0→ use user spec leaseFixes: #5107