Advisor: Redefine check properties (#100874)
This commit is contained in:
committed by
GitHub
parent
9f49f4ce36
commit
a24fd1b722
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
type check struct {
|
||||
@@ -72,7 +73,12 @@ func (s *uidValidationStep) Title() string {
|
||||
}
|
||||
|
||||
func (s *uidValidationStep) Description() string {
|
||||
return "Check if the UID of each data source is valid."
|
||||
return "Checks if the UID of a data source is valid."
|
||||
}
|
||||
|
||||
func (s *uidValidationStep) Resolution() string {
|
||||
return "Check the <a href='https://grafana.com/docs/grafana/latest/upgrade-guide/upgrade-v11.2/#grafana-data-source-uid-format-enforcement'" +
|
||||
"target=_blank>documentation</a> for more information or delete the data source and create a new one."
|
||||
}
|
||||
|
||||
func (s *uidValidationStep) Run(ctx context.Context, obj *advisor.CheckSpec, i any) (*advisor.CheckReportFailure, error) {
|
||||
@@ -85,10 +91,9 @@ func (s *uidValidationStep) Run(ctx context.Context, obj *advisor.CheckSpec, i a
|
||||
if err != nil {
|
||||
return checks.NewCheckReportFailure(
|
||||
advisor.CheckReportFailureSeverityLow,
|
||||
fmt.Sprintf("Invalid UID '%s' for data source %s", ds.UID, ds.Name),
|
||||
"Check the <a href='https://grafana.com/docs/grafana/latest/upgrade-guide/upgrade-v11.2/#grafana-data-source-uid-format-enforcement' target=_blank>documentation</a> for more information.",
|
||||
s.ID(),
|
||||
ds.UID,
|
||||
fmt.Sprintf("%s (%s)", ds.Name, ds.UID),
|
||||
[]advisor.CheckErrorLink{},
|
||||
), nil
|
||||
}
|
||||
return nil, nil
|
||||
@@ -104,7 +109,11 @@ func (s *healthCheckStep) Title() string {
|
||||
}
|
||||
|
||||
func (s *healthCheckStep) Description() string {
|
||||
return "Check if all data sources are healthy."
|
||||
return "Checks if a data sources is healthy."
|
||||
}
|
||||
|
||||
func (s *healthCheckStep) Resolution() string {
|
||||
return "Go to the data source configuration page and address the issues reported."
|
||||
}
|
||||
|
||||
func (s *healthCheckStep) ID() string {
|
||||
@@ -124,7 +133,9 @@ func (s *healthCheckStep) Run(ctx context.Context, obj *advisor.CheckSpec, i any
|
||||
}
|
||||
pCtx, err := s.PluginContextProvider.GetWithDataSource(ctx, ds.Type, requester, ds)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get plugin context: %w", err)
|
||||
// Unable to check health check
|
||||
klog.Error("Failed to get plugin context", "datasource_uid", ds.UID, "error", err)
|
||||
return nil, nil
|
||||
}
|
||||
req := &backend.CheckHealthRequest{
|
||||
PluginContext: pCtx,
|
||||
@@ -134,12 +145,14 @@ func (s *healthCheckStep) Run(ctx context.Context, obj *advisor.CheckSpec, i any
|
||||
if err != nil || resp.Status != backend.HealthStatusOk {
|
||||
return checks.NewCheckReportFailure(
|
||||
advisor.CheckReportFailureSeverityHigh,
|
||||
fmt.Sprintf("Health check failed for %s", ds.Name),
|
||||
fmt.Sprintf(
|
||||
"Go to the <a href='/connections/datasources/edit/%s'>data source configuration</a>"+
|
||||
" and address the issues reported.", ds.UID),
|
||||
s.ID(),
|
||||
ds.UID,
|
||||
ds.Name,
|
||||
[]advisor.CheckErrorLink{
|
||||
{
|
||||
Message: "Fix me",
|
||||
Url: fmt.Sprintf("/connections/datasources/edit/%s", ds.UID),
|
||||
},
|
||||
},
|
||||
), nil
|
||||
}
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user