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

Apply TaskRun CR without TaskRef field will panic in webhook #351

Closed
mathspanda opened this issue Dec 26, 2018 · 1 comment
Closed

Apply TaskRun CR without TaskRef field will panic in webhook #351

mathspanda opened this issue Dec 26, 2018 · 1 comment

Comments

@mathspanda
Copy link
Contributor

Actual Behavior

Apply TaskRun CR without TaskRef field will panic in webhook.

Steps to Reproduce the Problem

kubectl apply a TaskRun CR without taskRef field like:

apiVersion: pipeline.knative.dev/v1alpha1
kind: TaskRun
metadata:
  name: build-push-task-run-2
spec:
  trigger:
    triggerRef:
      type: manual
  inputs:
    resources:
      - name: workspace
        resourceRef:
          name: go-example-git
  taskSpec:
    inputs:
      resources:
        - name: workspace
          type: git
    steps:
      - name: build-and-push
        image: gcr.io/kaniko-project/executor
        command:
          - /kaniko/executor
        args:
          - --destination=gcr.io/my-project/gohelloworld

The logs in webhook are:

{"level":"info","logger":"webhook","caller":"webhook/webhook.go:569","msg":"No changes in the spec, not bumping generation","knative.dev/controller":"webhook","knative.dev/kind":"pipeline.knative.dev/v1alpha1, Kind=TaskRun","knative.dev/namespace":"linpeiyu","knative.dev/name":"build-push-task-run-2","knative.dev/operation":"UPDATE","knative.dev/resource":"{pipeline.knative.dev v1alpha1 taskruns}","knative.dev/subresource":"","knative.dev/userinfo":"{system:serviceaccount:kube-system:generic-garbage-collector ebccf2e4-f148-11e8-b12b-00155d3e7f00 [system:serviceaccounts system:serviceaccounts:kube-system system:authenticated] map[]}"}
2018/12/26 11:11:48 http2: panic serving 10.100.123.192:1709: runtime error: invalid memory address or nil pointer dereference
goroutine 47 [running]:
net/http.(*http2serverConn).runHandler.func1(0xc0005fc0a0, 0xc0003b1faf, 0xc0004f0000)
	/usr/local/go/src/net/http/h2_bundle.go:5870 +0x17c
panic(0x103d6c0, 0x1cd3eb0)
	/usr/local/go/src/runtime/panic.go:513 +0x1b9
github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1.(*TaskRunSpec).SetDefaults(...)
	/Users/linpeiyu/gopath/src/github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1/taskrun_defaults.go:24
github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1.(*TaskRun).SetDefaults(0xc000195440)
	/Users/linpeiyu/gopath/src/github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1/taskrun_defaults.go:20 +0x30
github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook.SetDefaults.func1(0xc0005a4520, 0x1301440, 0xc000195440, 0x1301440, 0xc000195200)
	/Users/linpeiyu/gopath/src/github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook/webhook.go:228 +0x77
github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook.(*AdmissionController).mutate(0xc000312000, 0x1301180, 0xc00061bb90, 0xc0005f8f80, 0x14, 0xc0005728c0, 0x8, 0xc0005728c8, 0x7, 0xc000689500, ...)
	/Users/linpeiyu/gopath/src/github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook/webhook.go:531 +0xa72
github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook.(*AdmissionController).admit(0xc000312000, 0x1301180, 0xc00061bb90, 0xc000532c80, 0xc00061bb90)
	/Users/linpeiyu/gopath/src/github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook/webhook.go:468 +0x153
github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook.(*AdmissionController).ServeHTTP(0xc000312000, 0x1300280, 0xc0005fc0a0, 0xc000486c00)
	/Users/linpeiyu/gopath/src/github.com/knative/build-pipeline/vendor/github.com/knative/pkg/webhook/webhook.go:435 +0xe40
net/http.serverHandler.ServeHTTP(0xc0003205b0, 0x1300280, 0xc0005fc0a0, 0xc000486c00)
	/usr/local/go/src/net/http/server.go:2741 +0xab
net/http.initNPNRequest.ServeHTTP(0xc00031ae00, 0xc0003205b0, 0x1300280, 0xc0005fc0a0, 0xc000486c00)
	/usr/local/go/src/net/http/server.go:3291 +0x8d
net/http.Handler.ServeHTTP-fm(0x1300280, 0xc0005fc0a0, 0xc000486c00)
	/usr/local/go/src/net/http/h2_bundle.go:5592 +0x4d
net/http.(*http2serverConn).runHandler(0xc0004f0000, 0xc0005fc0a0, 0xc000486c00, 0xc000594a00)
	/usr/local/go/src/net/http/h2_bundle.go:5877 +0x89
created by net/http.(*http2serverConn).processHeaders
	/usr/local/go/src/net/http/h2_bundle.go:5611 +0x4d3

Additional Info

/kind bug

@bobcatfish
Copy link
Collaborator

Thanks for the detailed report and for fixing this @mathspanda !! 🎉

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

No branches or pull requests

2 participants