Checklist:
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: 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
$ 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):
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|..."
}
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.
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
Most helpful comment
To parametrize the resource, you should use
podSpecfeature.you can pass parametrize any podSpec elements using
podSpecfeature likepodSpecPatch: '{"activeDeadlineSeconds":{{inputs.parameters.timeout}}}'