argoproj / argoproj/argo-workflows
Lint error: exit handler - failed to resolve `{{workflow.labels.workflows.argoproj.io/creator-preferred-username}}`
- Dominant language
- Go
- Stars
- 17k
- Forks
- 3.7k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 138
Description
### Pre-requisites
- [X] I have double-checked my configuration
- [X] I can confirm the issues exists when I tested with `:latest`
- [ ] I'd like to contribute the fix myself (see [contributing guide](https://github.com/argoproj/argo-workflows/blob/master/docs/CONTRIBUTING.md))
### What happened/what you expected to happen?
Hi
Argo lint has a bug - I cannot pass linting step of working workflow script:
```
(base) ➜ ./argo-linux-amd64 version
argo: v3.4.5
BuildDate: 2023-02-07T13:22:11Z
GitCommit: 1253f443baa8ad1610d2e62ec26ecdc85fe1b837
GitTreeState: clean
GitTag: v3.4.5
GoVersion: go1.18.10
Compiler: gc
Platform: linux/amd64
(base) ➜ ./argo-linux-amd64 lint test.yaml
test.yaml:
✖ in "test-exit-handler-" (WorkflowTemplate): rpc error: code = InvalidArgument desc = templates.main-exit-handler: failed to resolve {{workflow.labels.workflows.argoproj.io/creator-preferred-username}}
```
What I would like to achieve: to get a workflow creator name in exit handler (from metadata):

I got the value I wanted, when executing a workflow:

Unfortunately, linting fails. A small workflow pasted below reproduces the case.
It is slightly connected with the issues https://github.com/argoproj/argo-workflows/issues/3448 https://github.com/argoproj/argo-workflows/issues/6036
### Version
3.4.5
### Paste a small workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.
```YAML
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
generateName: test-exit-handler-
spec:
entrypoint: runner
onExit: main-exit-handler
templates:
- name: runner
container:
image: docker/whalesay
command: [cowsay]
args: ["runner"]
resources:
limits:
memory: 32Mi
cpu: 100m
- name: main-exit-handler
container:
image: docker/whalesay
command: [cowsay]
args: ["{{workflow.labels.workflows.argoproj.io/creator-preferred-username}}"]
resources:
limits:
memory: 32Mi
cpu: 100m
```
### Logs from the workflow controller
```text
kubectl logs -n argo deploy/workflow-controller | grep ${workflow}
```
### Logs from in your workflow's wait container
```text
kubectl logs -n argo -c wait -l workflows.argoproj.io/workflow=${workflow},workflow.argoproj.io/phase!=Succeeded
```
Contributor guide
Research direction
Start by running the supplied `./argo-linux-amd64 lint test.yaml` workflow and compare linting with the successful execution described in the issue. Trace how the `argo lint` entry point resolves `workflow.labels` in the exit handler; done means this valid workflow passes linting and still produces the creator username at runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- cli, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100