Skip to content

Commit 614a6de

Browse files
committed
Use step.ImageID instead of looking into status.TaskSpec
`tr.Status.TaskSpec.Steps` can be out-of-sync with `tr.Status.Steps`. As we already have the image information (through `ImageID`) in the struct be are getting from our iteration, we don't need to look into another array, with the risk of getting a panic. The same goes for sidecars. We managed to get multiple panics on the controller prior to this change. See tektoncd#4952 for the initial implementation. Signed-off-by: Vincent Demeester <[email protected]>
1 parent 2f93ab2 commit 614a6de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/reconciler/taskrun/taskrun.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkg
199199
func (c *Reconciler) checkPodFailed(tr *v1beta1.TaskRun) (bool, v1beta1.TaskRunReason, string) {
200200
for index, step := range tr.Status.Steps {
201201
if step.Waiting != nil && step.Waiting.Reason == "ImagePullBackOff" {
202-
image := tr.Status.TaskSpec.Steps[index].Image
202+
image := step.ImageID
203203
message := fmt.Sprintf(`The step %q in TaskRun %q failed to pull the image %q. The pod errored with the message: "%s."`, step.Name, tr.Name, image, step.Waiting.Message)
204204
return true, v1beta1.TaskRunReasonImagePullFailed, message
205205
}
206206
}
207207
for index, sidecar := range tr.Status.Sidecars {
208208
if sidecar.Waiting != nil && sidecar.Waiting.Reason == "ImagePullBackOff" {
209-
image := tr.Status.TaskSpec.Sidecars[index].Image
209+
image := sidecar.ImageID
210210
message := fmt.Sprintf(`The sidecar %q in TaskRun %q failed to pull the image %q. The pod errored with the message: "%s."`, sidecar.Name, tr.Name, image, sidecar.Waiting.Message)
211211
return true, v1beta1.TaskRunReasonImagePullFailed, message
212212
}

0 commit comments

Comments
 (0)