Argo: Specifying specifying resources with input arguments causes an error

Created on 11 Mar 2020  路  6Comments  路  Source: argoproj/argo

Checklist:

  • [x] I've included the version.
  • [x] I've included reproduction steps.
  • [x] I've included the workflow YAML.
  • [x] I've included the logs.

What happened:
I am trying to make the template's resources depend on input arguments. When I submit a workflow like this it fails
What you expected to happen:
Each template should be able to have its own resources
How to reproduce it (as minimally and precisely as possible):
Apply the following using kubectl apply -f example.yaml
apiVersion: argoproj.io/v1alpha1 kind: CronWorkflow metadata: name: test spec: schedule: "* * * * *" timezone: "GMT" startingDeadlineSeconds: 0 concurrencyPolicy: "Forbid" successfulJobsHistoryLimit: 4 failedJobsHistoryLimit: 4 suspend: false workflowSpec: metadata: generateName: auto-extraction-gamivo- entrypoint: test templates: - name: test steps: - - name: step1 template: general arguments: parameters: - name: cpu value: "100m" - name: memory value: "1G" - name: general inputs: parameters: - name: cpu - name: memory container: image: ubuntu:latest command: [sh, -c] resources: requests: memory: "{{inputs.parameters.memory}}" cpu: "{{inputs.parameters.cpu}}" args: ["sleep inifinity"]
Anything else we need to know?:

Environment:

  • Argo version:
$ argo version
argo: v2.4.3
  BuildDate: 2019-12-06T03:36:01Z
  GitCommit: cfe5f377bc3552fba90afe6db7a76edd92c753cd
  GitTreeState: clean
  GitTag: v2.4.3
  GoVersion: go1.11.5
  Compiler: gc
  Platform: linux/amd64
  • Kubernetes version :
$ kubectl version -o yaml
clientVersion:
  buildDate: "2019-10-15T19:18:23Z"
  compiler: gc
  gitCommit: c97fe5036ef3df2967d086711e6c0c405941e14b
  gitTreeState: clean
  gitVersion: v1.16.2
  goVersion: go1.12.10
  major: "1"
  minor: "16"
  platform: linux/amd64
serverVersion:
  buildDate: "2020-01-17T23:10:13Z"
  compiler: gc
  gitCommit: bdceba0734835c6cb1acbd1c447caf17d8613b44
  gitTreeState: clean
  gitVersion: v1.14.10-gke.17
  goVersion: go1.12.12b4
  major: "1"
  minor: 14+
  platform: linux/amd64

Other debugging information (if applicable):

  • when trying to load http://127.0.0.1:2746/cron-workflows:
HTTP 500

{
  "error": "v1alpha1.CronWorkflowList.Items: []v1alpha1.CronWorkflow: v1alpha1.CronWorkflow.Spec: v1alpha1.CronWorkflowSpec.WorkflowSpec: v1alpha1.WorkflowSpec.Templates: []v1alpha1.Template: v1alpha1.Template.Container: v1.Container.Resources: v1.ResourceRequirements.Requests: unmarshalerDecoder: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$', error found in #10 byte of ...|ers.cpu}}\",\"memory\":|..., bigger context ...|es\":{\"requests\":{\"cpu\":\"{{inputs.parameters.cpu}}\",\"memory\":\"{{inputs.parameters.memory}}\"}}},\"input|...",
  "code": 2,
  "message": "v1alpha1.CronWorkflowList.Items: []v1alpha1.CronWorkflow: v1alpha1.CronWorkflow.Spec: v1alpha1.CronWorkflowSpec.WorkflowSpec: v1alpha1.WorkflowSpec.Templates: []v1alpha1.Template: v1alpha1.Template.Container: v1.Container.Resources: v1.ResourceRequirements.Requests: unmarshalerDecoder: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$', error found in #10 byte of ...|ers.cpu}}\",\"memory\":|..., bigger context ...|es\":{\"requests\":{\"cpu\":\"{{inputs.parameters.cpu}}\",\"memory\":\"{{inputs.parameters.memory}}\"}}},\"input|..."
}
  • workflow-controller logs:
kubectl logs -n argo $(kubectl get pods -l app=workflow-controller -n argo -o name)
E0311 14:36:50.509012       1 reflector.go:125] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:98: Failed to list *v1alpha1.CronWorkflow: v1alpha1.CronWorkflowList.Items: []v1alpha1.CronWorkflow: v1alpha1.CronWorkflow.Spec: v1alpha1.CronWorkflowSpec.WorkflowSpec: v1alpha1.WorkflowSpec.Templates: []v1alpha1.Template: v1alpha1.Template.Container: v1.Container.Resources: v1.ResourceRequirements.Requests: unmarshalerDecoder: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$', error found in #10 byte of ...|ers.cpu}}","memory":|..., bigger context ...|es":{"requests":{"cpu":"{{inputs.parameters.cpu}}","memory":"{{inputs.parameters.memory}}"}}},"input|...


Message from the maintainers:

If you are impacted by this bug please add a 馃憤 reaction to this issue! We often sort issues this way to know what to prioritize.

question wontfix

Most helpful comment

To parametrize the resource, you should use podSpec feature.
you can pass parametrize any podSpec elements using podSpec feature like podSpecPatch: '{"activeDeadlineSeconds":{{inputs.parameters.timeout}}}'

apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
  name: test
spec:
  schedule: "* * * * *"
  timezone: "GMT"
  startingDeadlineSeconds: 0
  concurrencyPolicy: "Forbid"
  successfulJobsHistoryLimit: 4
  failedJobsHistoryLimit: 4
  suspend: false
  workflowSpec:
    entrypoint: test
    templates:
      - name: test
        steps:
          - - name: step1
              template: general
              arguments:
                parameters:
                  - name: cpu
                    value: "100m"
                  - name: memory
                    value: "1G"
      - name: general
        inputs:
          parameters:
            - name: cpu
            - name: memory
        podSpecPatch: '{"containers":[{"name":"main", "resources":{"limits":{"cpu": "{{inputs.parameters.cpu}}", "memory": "{{inputs.parameters.memory}}" }}}]}'


        container:
          image: ubuntu:latest
          command: [sh, -c]
          args: ["sleep inifinity"]

All 6 comments

Example spec is incorrect, should be

apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
  name: test
spec:
  schedule: "* * * * *"
  timezone: "GMT"
  startingDeadlineSeconds: 0
  concurrencyPolicy: "Forbid"
  successfulJobsHistoryLimit: 4
  failedJobsHistoryLimit: 4
  suspend: false
  workflowSpec:
    entrypoint: test
    templates:
      - name: test
        steps:
          - - name: step1
              template: general
              arguments:
                parameters:
                  - name: cpu
                    value: "100m"
                  - name: memory
                    value: "1G"
      - name: general
        inputs:
          parameters:
            - name: cpu
            - name: memory
        container:
          image: ubuntu:latest
          command: [sh, -c]
          resources:
            requests:
              memory: "{{inputs.parameters.memory}}"
              cpu: "{{inputs.parameters.cpu}}"
          args: ["sleep inifinity"]

To parametrize the resource, you should use podSpec feature.
you can pass parametrize any podSpec elements using podSpec feature like podSpecPatch: '{"activeDeadlineSeconds":{{inputs.parameters.timeout}}}'

apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
  name: test
spec:
  schedule: "* * * * *"
  timezone: "GMT"
  startingDeadlineSeconds: 0
  concurrencyPolicy: "Forbid"
  successfulJobsHistoryLimit: 4
  failedJobsHistoryLimit: 4
  suspend: false
  workflowSpec:
    entrypoint: test
    templates:
      - name: test
        steps:
          - - name: step1
              template: general
              arguments:
                parameters:
                  - name: cpu
                    value: "100m"
                  - name: memory
                    value: "1G"
      - name: general
        inputs:
          parameters:
            - name: cpu
            - name: memory
        podSpecPatch: '{"containers":[{"name":"main", "resources":{"limits":{"cpu": "{{inputs.parameters.cpu}}", "memory": "{{inputs.parameters.memory}}" }}}]}'


        container:
          image: ubuntu:latest
          command: [sh, -c]
          args: ["sleep inifinity"]

@sarabala1979 I would have expected this to work too - any thoughts as to why not?

// PodSpecPatch holds strategic merge patch to apply against the pod spec. Allows parameterization of
// container fields which are not strings (e.g. resource limits).

Ok, even thought this behaviour is counter intuitive - I've reviewed the code and changing it would incur costs that out-weight the benefit.

Thank you

Was this page helpful?
0 / 5 - 0 ratings