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

Unable to start task with -f flag if the task definition file contains params with no default value #959

Closed
VeereshAradhya opened this issue May 4, 2020 · 5 comments · Fixed by #964
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@VeereshAradhya
Copy link
Contributor

Version and Operating System

tkn Version:
v0.9.0

Operating System:
All

Expected Behavior

Taskrun should get created

Actual Behavior

The command is throwing the error Error: param 'test-param' not present in spec

Steps to Reproduce the Problem

  1. Create a task definition in a yaml file with params with no default values
  2. Start the taskrun using the command tkn task start -f <yaml file> -p <param name>=<param value>

Additional Info

Below are command logs

$ cat script-task-python.yaml 
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: python-script-task-test
spec:
  description: python task
  params:
    - name: test-param
      description: this is test param
  steps:
    - name: step-one
      image: python  
      script: |
        #!/usr/bin/env python3
        print("$(params.test-param)")
        print("Hello from Python!")
        import time
        for i in range(50):
          print("this is task", flush=True)
          time.sleep(2)


$ cat script-task-python.yaml 
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: python-script-task-test
spec:
  description: python task
  params:
    - name: test-param
      description: this is test param
  steps:
    - name: step-one
      image: python  
      script: |
        #!/usr/bin/env python3
        print("$(params.test-param)")
        print("Hello from Python!")
        import time
        for i in range(50):
          print("this is task", flush=True)
          time.sleep(2)

$ tkn task start -f script-task-python.yaml -p test-param="this is test param"
Error: param 'test-param' not present in spec
[varadhya@localhost testing]$ 
@pradeepitm12
Copy link
Contributor

/assign

@danielhelfand
Copy link
Member

The params will be on the TaskSpec in this case as opposed to the TaskRunSpec, which is causing the issue:

param, err := params.MergeParam(tr.Spec.Params, opt.Params)

@danielhelfand
Copy link
Member

This also affects tkn pipeline start:

param, err := params.MergeParam(pr.Spec.Params, opt.Params)

@danielhelfand danielhelfand added the kind/bug Categorizes issue or PR as related to a bug. label May 4, 2020
@pradeepitm12
Copy link
Contributor

pradeepitm12 commented May 5, 2020

I tried with the older version of Pipeline and CLI, seems like an existing issue.

@danielhelfand
Copy link
Member

@pradeepitm12 Yes, I think this was missed from the original implementation of this.

tekton-robot pushed a commit that referenced this issue May 6, 2020
Close #959

This fixes task start with file command.

Note: to start a task from file params needs to have its type
speficed, in case of existing task in cluster type is appended by
the controller.

Signed-off-by: Pradeep Kumar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants