mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
UniStore: Add config to enable periodic DualWriter DataSyncer (#93555)
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
This commit is contained in:
@@ -67,6 +67,7 @@ kubernetesPlaylists = true
|
|||||||
|
|
||||||
[unified_storage.playlists.playlist.grafana.app]
|
[unified_storage.playlists.playlist.grafana.app]
|
||||||
dualWriterMode = 2
|
dualWriterMode = 2
|
||||||
|
dualWriterPeriodicDataSyncJobEnabled = true
|
||||||
```
|
```
|
||||||
|
|
||||||
This will create a development kubeconfig and start a parallel ssl listener. It can be registered by
|
This will create a development kubeconfig and start a parallel ssl listener. It can be registered by
|
||||||
|
|||||||
@@ -170,9 +170,13 @@ func InstallAPIs(
|
|||||||
// Get the option from custom.ini/command line
|
// Get the option from custom.ini/command line
|
||||||
// when missing this will default to mode zero (legacy only)
|
// when missing this will default to mode zero (legacy only)
|
||||||
var mode = grafanarest.DualWriterMode(0)
|
var mode = grafanarest.DualWriterMode(0)
|
||||||
|
|
||||||
|
var dualWriterPeriodicDataSyncJobEnabled bool
|
||||||
|
|
||||||
resourceConfig, resourceExists := storageOpts.UnifiedStorageConfig[key]
|
resourceConfig, resourceExists := storageOpts.UnifiedStorageConfig[key]
|
||||||
if resourceExists {
|
if resourceExists {
|
||||||
mode = resourceConfig.DualWriterMode
|
mode = resourceConfig.DualWriterMode
|
||||||
|
dualWriterPeriodicDataSyncJobEnabled = resourceConfig.DualWriterPeriodicDataSyncJobEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force using storage only -- regardless of internal synchronization state
|
// Force using storage only -- regardless of internal synchronization state
|
||||||
@@ -198,7 +202,7 @@ func InstallAPIs(
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if storageOpts.DualWriterDataSyncJobEnabled[key] {
|
if dualWriterPeriodicDataSyncJobEnabled {
|
||||||
grafanarest.StartPeriodicDataSyncer(ctx, currentMode, legacy, storage, key, reg, serverLock, requestInfo)
|
grafanarest.StartPeriodicDataSyncer(ctx, currentMode, legacy, storage, key, reg, serverLock, requestInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,11 +60,6 @@ func applyGrafanaConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles, o
|
|||||||
unifiedStorageCfg := cfg.UnifiedStorage
|
unifiedStorageCfg := cfg.UnifiedStorage
|
||||||
o.StorageOptions.UnifiedStorageConfig = unifiedStorageCfg
|
o.StorageOptions.UnifiedStorageConfig = unifiedStorageCfg
|
||||||
|
|
||||||
o.StorageOptions.DualWriterDataSyncJobEnabled = map[string]bool{
|
|
||||||
// TODO: This will be enabled later, when we get a dedicated config section for unified_storage
|
|
||||||
// playlist.RESOURCE + "." + playlist.GROUP: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
o.ExtraOptions.DevMode = features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerEnsureKubectlAccess)
|
o.ExtraOptions.DevMode = features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerEnsureKubectlAccess)
|
||||||
o.ExtraOptions.ExternalAddress = host
|
o.ExtraOptions.ExternalAddress = host
|
||||||
o.ExtraOptions.APIURL = apiURL
|
o.ExtraOptions.APIURL = apiURL
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ type StorageOptions struct { // The desired storage type
|
|||||||
|
|
||||||
// {resource}.{group} = 1|2|3|4
|
// {resource}.{group} = 1|2|3|4
|
||||||
UnifiedStorageConfig map[string]setting.UnifiedStorageConfig
|
UnifiedStorageConfig map[string]setting.UnifiedStorageConfig
|
||||||
|
|
||||||
// TODO... this will be moved to UnifiedStorageConfig
|
|
||||||
DualWriterDataSyncJobEnabled map[string]bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorageOptions() *StorageOptions {
|
func NewStorageOptions() *StorageOptions {
|
||||||
|
|||||||
@@ -532,6 +532,7 @@ type Cfg struct {
|
|||||||
|
|
||||||
type UnifiedStorageConfig struct {
|
type UnifiedStorageConfig struct {
|
||||||
DualWriterMode rest.DualWriterMode
|
DualWriterMode rest.DualWriterMode
|
||||||
|
DualWriterPeriodicDataSyncJobEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type InstallPlugin struct {
|
type InstallPlugin struct {
|
||||||
|
|||||||
@@ -25,7 +25,14 @@ func (cfg *Cfg) setUnifiedStorageConfig() {
|
|||||||
|
|
||||||
// parse dualWriter modes from the section
|
// parse dualWriter modes from the section
|
||||||
dualWriterMode := section.Key("dualWriterMode").MustInt(0)
|
dualWriterMode := section.Key("dualWriterMode").MustInt(0)
|
||||||
storageConfig[resourceName] = UnifiedStorageConfig{DualWriterMode: rest.DualWriterMode(dualWriterMode)}
|
|
||||||
|
// parse dualWriter periodic data syncer config
|
||||||
|
dualWriterPeriodicDataSyncJobEnabled := section.Key("dualWriterPeriodicDataSyncJobEnabled").MustBool(false)
|
||||||
|
|
||||||
|
storageConfig[resourceName] = UnifiedStorageConfig{
|
||||||
|
DualWriterMode: rest.DualWriterMode(dualWriterMode),
|
||||||
|
DualWriterPeriodicDataSyncJobEnabled: dualWriterPeriodicDataSyncJobEnabled,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cfg.UnifiedStorage = storageConfig
|
cfg.UnifiedStorage = storageConfig
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,17 @@ func TestCfg_setUnifiedStorageConfig(t *testing.T) {
|
|||||||
_, err = s.NewKey("dualWriterMode", "2")
|
_, err = s.NewKey("dualWriterMode", "2")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
_, err = s.NewKey("dualWriterPeriodicDataSyncJobEnabled", "true")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
cfg.setUnifiedStorageConfig()
|
cfg.setUnifiedStorageConfig()
|
||||||
|
|
||||||
value, exists := cfg.UnifiedStorage["playlists.playlist.grafana.app"]
|
value, exists := cfg.UnifiedStorage["playlists.playlist.grafana.app"]
|
||||||
|
|
||||||
assert.Equal(t, exists, true)
|
assert.Equal(t, exists, true)
|
||||||
assert.Equal(t, value, UnifiedStorageConfig{DualWriterMode: 2})
|
assert.Equal(t, value, UnifiedStorageConfig{
|
||||||
|
DualWriterMode: 2,
|
||||||
|
DualWriterPeriodicDataSyncJobEnabled: true,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user