Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"argo template lint" errors on missing arguments #6044

Closed
atombender opened this issue May 28, 2021 · 8 comments
Closed

"argo template lint" errors on missing arguments #6044

atombender opened this issue May 28, 2021 · 8 comments
Labels

Comments

@atombender
Copy link

Here's what happens:

$ argo template lint ./k8s/environments/staging/wftmpl-webhooks.yaml
./k8s/environments/staging/wftmpl-webhooks.yaml:
   ✖ in "webhooks" (WorkflowTemplate): spec.arguments.commit.value is required

My workflow template starts with this:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: webhooks
spec:
  arguments:
    parameters:
    - name: commit

First of all, there's no flag to pass parameters to the linter to make it pass.

Second of all, how does that error make any sense? The arguments to the template doesn't matter to linting. Those arguments can be anything at runtime, so they cannot possibly be linted.

Is argo template lint intended for some other use case than linting workflow templates?

$ argo version
argo: v3.0.7+e79e7cc.dirty
  BuildDate: 2021-05-26T00:43:44Z
  GitCommit: e79e7ccda747fa4487bf889142c744457c26e9f7
  GitTreeState: dirty
  GitTag: v3.0.7
  GoVersion: go1.16.3
  Compiler: gc
  Platform: darwin/amd64

Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

@alexec
Copy link
Contributor

alexec commented May 28, 2021

Is this a regression?

@atombender
Copy link
Author

I have not used the tool before, so I wouldn't know.

@stale
Copy link

stale bot commented Jul 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 27, 2021
@atombender
Copy link
Author

It's not stale.

@stale stale bot removed the wontfix label Jul 28, 2021
@kennytrytek
Copy link
Contributor

I looked into this some, so here are my thoughts. Jump to the bottom for a conclusion and follow-up question.

Starting from a simple Workflow, this spec functions.
Template:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-parameters-
spec:
  entrypoint: whalesay
  arguments:
    parameters:
      - name: message
        value: hello world
  templates:
    - name: whalesay
      container:
        image: docker/whalesay
        command: [ cowsay ]
        args: [ "{{workflow.parameters.message}}" ] 

$ argo submit ./test-input-params.yaml: ✅

If I remove the value for message, then I need to provide it when submitting the workflow, but it still works.
Template:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-parameters-
spec:
  entrypoint: whalesay
  arguments:
    parameters:
      - name: message
  templates:
    - name: whalesay
      container:
        image: docker/whalesay
        command: [ cowsay ]
        args: [ "{{workflow.parameters.message}}" ] 

$ argo submit ./test-input-params.yaml -p 'message=hey': ✅

For a WorkflowTemplate, I can create one with a message argument value.
Template:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: hello-world-parameters
spec:
  entrypoint: whalesay
  arguments:
    parameters:
      - name: message
        value: hello world
  templates:
    - name: whalesay
      container:
        image: docker/whalesay
        command: [ cowsay ]
        args: [ "{{workflow.parameters.message}}" ] 

$ argo template create ./test-input-params.yaml: ✅

But if I remove the argument value, it fails.
Template:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: hello-world-parameters
spec:
  entrypoint: whalesay
  arguments:
    parameters:
      - name: message
  templates:
    - name: whalesay
      container:
        image: docker/whalesay
        command: [ cowsay ]
        args: [ "{{workflow.parameters.message}}" ] 

$ argo template create ./test-input-params.yaml: ❌

2021/10/11 19:32:31 Failed to create workflow template: spec.arguments.message.value is required

For a workflow template that has defined argument values, I can still submit overrides for any parameters.
$ argo submit --from=workflowtemplate/hello-world-parameters -p 'message=hey': ✅


The question is whether it is valid for a workflow template to exist that does not have values defined for its arguments. The current implementation says no, arguments for templates must always have accompanying values.

Since a Workflow can have arguments that do not require values, I think it would be sensible for WorkflowTemplates to behave the same way.

@alexec, I'd be willing to open a pull request for this (provided I can figure out where to start 😄).

@kennytrytek
Copy link
Contributor

As I started looking through the code, this comment appears to indicate that this lint behavior is a regression.

// if we are just linting we don't care if spec.arguments.parameters.XXX doesn't have an
// explicit value. workflows without a default value is a desired use case

@kennytrytek
Copy link
Contributor

I have opened a draft pull request to fix this issue at #7124, though I cannot get CI/Lint to pass for an unknown reason. I left a message at https://cloud-native.slack.com/archives/C020XM04CUW/p1635817253027600, but I'm not sure where to go from here.

@kennytrytek
Copy link
Contributor

Got the lint error resolved. PR is open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants