Use dw dynamic config (#91882)
* Remove kubernetesPlaylists feature_toggle * Remove unified_storage_mode * Remove double import * Read from config instead from feature_toggle * cover scenario for when unified storage is not defined * Be temporarily retro compatible with previous feature toggle * Properly read unified_storage section * [WIP] Read new format of config * Fix test * Fix other tests * Generate feature flags file * Use <group>.<resource> schema * Use <group>.resource format on the FE as well * Hide UniStore config from Frontend Signed-off-by: Maicon Costa <maiconscosta@gmail.com> * unwanted changes * Use feature toggles in the FE. Enforce FTs are present before enabling dual writing Co-authored-by: Ryan McKinley <ryantxu@users.noreply.github.com> * use kubernetes playlists feature toggle on the FE * Remove unwanted code * Remove configs from the FE * Remove commented code * Add more explicit example --------- Signed-off-by: Maicon Costa <maiconscosta@gmail.com> Co-authored-by: Maicon Costa <maiconscosta@gmail.com>
This commit is contained in:
co-authored by
Ryan McKinley
Maicon Costa
parent
f8765087b5
commit
2e451b2ed7
@@ -18,6 +18,7 @@ import (
|
||||
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/playlist"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tests/apis"
|
||||
"github.com/grafana/grafana/pkg/tests/testinfra"
|
||||
"github.com/grafana/grafana/pkg/tests/testsuite"
|
||||
@@ -92,12 +93,14 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
AppModeProduction: true,
|
||||
DisableAnonymous: true,
|
||||
APIServerStorageType: "file", // write the files to disk
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode0,
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode0,
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -106,12 +109,14 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
AppModeProduction: true,
|
||||
DisableAnonymous: true,
|
||||
APIServerStorageType: "file", // write the files to disk
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode1,
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode1,
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -120,12 +125,14 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
AppModeProduction: true,
|
||||
DisableAnonymous: true,
|
||||
APIServerStorageType: "file", // write the files to disk
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode2,
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode2,
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -134,12 +141,14 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
AppModeProduction: true,
|
||||
DisableAnonymous: true,
|
||||
APIServerStorageType: "file", // write the files to disk
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode3,
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode3,
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -151,8 +160,10 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode0,
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode0,
|
||||
},
|
||||
},
|
||||
}))
|
||||
})
|
||||
@@ -162,12 +173,7 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
AppModeProduction: false, // required for unified storage
|
||||
DisableAnonymous: true,
|
||||
APIServerStorageType: "unified", // use the entity api tables
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode1,
|
||||
},
|
||||
EnableFeatureToggles: []string{},
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -179,8 +185,10 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode2,
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode2,
|
||||
},
|
||||
},
|
||||
}))
|
||||
})
|
||||
@@ -193,8 +201,10 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode3,
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode3,
|
||||
},
|
||||
},
|
||||
}))
|
||||
})
|
||||
@@ -207,12 +217,14 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
AppModeProduction: true,
|
||||
DisableAnonymous: true,
|
||||
APIServerStorageType: "etcd", // requires etcd running on localhost:2379
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode0,
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode0,
|
||||
},
|
||||
})
|
||||
|
||||
// Clear the collection before starting (etcd)
|
||||
@@ -237,8 +249,10 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode1,
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode1,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -264,8 +278,10 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode2,
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode2,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -291,8 +307,10 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
|
||||
},
|
||||
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
|
||||
playlistv0alpha1.GROUPRESOURCE: grafanarest.Mode3,
|
||||
UnifiedStorageConfig: map[string]setting.UnifiedStorageConfig{
|
||||
playlistv0alpha1.GROUPRESOURCE: {
|
||||
DualWriterMode: grafanarest.Mode3,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
"gopkg.in/ini.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api"
|
||||
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
|
||||
"github.com/grafana/grafana/pkg/extensions"
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/fs"
|
||||
@@ -390,12 +389,11 @@ func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
||||
_, err = grafanaComSection.NewKey("api_url", o.GrafanaComAPIURL)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
if o.DualWriterDesiredModes != nil {
|
||||
unifiedStorageMode, err := getOrCreateSection("unified_storage_mode")
|
||||
require.NoError(t, err)
|
||||
for k, v := range o.DualWriterDesiredModes {
|
||||
_, err = unifiedStorageMode.NewKey(k, fmt.Sprint(v))
|
||||
if o.UnifiedStorageConfig != nil {
|
||||
for k, v := range o.UnifiedStorageConfig {
|
||||
section, err := getOrCreateSection(fmt.Sprintf("unified_storage.%s", k))
|
||||
require.NoError(t, err)
|
||||
_, err = section.NewKey("dualWriterMode", fmt.Sprintf("%d", v.DualWriterMode))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
}
|
||||
@@ -446,7 +444,7 @@ type GrafanaOpts struct {
|
||||
QueryRetries int64
|
||||
APIServerStorageType string
|
||||
GrafanaComAPIURL string
|
||||
DualWriterDesiredModes map[string]grafanarest.DualWriterMode
|
||||
UnifiedStorageConfig map[string]setting.UnifiedStorageConfig
|
||||
}
|
||||
|
||||
func CreateUser(t *testing.T, store db.DB, cfg *setting.Cfg, cmd user.CreateUserCommand) *user.User {
|
||||
|
||||
Reference in New Issue
Block a user