Azure Monitor: Set error source in http and user errors accordingly (#100873)

pull/100988/head
Ivana Huckova 10 months ago committed by GitHub
parent 2d3de82ae9
commit 8986df26a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      pkg/tsdb/azuremonitor/azmoncredentials/builder.go
  2. 6
      pkg/tsdb/azuremonitor/metrics/azuremonitor-datasource.go

@ -1,10 +1,12 @@
package azmoncredentials
import (
"errors"
"fmt"
"github.com/grafana/grafana-azure-sdk-go/v2/azcredentials"
"github.com/grafana/grafana-azure-sdk-go/v2/azsettings"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data/utils/maputil"
)
@ -95,7 +97,7 @@ func getFromLegacy(data map[string]interface{}, secureData map[string]string) (a
clientSecret := secureData["clientSecret"]
if secureData["clientSecret"] == "" {
return nil, fmt.Errorf("unable to instantiate credentials, clientSecret must be set")
return nil, backend.DownstreamError(errors.New("unable to instantiate credentials, clientSecret must be set"))
}
credentials := &azcredentials.AzureClientSecretCredentials{

@ -269,7 +269,11 @@ func (e *AzureMonitorDatasource) retrieveSubscriptionDetails(cli *http.Client, c
res, err := cli.Do(req)
if err != nil {
return "", fmt.Errorf("failed to request subscription details: %s", err)
err = fmt.Errorf("failed to request subscription details: %s", err)
if backend.IsDownstreamHTTPError(err) {
err = backend.DownstreamError(err)
}
return "", err
}
defer func() {

Loading…
Cancel
Save