Skip to content

Commit

Permalink
Error sweep: add more context for PipelineRunCouldntGetPipeline error…
Browse files Browse the repository at this point in the history
… message
  • Loading branch information
JeromeJu authored and tekton-robot committed Nov 30, 2023
1 parent 891048c commit 6847203
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GetPipelineData(ctx context.Context, pipelineRun *v1.PipelineRun, getPipeli
// Get related pipeline for pipelinerun
p, source, vr, err := getPipeline(ctx, pipelineRun.Spec.PipelineRef.Name)
if err != nil {
return nil, nil, fmt.Errorf("error when listing pipelines for pipelineRun %s: %w", pipelineRun.Name, err)
return nil, nil, fmt.Errorf("error when getting Pipeline for PipelineRun %s: %w", pipelineRun.Name, err)
}
pipelineMeta = p.PipelineMetadata()
pipelineSpec = p.PipelineSpec()
Expand Down
8 changes: 4 additions & 4 deletions pkg/reconciler/pipelinerun/resources/pipelineref.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (l *LocalPipelineRefResolver) GetPipeline(ctx context.Context, name string)

pipeline, err := l.Tektonclient.TektonV1().Pipelines(l.Namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return nil, nil, nil, err
return nil, nil, nil, fmt.Errorf("tekton client cannot get pipeline %s from local cluster: %w", name, err)
}
return pipeline, nil, nil, nil
}
Expand All @@ -115,11 +115,11 @@ func (l *LocalPipelineRefResolver) GetPipeline(ctx context.Context, name string)
func resolvePipeline(ctx context.Context, resolver remote.Resolver, name string, namespace string, k8s kubernetes.Interface, tekton clientset.Interface, verificationPolicies []*v1alpha1.VerificationPolicy) (*v1.Pipeline, *v1.RefSource, *trustedresources.VerificationResult, error) {
obj, refSource, err := resolver.Get(ctx, "pipeline", name)
if err != nil {
return nil, nil, nil, err
return nil, nil, nil, fmt.Errorf("resolver failed to get Pipeline %s: %w", name, err)
}
pipelineObj, vr, err := readRuntimeObjectAsPipeline(ctx, namespace, obj, k8s, tekton, refSource, verificationPolicies)
if err != nil {
return nil, nil, nil, err
return nil, nil, nil, fmt.Errorf("failed to read runtime object as Pipeline: %w", err)
}
return pipelineObj, refSource, vr, nil
}
Expand Down Expand Up @@ -150,7 +150,7 @@ func readRuntimeObjectAsPipeline(ctx context.Context, namespace string, obj runt
},
}
if err := obj.ConvertTo(ctx, p); err != nil {
return nil, nil, fmt.Errorf("failed to convert obj %s into Pipeline", obj.GetObjectKind().GroupVersionKind().String())
return nil, nil, fmt.Errorf("failed to convert v1beta1 obj %s into v1 Pipeline", obj.GetObjectKind().GroupVersionKind().String())
}
return p, &vr, nil
case *v1.Pipeline:
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/pipelineref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ func TestGetPipelineFunc_GetFuncError(t *testing.T) {
name: "get error when remote resolution return error",
requester: requesterUnsigned,
pipelinerun: *prResolutionError,
expectedErr: fmt.Errorf("error accessing data from remote resource: %w", resolvedUnsigned.DataErr),
expectedErr: fmt.Errorf("resolver failed to get Pipeline %s: error accessing data from remote resource: %w", prResolutionError.Spec.PipelineRef.Name, resolvedUnsigned.DataErr),
},
}
for _, tc := range testcases {
Expand Down

0 comments on commit 6847203

Please sign in to comment.