Data source plugin: Improve error message when plugin has connection issues (#102625)
* Improve data source error message when stackID * Update comment * Revert "Update comment" This reverts commit48922bc552. * Revert "Improve data source error message when stackID" This reverts commit4bf0a2f7b7. * Make public messagic configurable based on context * Update, simplify * Update * Update getting stack * Update pkg/plugins/errors.go Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com> * Refactor test to test for when context has stack value * Remove duplicated test * Fix error checking logic --------- Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>
This commit is contained in:
co-authored by
Andres Martinez Gotor
parent
ffb6fb59a3
commit
54a51bd3e3
@@ -35,7 +35,6 @@ var passthroughErrors = []error{
|
||||
plugins.ErrPluginUnavailable,
|
||||
plugins.ErrMethodNotImplemented,
|
||||
plugins.ErrPluginGrpcResourceExhaustedBase,
|
||||
plugins.ErrPluginGrpcConnectionUnavailableBase,
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
@@ -66,6 +65,12 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
||||
}
|
||||
}
|
||||
|
||||
// If the error is a plugin grpc connection unavailable error, return it directly
|
||||
// This error is created dynamically based on the context, so we need to check for it here
|
||||
if errors.Is(err, plugins.ErrPluginGrpcConnectionUnavailableBaseFn(ctx)) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return nil, plugins.ErrPluginRequestCanceledErrorBase.Errorf("client: query data request canceled: %w", err)
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ func TestQueryData(t *testing.T) {
|
||||
shouldPassThrough: false,
|
||||
},
|
||||
{
|
||||
err: plugins.ErrPluginGrpcConnectionUnavailableBase.Errorf("unavailable"),
|
||||
expectedError: plugins.ErrPluginGrpcConnectionUnavailableBase.Errorf("unavailable"),
|
||||
err: plugins.ErrPluginGrpcConnectionUnavailableBaseFn(context.Background()).Errorf("unavailable"),
|
||||
expectedError: plugins.ErrPluginGrpcConnectionUnavailableBaseFn(context.Background()).Errorf("unavailable"),
|
||||
shouldPassThrough: true,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user