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

Error sweep: add more context for PipelineRunCouldntGetPipeline error message #7403

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading