Schema: convert dashboards from v1beta1 to v2beta1 (#109037)
- Implement full conversion pipeline from v1beta1 → v2beta1 - Ensure frontend–backend parity for all dashboard serialization paths - Add automatic data loss detection for conversions (panels, queries, annotations, links, variables) - Extract atomic conversion functions for v0 → v1beta1 → v2alpha1 → v2beta1 - Introduce conversion metrics and detailed logging for loss tracking - Normalize datasource resolution, defaults, and annotation processing - Improve panel layout serialization and y-coordinate normalization - Fix inconsistencies in nested panels and collapsed row behavior - Refine variable handling: - Filter refId from variable query specs - Default variable refresh to 'never' (matches frontend) - Fix constant and interval variable handling for missing queries - Unify schema defaults (enable, hide, iconColor, editable, liveNow) - Fix pluginId usage (UID vs type) and datasource references - Fix metrics.go bug swallowing errors (return nil → return err) - Add tests for version-specific conversion error handling - Add data loss detection tests using source/target version comparison - Clean up lint issues, legacy code, and redundant files - Update OpenAPI snapshots and migrated dashboards - Improve backend migrator to reuse datasource provider and match frontend logic Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com> Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com> Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
co-authored by
Haris Rozajac
Oscar Kilhed
Stephanie Hingtgen
parent
09942c08db
commit
e463781077
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
)
|
||||
|
||||
@@ -11,9 +12,20 @@ type datasourceInfoProvider struct {
|
||||
datasourceService datasources.DataSourceService
|
||||
}
|
||||
|
||||
func (d *datasourceInfoProvider) GetDataSourceInfo(_ context.Context) []schemaversion.DataSourceInfo {
|
||||
query := datasources.GetAllDataSourcesQuery{}
|
||||
dataSources, err := d.datasourceService.GetAllDataSources(context.Background(), &query)
|
||||
func (d *datasourceInfoProvider) GetDataSourceInfo(ctx context.Context) []schemaversion.DataSourceInfo {
|
||||
// Extract namespace info from context to get OrgID
|
||||
nsInfo, err := request.NamespaceInfoFrom(ctx, true)
|
||||
if err != nil {
|
||||
// If namespace info is not available, return empty list
|
||||
return []schemaversion.DataSourceInfo{}
|
||||
}
|
||||
|
||||
// Use GetDataSources with OrgID query instead of GetAllDataSources
|
||||
// This ensures tenant-aware datasource retrieval
|
||||
query := datasources.GetDataSourcesQuery{
|
||||
OrgID: nsInfo.OrgID,
|
||||
}
|
||||
dataSources, err := d.datasourceService.GetDataSources(ctx, &query)
|
||||
|
||||
if err != nil {
|
||||
return []schemaversion.DataSourceInfo{}
|
||||
|
||||
@@ -231,7 +231,7 @@ func (b *DashboardsAPIBuilder) InstallSchema(scheme *runtime.Scheme) error {
|
||||
}
|
||||
|
||||
// Register the explicit conversions
|
||||
if err := conversion.RegisterConversions(scheme); err != nil {
|
||||
if err := conversion.RegisterConversions(scheme, migration.GetDataSourceInfoProvider()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -3762,9 +3762,9 @@
|
||||
"default": ""
|
||||
},
|
||||
"value": {
|
||||
"description": "Value null means -Infinity",
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"default": 0
|
||||
"format": "double"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -3923,6 +3923,10 @@
|
||||
"properties"
|
||||
],
|
||||
"properties": {
|
||||
"__systemRef": {
|
||||
"description": "Describes config override rules created when interacting with Grafana.",
|
||||
"type": "string"
|
||||
},
|
||||
"matcher": {
|
||||
"default": {},
|
||||
"allOf": [
|
||||
|
||||
Reference in New Issue
Block a user