Skip to content

Derive task commands from Dockerfiles so Argo needs no registry lookup - #901

Open
aranega wants to merge 14 commits into
developfrom
fix/argo-task-entrypoint-lookup
Open

aranega wants to merge 14 commits into
developfrom
fix/argo-task-entrypoint-lookup

Conversation

@aranega

@aranega aranega commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Implemented solution

With Argo Workflows 4, a task container without a command makes the workflow controller read the
image's ENTRYPOINT/CMD from the registry, which needs credentials the controller doesn't have
(failed to look-up entrypoint/cmd for image ... DENIED). Passing Argo a secret isn't portable across
clouds, and writing a command= for every task by hand is error-prone.

harness-deployment now derives each task image's command from its Dockerfile and writes it to the
generated values as task-commands, next to task-images. At runtime CustomTask (and so the exit
handler) uses it as the default command. The controller then sees a command in the spec and never
queries the registry. Nothing secret is involved and nothing is cloud-specific.

  • Schema: task-commands added to HarnessMainConfig (free-form map, like task-images).
  • Parser: new ch_cli_tools/dockerfile.py (DockerfileParser) builds a small model of the file
    (instructions, stages, resolved ENTRYPOINT/CMD) following Docker's rules: last ENTRYPOINT/CMD of the
    final stage wins; an ENTRYPOINT clears a CMD inherited from a base but not one set earlier in the same
    stage; shell form runs as <shell> -c <raw string> with SHELL honoured, also across project base
    images; exec form is used as written; stage names are case-insensitive.
  • Inheritance: CHDockerfile follows project base images referenced through ARG. Dockerfiles that
    lead back to themselves are reported as an error and their base is ignored.
  • Generation: CHProject.all_task_commands() fills task-commands, keyed like task-images.
  • Runtime: CloudharnessConfig.get_task_command(name) reads it.

Precedence (what is written in code always wins):

  1. command= passed to the task
  2. command in template_overrides['container']
  3. args in template_overrides['container'] (no command is derived, the image's entrypoint runs)
  4. the command derived from the Dockerfile

Known limits

  • A base image outside the project (e.g. node:20) may define its own ENTRYPOINT, which a Dockerfile
    parser cannot see. It is assumed to define none, and one highlighted warning names the external bases
    the commands rely on. A task on such a base that sets only a CMD gets a wrong command until it sets
    command=.
  • A task with neither ENTRYPOINT nor CMD gets no derived command and a warning.
  • A task with an args override and no command still hits the registry lookup.

How to test this PR

Automated:

cd tools/deployment-cli-tools && pytest tests/test_task_commands.py tests/test_dockerfile_parser.py
cd libraries/cloudharness-common && pytest tests/test_workflow.py

On a project:

  1. Run harness-deployment with a task whose Dockerfile has a CMD and check deployment/helm/values.yaml:
    task-commands holds its command, keyed by the task image name.
  2. Remove the explicit command= from a CustomTask of that project, deploy, and start the workflow.
  3. kubectl get wf <name> -o yaml shows the derived container.command in the template, the controller
    logs no failed to look-up, and the workflow succeeds (the exit handler too).

Verified this way on a dev cluster with a real project project: two different task workflows (shell-form CMD with variables), both with the explicit command removed, ran to completion including their exit handler. The project's other workflows were not run. On HFO the derived commands equal the explicit ones for all of its tasks.

Sanity checks:

  • The pull request is explicitly linked to the relevant issue(s)
  • The issue is well described: clearly states the problem and the general proposed solution(s)
  • In this PR it is explicitly stated how to test the current change
  • The issue seta the scope and the type of issue (bug, story, task, etc.)
  • The relevant components are indicated in the issue (if any)
  • All the automated test checks are passing
  • All the linked issues are included in one Sprint
  • All the linked issues are in the Review state
  • All the linked issues are assigned

Breaking changes (select one):

  • The present changes do not change the preexisting api in any way
  • This PR and the issue are tagged as a breaking-change and the migration procedure is well described above

Possible deployment updates issues (select one):

  • There is no reason why deployments based on CloudHarness may break after the current update
  • This PR and the issue are tagged as alert:deployment

Test coverage (select one):

  • Tests for the relevant cases are included in this pr
  • The changes included in this pr are out of the current test coverage scope

Documentation (select one):

  • The documentation has been updated to match the current changes
  • The changes included in this PR are out of the current documentation scope

Nice to have (if relevant):

  • Screenshots of the changes
  • Explanatory video/animated gif

@aranega
aranega requested a review from filippomc November 17, 2026 17:48
@aranega aranega added the bug Something isn't working label Nov 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant