argo-workflows: [BUG] resource can not be passes as parameter
I try to pass container resources (cpu in my case) as workflow parameter( see workflow below) But argo cli validation failed like follows:
$ argo submit resource-param.yaml
2018/01/26 19:00:54 resource-param.yaml failed to parse: error unmarshaling JSON: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
AFAIU this is happens because expression was not actually substituted.
WORKFLOW
# Try to pass cpu resource as an argument
#
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: resource-param-
spec:
arguments:
parameters:
- name: nrcpu
value: 4
entrypoint: stress-ng
templates:
- name: stress-ng
inputs:
parameters:
- name: nrcpu
container:
image: lorel/docker-stress-ng
args: [ "--cpu", "{{workflow.parameters.nrcpu}}", "--timeout", "15s", "--metrics-brief" ]
resources:
requests:
memory: 1Gi
#cpu: 4
cpu: "{{workflow.parameters.nrcpu}}"
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 14
- Comments: 17 (7 by maintainers)
https://github.com/argoproj/argo/blob/master/examples/pod-spec-patch-wf-tmpl.yaml https://github.com/argoproj/argo/blob/master/examples/pod-spec-patch.yaml https://github.com/argoproj/argo/blob/master/examples/pod-spec-yaml-patch.yaml
@Snapple49 Basically I just use this pattern:
https://github.com/argoproj/argo/blob/baf37052976458401a6c0e44d06f30dc8d819680/examples/k8s-jobs.yaml
The
manifest
portion is fully template compatible, so you can swap out anything for a variable, including resource allocation.For example:
The downside is that logs won’t show up directly associated with the workflow, it’s less readable, and more complex.
also got bitten by this issue. as @discordianfish alludes to, the only known workaround so far is to have multiple copies of the same template but with different resource requests. for example:
some way to DRY this manifest would be greatly appreciated. i guess it’s possible to use YAML anchors but the syntax there is quite confusing