Fix listing and getting dashboard versions across different API versions (#109860)

* Fix listing and getting dashboard versions across different API versions

What

This commit updates dashboard version service to use API version aware
API client. The service now also supports parsing different API version
representation of dashboards.

The API version aware client is also updated to support listing across
versions.

Why

Currently listing or getting specific versions is broken for all v2
versions of the dashboard API, especially if the dashboard being checked
is still saved using v1 APIs.

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

* Remove superfluous tracing spans

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

---------

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>
This commit is contained in:
Igor Suleymanov
2025-09-03 13:51:11 +03:00
committed by GitHub
parent 95080d9d56
commit a07a8d0ba2
13 changed files with 794 additions and 103 deletions
+25 -3
View File
@@ -37,6 +37,7 @@ import (
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/dashboards/database"
dashboardservice "github.com/grafana/grafana/pkg/services/dashboards/service"
dashclient "github.com/grafana/grafana/pkg/services/dashboards/service/client"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/folder/folderimpl"
"github.com/grafana/grafana/pkg/services/licensing/licensingtest"
@@ -446,11 +447,32 @@ func setupServer(b testing.TB, sc benchScenario, features featuremgmt.FeatureTog
cfg, features, routing.NewRouteRegister(), sc.db, ac, license, folderServiceWithFlagOn, acSvc, sc.teamSvc, sc.userSvc, actionSets)
require.NoError(b, err)
dashboardSvc, err := dashboardservice.ProvideDashboardServiceImpl(
sc.cfg, dashStore, folderStore,
features, folderPermissions, ac, actest.FakeService{},
folderServiceWithFlagOn, nil, client.MockTestRestConfig{}, nil, quotaSrv, nil, nil, nil, dualwrite.ProvideTestService(), sort.ProvideService(),
sc.cfg,
dashStore,
folderStore,
features,
folderPermissions,
ac,
actest.FakeService{},
folderServiceWithFlagOn,
nil,
quotaSrv,
nil,
nil,
dualwrite.ProvideTestService(),
serverlock.ProvideService(sc.db, tracing.InitializeTracerForTest()),
kvstore.NewFakeKVStore(),
dashclient.NewK8sClientWithFallback(
sc.cfg,
client.MockTestRestConfig{},
dashStore,
sc.userSvc,
nil,
sort.ProvideService(),
dualwrite.ProvideTestService(),
nil,
features,
),
)
require.NoError(b, err)