Dashboard migration: Add missing metrics registration (#110178)

This commit is contained in:
Dominik Prokop
2025-08-29 18:37:39 -06:00
committed by GitHub
parent b22f15ad16
commit 398ed84a60
13 changed files with 1504 additions and 90 deletions
@@ -5,11 +5,12 @@ import "fmt"
var _ error = &MigrationError{}
// ErrMigrationFailed is an error that is returned when a migration fails.
func NewMigrationError(msg string, currentVersion, targetVersion int) *MigrationError {
func NewMigrationError(msg string, currentVersion, targetVersion int, functionName string) *MigrationError {
return &MigrationError{
msg: msg,
targetVersion: targetVersion,
currentVersion: currentVersion,
functionName: functionName,
}
}
@@ -18,12 +19,18 @@ type MigrationError struct {
msg string
targetVersion int
currentVersion int
functionName string
}
func (e *MigrationError) Error() string {
return fmt.Errorf("schema migration from version %d to %d failed: %v", e.currentVersion, e.targetVersion, e.msg).Error()
}
// GetFunctionName returns the name of the migration function that failed
func (e *MigrationError) GetFunctionName() string {
return e.functionName
}
// MinimumVersionError is an error that is returned when the schema version is below the minimum version.
func NewMinimumVersionError(inputVersion int) *MinimumVersionError {
return &MinimumVersionError{inputVersion: inputVersion}
@@ -227,7 +227,7 @@ func (m *v24Migrator) migrate(dashboard map[string]interface{}) error {
// Find if the panel plugin exists
tablePanelPlugin := m.panelProvider.GetPanelPlugin("table")
if tablePanelPlugin.ID == "" {
return NewMigrationError("table panel plugin not found when migrating dashboard to schema version 24", 24, LATEST_VERSION)
return NewMigrationError("table panel plugin not found when migrating dashboard to schema version 24", 24, LATEST_VERSION, "V24")
}
panelMap["pluginVersion"] = tablePanelPlugin.Version
err := tablePanelChangedHandler(panelMap)
@@ -148,7 +148,7 @@ func (m *v28Migrator) migrateSinglestatPanel(panel map[string]interface{}) error
// Use cached stat panel version
if m.statPanelVersion == "" {
return NewMigrationError("stat panel plugin not found when migrating dashboard to schema version 28", 28, LATEST_VERSION)
return NewMigrationError("stat panel plugin not found when migrating dashboard to schema version 28", 28, LATEST_VERSION, "V28")
}
panel["pluginVersion"] = m.statPanelVersion