commands: make builder status timeouts configurable across cli flows

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2026-02-24 17:54:12 +01:00
parent 6248145bef
commit f4cc8638c0
14 changed files with 97 additions and 45 deletions
+9 -1
View File
@@ -36,6 +36,7 @@ type pruneOptions struct {
minFreeSpace opts.MemBytes
force bool
verbose bool
timeout time.Duration
}
const (
@@ -68,7 +69,13 @@ func runPrune(ctx context.Context, dockerCli command.Cli, opts pruneOptions) err
return err
}
nodes, err := b.LoadNodes(ctx)
timeoutCtx, cancel := context.WithCancelCause(ctx)
if opts.timeout > 0 {
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, opts.timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
}
defer func() { cancel(errors.WithStack(context.Canceled)) }()
nodes, err := b.LoadNodes(timeoutCtx)
if err != nil {
return err
}
@@ -182,6 +189,7 @@ func pruneCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
flags.Var(&options.maxUsedSpace, "max-used-space", "Maximum amount of disk space allowed to keep for cache")
flags.BoolVar(&options.verbose, "verbose", false, "Provide a more verbose output")
flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation")
setBuilderStatusTimeoutFlag(flags, &options.timeout)
flags.Var(&options.reservedSpace, "keep-storage", "Amount of disk space to keep for cache")
flags.MarkDeprecated("keep-storage", "keep-storage flag has been changed to reserved-space")