argoproj / argoproj/argo-workflows

Lint error: exit handler - failed to resolve `{{workflow.labels.workflows.argoproj.io/creator-preferred-username}}`

Open
#10,554 7 comments 0 reactions 0 assignees View on GitHub
area/cli area/templating P3 solution/workaround
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):
![obraz](https://user-images.githubusercontent.com/4583553/220102832-5cc093ae-611b-45cd-b34f-59d744d90c2f.png)

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

![obraz](https://user-images.githubusercontent.com/4583553/220103880-06805014-e99d-46f8-9b14-984a30174ee3.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.