argoproj / argoproj/argo-workflows

Resources does not allow expressions when defined inline

Open
#15,005 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

solution/workaround
Dominant language
Go
Stars
17k
Forks
3.7k
Avg merge
1d 20h
Merged PRs (30d)
138

Description

Pre-requisites
  • I have double-checked my configuration
  • I have tested with the :latest image tag (i.e. quay.io/argoproj/workflow-controller:latest) and can confirm the issue still exists on :latest. If not, I have explained why, in detail, in my description below.
  • I have searched existing issues and could not find a match for this bug
  • I'd like to contribute the fix myself (see contributing guide)
What happened? What did you expect to happen?

What happened:

Argo lint failed for the second workflow because the container template type enforces schema validation for resource fields. The expression "{{workflow.parameters.memoryLimit}}" isn’t recognized as a valid Kubernetes quantity during linting—it’s treated as a literal string, violating the schema.

What you expected to happen:

Both workflows should behave identically and pass lint, since they run the same container with the same parameterized memory limit.

Version(s)

v3.7.2, latest

Paste a minimal workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflow that uses private images.
# Minimal test case comparing two approaches to parameterize container resources
# Both workflows run the EXACT SAME container, just using different Argo template types

---
# ============================================================================
# APPROACH 1: Using 'resource' template with manifest string - ✅ PASSES LINT
# ============================================================================
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: test-manifest-
  namespace: ma
spec:
  entrypoint: main
  arguments:
    parameters:
      - name: memoryLimit
        value: "2Gi"
  templates:
    - name: main
      resource:
        action: create
        setOwnerReference: true
        successCondition: status.phase == Succeeded
        manifest: |
          apiVersion: v1
          kind: Pod
          metadata:
            generateName: test-pod-
          spec:
            restartPolicy: Never
            containers:
            - name: main
              image: busybox:latest
              command: [sh, -c, "echo 'Memory: {{workflow.parameters.memoryLimit}}' && sleep 5"]
              resources:
                limits:
                  memory: "{{workflow.parameters.memoryLimit}}"

---
# ============================================================================
# APPROACH 2: Using 'container' template with YAML - ❌ FAILS LINT
# ============================================================================
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: test-yaml-
  namespace: ma
spec:
  entrypoint: main
  arguments:
    parameters:
      - name: memoryLimit
        value: "2Gi"
  templates:
    - name: main
      container:
        image: busybox:latest
        command: [sh, -c, "echo 'Memory: {{workflow.parameters.memoryLimit}}' && sleep 5"]
        resources:
          limits:
            memory: "{{workflow.parameters.memoryLimit}}"

---
# ============================================================================
# COMPARISON
# ============================================================================
#
# IDENTICAL ASPECTS:
# - Same container image (busybox:latest)
# - Same command
# - Same parameter (memoryLimit: "2Gi")
# - Same resource limit (memory)
#
# ONLY DIFFERENCE:
# - Approach 1: Wraps container in Pod manifest (resource template)
# - Approach 2: Direct container spec (container template)
#
# RESULT:
# - Approach 1: ✅ Passes lint (manifest is a string, not validated)
# - Approach 2: ❌ Fails lint (resources field validated against schema)
#
# Run: argo lint k8sResources/resource-parameterization-examples.yaml
Logs from the workflow controller
time="2025-11-04T12:45:25.501Z" level=info msg="Alloc=15893 TotalAlloc=968553 Sys=45909 NumGC=268 Goroutines=168"
time="2025-11-04T12:47:44.902Z" level=warning msg="Failed to unmarshal key to workflow object" error="quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'" key=ma/test-yaml-nr42j
time="2025-11-04T12:47:44.902Z" level=info msg="Updated phase  -> Failed" namespace=ma workflow=test-yaml-nr42j
time="2025-11-04T12:47:44.902Z" level=info msg="Updated message  -> cannot unmarshall spec: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'" namespace=ma workflow=test-yaml-nr42j
time="2025-11-04T12:47:44.902Z" level=info msg="Marking workflow completed" namespace=ma workflow=test-yaml-nr42j
time="2025-11-04T12:47:44.903Z" level=info msg="Workflow to be dehydrated" Workflow Size=646
time="2025-11-04T12:47:44.909Z" level=info msg="Workflow update successful" namespace=ma phase=Failed resourceVersion=133086 workflow=test-yaml-nr42j
time="2025-11-04T12:47:44.912Z" level=warning msg="Invalid workflow object" key="&{map[apiVersion:argoproj.io/v1alpha1 kind:Workflow metadata:map[creationTimestamp:2025-11-04T12:47:44Z generateName:test-yaml- generation:1 managedFields:[map[apiVersion:argoproj.io/v1alpha1 fieldsType:FieldsV1 fieldsV1:map[f:metadata:map[f:generateName:map[]] f:spec:map[]] manager:kubectl-create operation:Update time:2025-11-04T12:47:44Z]] name:test-yaml-nr42j namespace:ma resourceVersion:133085 uid:8b0f237f-e53e-4ac7-a667-133bec44d23e] spec:map[arguments:map[parameters:[map[name:memoryLimit value:2Gi]]] entrypoint:main templates:[map[container:map[command:[sh -c echo 'Memory: {{workflow.parameters.memoryLimit}}' && sleep 5] image:busybox:latest resources:map[limits:map[memory:{{workflow.parameters.memoryLimit}}]]] name:main]]]]}"
Logs from in your workflow's wait container
N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running argo lint on k8sResources/resource-parameterization-examples.yaml and compare the resource-template and container-template cases. Trace how the inline container resources field is validated and unmarshaled; done means parameterized quantities are accepted and both equivalent workflows pass lint and run successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.