Playlists: Remove kubernetesPlaylists flag (#104171)

This commit is contained in:
Ryan McKinley
2025-04-22 10:39:40 +02:00
committed by GitHub
parent 64e9f9bf44
commit 17e4a3b386
10 changed files with 77 additions and 345 deletions
-20
View File
@@ -14,7 +14,6 @@ import (
"k8s.io/client-go/rest"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/storage/unified/apistore"
"github.com/grafana/grafana/pkg/storage/unified/resource"
@@ -153,22 +152,3 @@ func (o *StorageOptions) ApplyTo(serverConfig *genericapiserver.RecommendedConfi
serverConfig.RESTOptionsGetter = getter
return nil
}
// EnforceFeatureToggleAfterMode1 makes sure there is a feature toggle set for resources with DualWriterMode > 1.
// This is needed to ensure that we use the K8s client before enabling dual writing.
func (o *StorageOptions) EnforceFeatureToggleAfterMode1(features featuremgmt.FeatureToggles) error {
// nolint:staticcheck
if o.StorageType != StorageTypeLegacy {
for rg, s := range o.UnifiedStorageConfig {
if s.DualWriterMode > 1 {
switch rg {
case "playlists.playlist.grafana.app":
if !features.IsEnabledGlobally(featuremgmt.FlagKubernetesPlaylists) {
return fmt.Errorf("feature toggle FlagKubernetesPlaylists to be set")
}
}
}
}
}
return nil
}
@@ -4,66 +4,8 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
)
func TestStorageOptions_CheckFeatureToggle(t *testing.T) {
tests := []struct {
name string
StorageType StorageType
UnifiedStorageConfig map[string]setting.UnifiedStorageConfig
features any
wantErr bool
}{
{
name: "with legacy storage",
StorageType: StorageTypeLegacy, // nolint:staticcheck
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{"playlists.playlist.grafana.app": {DualWriterMode: 2}},
features: featuremgmt.WithFeatures(),
},
{
name: "with unified storage and without config for resource",
StorageType: StorageTypeUnified,
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{},
features: featuremgmt.WithFeatures(),
},
{
name: "with unified storage, mode > 1 and with toggle for resource",
StorageType: StorageTypeUnified,
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{"playlists.playlist.grafana.app": {DualWriterMode: 2}},
features: featuremgmt.WithFeatures(featuremgmt.FlagKubernetesPlaylists),
},
{
name: "with unified storage, mode > 1 and without toggle for resource",
StorageType: StorageTypeUnified,
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{"playlists.playlist.grafana.app": {DualWriterMode: 2}},
features: featuremgmt.WithFeatures(),
wantErr: true,
},
{
name: "with unified storage and mode = 1",
StorageType: StorageTypeUnified,
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{"playlists.playlist.grafana.app": {DualWriterMode: 1}},
features: featuremgmt.WithFeatures(),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
o := &StorageOptions{
StorageType: tt.StorageType,
UnifiedStorageConfig: tt.UnifiedStorageConfig,
}
err := o.EnforceFeatureToggleAfterMode1(tt.features.(featuremgmt.FeatureToggles))
if tt.wantErr {
return
}
assert.NoError(t, err)
})
}
}
func TestStorageOptions_Validate(t *testing.T) {
tests := []struct {
name string
-8
View File
@@ -271,14 +271,6 @@ func (s *service) start(ctx context.Context) error {
return errs[0]
}
// This will check that required feature toggles are enabled for more advanced storage modes
// Any required preconditions should be hardcoded here
if o.StorageOptions != nil {
if err := o.StorageOptions.EnforceFeatureToggleAfterMode1(s.features); err != nil {
return err
}
}
serverConfig := genericapiserver.NewRecommendedConfig(s.codecs)
if err := o.ApplyTo(serverConfig); err != nil {
return err
-8
View File
@@ -517,14 +517,6 @@ var (
Owner: grafanaDatavizSquad,
Expression: "true", // enabled by default
},
{
Name: "kubernetesPlaylists",
Description: "Use the kubernetes API in the frontend for playlists, and route /api/playlist requests to k8s",
Stage: FeatureStageGeneralAvailability,
Owner: grafanaAppPlatformSquad,
Expression: "true",
RequiresRestart: true, // changes the API routing
},
{
Name: "kubernetesSnapshots",
Description: "Routes snapshot requests from /api to the /apis endpoint",
-1
View File
@@ -66,7 +66,6 @@ panelMonitoring,GA,@grafana/dataviz-squad,false,false,true
enableNativeHTTPHistogram,experimental,@grafana/grafana-backend-services-squad,false,true,false
disableClassicHTTPHistogram,experimental,@grafana/grafana-backend-services-squad,false,true,false
formatString,GA,@grafana/dataviz-squad,false,false,true
kubernetesPlaylists,GA,@grafana/grafana-app-platform-squad,false,true,false
kubernetesSnapshots,experimental,@grafana/grafana-app-platform-squad,false,true,false
kubernetesDashboards,experimental,@grafana/grafana-app-platform-squad,false,false,true
kubernetesClientDashboardsFolders,GA,@grafana/grafana-app-platform-squad,false,false,false
1 Name Stage Owner requiresDevMode RequiresRestart FrontendOnly
66 enableNativeHTTPHistogram experimental @grafana/grafana-backend-services-squad false true false
67 disableClassicHTTPHistogram experimental @grafana/grafana-backend-services-squad false true false
68 formatString GA @grafana/dataviz-squad false false true
kubernetesPlaylists GA @grafana/grafana-app-platform-squad false true false
69 kubernetesSnapshots experimental @grafana/grafana-app-platform-squad false true false
70 kubernetesDashboards experimental @grafana/grafana-app-platform-squad false false true
71 kubernetesClientDashboardsFolders GA @grafana/grafana-app-platform-squad false false false
-4
View File
@@ -275,10 +275,6 @@ const (
// Enable format string transformer
FlagFormatString = "formatString"
// FlagKubernetesPlaylists
// Use the kubernetes API in the frontend for playlists, and route /api/playlist requests to k8s
FlagKubernetesPlaylists = "kubernetesPlaylists"
// FlagKubernetesSnapshots
// Routes snapshot requests from /api to the /apis endpoint
FlagKubernetesSnapshots = "kubernetesSnapshots"