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

applying the same TaskRun yaml more than once produces errors #2276

Closed
zjgoodman opened this issue Mar 24, 2020 · 4 comments · Fixed by #2285
Closed

applying the same TaskRun yaml more than once produces errors #2276

zjgoodman opened this issue Mar 24, 2020 · 4 comments · Fixed by #2285
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now.

Comments

@zjgoodman
Copy link
Contributor

I am using the following TaskRun yaml

apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: echo-hello-world-task-run
spec:
  taskSpec:
    steps:
      - name: echo
        image: ubuntu
        command:
          - echo
        args:
          - "Hello World"

When I do a kubectl apply -f <file> on this TaskRun more than once I get errors

Expected Behavior

Upon applying the file, if I made changes to the TaskRun, apply the changes. Otherwise kubernetes should tell me that it's unchanged, like this:

taskrun/echo-hello-world-task-run unchanged

Actual Behavior

Applying the file when nothing exists works, but any additional applies causes errors, regardless of whether or not I change the contents of the file. I noticed that if I change the name of the TaskRun it works (a new TaskRun with the new name is created).

Steps to Reproduce the Problem

I confirm I have no TaskRuns

zjgoodma@Big Business ~/t/tutorial> kubectl get tr
No resources found in default namespace.

I create the TaskRun and confirm it ran successfully.

zjgoodma@Big Business ~/t/tutorial> kubectl apply -f hello-world-taskrun.yaml
taskrun.tekton.dev/echo-hello-world-task-run created

zjgoodma@Big Business ~/t/tutorial> kubectl get tr
NAME                        SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
echo-hello-world-task-run   True        Succeeded   12s         7s

I apply the exact same TaskRun yaml again without making any changes to it and get an error

zjgoodma@Big Business ~/t/tutorial> kubectl apply -f hello-world-taskrun.yaml
Error from server (BadRequest): error when applying patch:
{"spec":{"taskSpec":{"steps":[{"args":["Hello World"],"command":["echo"],"image":"ubuntu","name":"echo"}]}}}
to:
Resource: "tekton.dev/v1beta1, Resource=taskruns", GroupVersionKind: "tekton.dev/v1beta1, Kind=TaskRun"
Name: "echo-hello-world-task-run", Namespace: "default"
Object: &{map["apiVersion":"tekton.dev/v1beta1" "kind":"TaskRun" "metadata":map["annotations":map["kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"tekton.dev/v1beta1\",\"kind\":\"TaskRun\",\"metadata\":{\"annotations\":{},\"name\":\"echo-hello-world-task-run\",\"namespace\":\"default\"},\"spec\":{\"taskSpec\":{\"steps\":[{\"args\":[\"Hello World\"],\"command\":[\"echo\"],\"image\":\"ubuntu\",\"name\":\"echo\"}]}}}\n" "pipeline.tekton.dev/release":"devel"] "creationTimestamp":"2020-03-24T21:03:24Z" "generation":'\x02' "labels":map["app.kubernetes.io/managed-by":"tekton-pipelines"] "name":"echo-hello-world-task-run" "namespace":"default" "resourceVersion":"14257" "selfLink":"/apis/tekton.dev/v1beta1/namespaces/default/taskruns/echo-hello-world-task-run" "uid":"63bcc1fa-22c9-4534-b0c7-4a477eba0b84"] "spec":map["inputs":map[] "outputs":map[] "serviceAccountName":"" "taskSpec":map["steps":[map["args":["Hello World"] "command":["echo"] "image":"ubuntu" "name":"echo" "resources":map[]]]] "timeout":"1h0m0s"] "status":map["completionTime":"2020-03-24T21:03:29Z" "conditions":[map["lastTransitionTime":"2020-03-24T21:03:29Z" "message":"All Steps have completed executing" "reason":"Succeeded" "status":"True" "type":"Succeeded"]] "podName":"echo-hello-world-task-run-pod-2l9xg" "startTime":"2020-03-24T21:03:24Z" "steps":[map["container":"step-echo" "imageID":"docker-pullable://ubuntu@sha256:bec5a2727be7fff3d308193cfde3491f8fba1a2ba392b7546b43a051853a341d" "name":"echo" "terminated":map["containerID":"docker://3ced6cc7b6988dd2a1c88c563a5b4279497e2aaaab7ea5b6774cbc696e0670d6" "exitCode":'\x00' "finishedAt":"2020-03-24T21:03:28Z" "reason":"Completed" "startedAt":"2020-03-24T21:03:28Z"]]]]]}
for: "hello-world-taskrun.yaml": admission webhook "webhook.pipeline.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: json: unknown field "inputs"

Additional Info

  • Kubernetes version:

    Output of kubectl version:

zjgoodma@Big Business ~/t/tutorial> kubectl version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-13T11:51:44Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:12:17Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
  • Tekton Pipeline version:

    Output of tkn version:

zjgoodma@Big Business ~/t/tutorial> tkn version
Client version: 0.8.0
Pipeline version: v0.11.0-rc2
@danielhelfand
Copy link
Member

danielhelfand commented Mar 25, 2020

This is somewhat related to #2113, which occurred when trying to use kubectl apply -f with generateName. #2113 turned out to be more of an issue with kubectl itself rather than Tekton. I am wondering if this case is similar or if there's something Tekton can do to return a more appropriate error message.

The preferred way of using kubectl with creating TaskRuns or PipelineRuns is to use generateName instead of name under the metadata property and to use kubectl create -f so you are always creating a TaskRun/PipelineRun with a new name.

So you could use kubectl create -f as many times as you like with the following TaskRun:

apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  generateName: echo-hello-world-task-run-
spec:
  taskSpec:
    steps:
      - name: echo
        image: ubuntu
        command:
          - echo
        args:
          - "Hello World"

Another way is to use the Tekton CLI (tkn), which offers a tkn task start command for a Task that is created on your cluster or using the -f flag to start a Task that exists in a local or remote file.

@vincent-pli
Copy link
Member

@zjgoodman
The unknow field inputs and ouput belong tov1alpha1, they are removed in v1beta1, that's why webhook reject the request.

I noticed you use the v1beta1 but the fields still appeared, I think it's because we still use the informer of v1alpha1, when move to v1beta1 the issue will gone.
@vdemeester

@vdemeester
Copy link
Member

@vincent-pli oh you might be right 🙀

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 25, 2020
@vdemeester vdemeester added this to the Pipelines 0.11 🐱 milestone Mar 25, 2020
@vdemeester
Copy link
Member

/assign

@vdemeester vdemeester added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Mar 25, 2020
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. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants