Repository navigation
fix: add --timeout flag to container commit to allow configurable lease timeout - #5253
Conversation
|
The single failing check ( |
ChengyuZhu6
left a comment
There was a problem hiding this comment.
Nit: the commit metadata looks inconsistent — could you please fix it ?
The commit author is hejianshan hejianshan@bytedance.com, but the Signed-off-by trailer is Turbo Jia turbo@example.com, which looks like a placeholder address.
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: hejianshan <hejianshan@bytedance.com>
Address review feedback on containerd#5108 that "--timeout=0 does not parse". time.ParseDuration special-cases a bare "0" as a valid duration without a unit, so both "--timeout=0" and "--timeout=0s" are accepted by the cobra Duration flag. Add a unit test locking in this behavior and clarify the command reference accordingly. Signed-off-by: liujiuyi <liujiuyi.ljy@alibaba-inc.com>
3254832 to
dae7288
Compare
|
@ChengyuZhu6 Thanks for catching that. Fixed — the first commit keeps the original authorship ( |
The hardcoded 1-hour lease expiration in
nerdctl container commitcan cause failures for containers with large filesystem deltas (e.g., many packages installed). When the diff operation exceeds 1 hour, the containerd GC cleans up the expired lease and its ingest data, resulting incontext deadline exceeded/failed to export layererrors.This PR continues the stalled #5108. The original commit by @Turbo-Jiaxxx789 is preserved as-is (full credit to the original author), rebased onto the latest main, with the outstanding review comment addressed in a follow-up commit.
Changes
Timeoutfield toContainerCommitOptionsandcommit.OptsCommit()to use a configurable lease expiration:--timeout=0(or negative): use containerd's default lease expiration (24h), applied byclient.WithLeasewhen no lease opts are passed (see client/lease.go)--timeout>0: use the specified duration--timeoutdefaults to 1h for backward compatibility--timeoutCLI flag (default: 1h)--timeout=2hand--timeout=0s--timeoutflag parsingAddressing the remaining review comment from #5108
time.ParseDurationspecial-cases a bare"0"as a valid duration without a unit (go/src/time/format.go, "Special case: if all that is left is "0", this is zero."). Since pflag'sDurationflag delegates totime.ParseDuration, both--timeout=0and--timeout=0sparse successfully.The added unit test
TestCommitTimeoutFlagParsinglocks in this behavior for0,0s,90m,4h, and the 1h default, and the command reference now explicitly documents that both0and0sare accepted.Usage
Fixes #5107
Supersedes #5108