Skip to content

[CFX-7834] refactor(task): validate --concurrency at parse time - #860

Merged
ajalon1 merged 1 commit into
aj/CFX-7834-countflags-pipelinesfrom
aj/CFX-7834-countflags-task
Aug 31, 2026
Merged

[CFX-7834] refactor(task): validate --concurrency at parse time#860
ajalon1 merged 1 commit into
aj/CFX-7834-countflags-pipelinesfrom
aj/CFX-7834-countflags-task

Conversation

@ajalon1

@ajalon1 ajalon1 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

RATIONALE

dr task run --concurrency forwarded any value verbatim as -C <n> to the task binary, and two of those values did the opposite of what a user would expect:

  • --concurrency 0 meant unlimited parallelism, not "use the default 2". go-task treats -C 0 as "no concurrency limit", so passing 0 — a reasonable reading of "default" — unbounded the fan-out across every task in the graph. With recursive/root Taskfiles that is a quiet resource spike.
  • Negative values went straight through to the child binary (-C -1), leaving its behavior undefined rather than ours.

Both now die at parse time via internal/countflags.PositiveInt (from #858): zero concurrency would run nothing, so it is rejected with the standard invalid argument message, before the task runner is even looked up.

CHANGES

  • --concurrency -> countflags.PositiveInt (default 2 unchanged).
  • Reject test added in the existing command-test style.

TESTING

task lint (all GOOS legs) and task test (race + coverage) pass.

NOTES

Part 3/4 of a stacked review. Based on #859, so this diff shows only the task change.

@datarobot-pr-review-router

Copy link
Copy Markdown

🎫 Jira: CFX-7834 — Refactor --limit/--offset flags to custom pflag.Value (move validation to parsetime)

@ajalon1
ajalon1 force-pushed the aj/CFX-7834-countflags-task branch from fa0bc1a to 4f5ba27 Compare August 27, 2026 20:49
@github-actions github-actions Bot added the go Pull requests that update go code label Aug 27, 2026
@ajalon1
ajalon1 marked this pull request as ready for review August 27, 2026 21:09
@ajalon1
ajalon1 requested a review from a team as a code owner August 27, 2026 21:09

@chasdr chasdr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👋 chasbot here, chas had me take a pass at this one.

clean. -C 0 quietly meaning "unlimited" was a real trap, and pushing the check to parse time via countflags.PositiveInt kills it before the task runner is even looked up. default 2 is preserved, Type() still reports int so GetInt keeps working, and the reject test needs no task env because parsing dies first. tidy work, you and your droid.

built the two packages and ran the new test on the branch, both green. approving with the stack in mind (this rides on #858/#859).

LGTM 👍

Migrates dr task run --concurrency onto internal/countflags.PositiveInt
(default 2 unchanged). Zero or negative values previously reached the
task runner and ran nothing or misbehaved; they are now rejected during
flag parsing with cobra's standard "invalid argument" message. Adds a
reject test in the existing command-test style.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@ajalon1
ajalon1 force-pushed the aj/CFX-7834-countflags-task branch from 4f5ba27 to 09314f0 Compare August 31, 2026 17:34
@ajalon1

ajalon1 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

/approve-smoke-tests

@ajalon1
ajalon1 merged commit ecbf2b5 into main Aug 31, 2026
20 checks passed
@ajalon1
ajalon1 deleted the aj/CFX-7834-countflags-task branch August 31, 2026 18:02
ajalon1 added a commit to ajalon1/derkeley that referenced this pull request Aug 31, 2026
Today's countflags migration (CFX-7834, datarobot-oss#858/datarobot-oss#859/datarobot-oss#860) is documented in
docs/development/flags.md but had no reviewer-facing rule — a new count-like
flag validated in RunE instead of at parse time would sail through review.
Adds the parse-time-validation rule plus its documented exception (0 as a
"use default" sentinel, per the workload config --port/--replicas precedent).
cdevent pushed a commit that referenced this pull request Sep 3, 2026
Migrates dr task run --concurrency onto internal/countflags.PositiveInt
(default 2 unchanged). Zero or negative values previously reached the
task runner and ran nothing or misbehaved; they are now rejected during
flag parsing with cobra's standard "invalid argument" message. Adds a
reject test in the existing command-test style.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants