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

Index out of range panic in CheckMissingResultReferences when references are missing #8083

Open
jbelldev opened this issue Jun 27, 2024 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@jbelldev
Copy link

When a PipelineRun lacks references (possibly TaskRun), it can cause the tekton-pipelines-controller pod to crash due to a runtime panic triggered by accessing a non-existing element in an array.

Expected Behavior

Controller should handle missing references gracefully, without crashing.

Actual Behavior

Pod crashes with following logs:

panic: runtime error: index out of range [0] with length 0
goroutine 382 [running]:
github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources.CheckMissingResultReferences({0xc03072cd00, 0xf, 0x44775a0?}, {0xc037fdfe30, 0x2, 0x0?})
/go/src/github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go:801 +0x27b
github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun.(*Reconciler).runNextSchedulableTask(0xc0007ec240, {0x2ce3ce8, 0xc056ddfa10}, 0xc056de8480, 0xc048d0ed08)
/go/src/github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/pipelinerun.go:841 +0x329
github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun.(*Reconciler).reconcile(0xc0007ec240, {0x2ce3ce8, 0xc056ddf980}, 0xc056de8480, 0x44775a0?, 0xc056116a80)
/go/src/github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/pipelinerun.go:773 +0x4775
github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun.(*Reconciler).ReconcileKind(0xc0007ec240, {0x2ce3ce8, 0xc056ddf650}, 0xc056de8480)
/go/src/github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/pipelinerun.go:265 +0x1132
github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1/pipelinerun.(*reconcilerImpl).Reconcile(0xc000756640, {0x2ce3ce8, 0xc056ddf560}, {0xc0514bf180, 0x45})
/go/src/github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1/pipelinerun/reconciler.go:236 +0x53b
knative.dev/pkg/controller.(*Impl).processNextWorkItem(0xc000751e60)
/go/src/github.com/tektoncd/pipeline/vendor/knative.dev/pkg/controller/controller.go:542 +0x4ad
knative.dev/pkg/controller.(*Impl).RunContext.func3()
/go/src/github.com/tektoncd/pipeline/vendor/knative.dev/pkg/controller/controller.go:491 +0x59
created by knative.dev/pkg/controller.(*Impl).RunContext in goroutine 234
/go/src/github.com/tektoncd/pipeline/vendor/knative.dev/pkg/controller/controller.go:489 +0x349

Steps to Reproduce the Problem

  1. Create PipelineRun without task runs (have not yet confirmed)
  2. Observe a crash in tekton-pipelines-controller related to index out of range error

Additional Info

Issue appears to be in the these lines of CheckMissingResultReferences, which assumes there will be at least one reference to each.

...
customRun := referencedPipelineTask.CustomRuns[0] 
...
taskRun := referencedPipelineTask.TaskRuns[0]
...

A basic length check may be needed either, though notably the former is first checked for a CustomRun reference and might be skipped over if empty.

  • Kubernetes version:
$ omc get clusterversion
NAME      VERSION   AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.14.27   True        False         6d      Cluster version is 4.14.27
  • Tekton Pipeline version:
$ tkn version
Client version: 0.33.0
Chains version: v0.20.1
Pipeline version: v0.59.0
Triggers version: v0.26.2
Operator version: devel

Related to https://issues.redhat.com/browse/SRVKP-5770

@jbelldev jbelldev added the kind/bug Categorizes issue or PR as related to a bug. label Jun 27, 2024
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

No branches or pull requests

1 participant