Revert "Use dw dynamic config" (#91846)

Revert "Use dw dynamic config (#91222)"

This reverts commit 0258842f87.
This commit is contained in:
Leonor Oliveira
2024-08-13 17:24:26 +02:00
committed by GitHub
parent b4db8bb967
commit d52d04b6d8
14 changed files with 70 additions and 31 deletions
+4 -5
View File
@@ -4,6 +4,7 @@
```ini
[feature_toggles]
kubernetesPlaylists = true
```
Start Grafana:
@@ -61,10 +62,8 @@ For kubectl to work, grafana needs to run over https. To simplify development,
app_mode = development
[feature_toggles]
grafanaAPIServerEnsureKubectlAccess = true
[unified_storage]
playlists.playlist.grafana.app = 2
grafanaAPIServerEnsureKubectlAccess = true
kubernetesPlaylists = true
```
This will create a development kubeconfig and start a parallel ssl listener. It can be registered by
@@ -91,4 +90,4 @@ The folder structure aims to follow the patterns established in standard (https:
* [pkg/apis](/pkg/apis) - where API resource types are defined. this is based on the structure of the [sample-apiserver](https://github.com/kubernetes/sample-apiserver/tree/master/pkg/apis)
* [hack/update-codegen.sh](/hack#kubernetes-hack-alert) - this script is used to run [k8s codegen](https://github.com/kubernetes/code-generator/), which generates the code that is used by the API server to handle the types defined in `pkg/apis`. it is based on the [update-codegen.sh from sample-apiserver](https://github.com/kubernetes/sample-apiserver/blob/master/hack/update-codegen.sh)
* [pkg/registry/apis](/pkg/registry/apis) - where all of the types in `pkg/apis` are registered with the API server by implementing the [builder](/pkg/services/apiserver/builder/common.go#L18) interface. this pattern is unique to grafana, and is needed to support using wire dependencies in legacy storage implementations. this is separated from `pkg/apis` to avoid issues with k8s codegen.
* [pkg/cmd/grafana/apiserver](/pkg/cmd/grafana/apiserver) - this is where the apiserver is configured for the `grafana apiserver` CLI command, which can be used to launch standalone API servers. this will eventually be merged with the config in `pkg/services/apiserver` to reduce duplication.
* [pkg/cmd/grafana/apiserver](/pkg/cmd/grafana/apiserver) - this is where the apiserver is configured for the `grafana apiserver` CLI command, which can be used to launch standalone API servers. this will eventually be merged with the config in `pkg/services/apiserver` to reduce duplication.
+7 -8
View File
@@ -7,6 +7,7 @@ import (
"strconv"
playlist "github.com/grafana/grafana/pkg/apis/playlist/v0alpha1"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/services/apiserver/options"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
@@ -54,16 +55,14 @@ func applyGrafanaConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles, o
o.StorageOptions.StorageType = options.StorageType(apiserverCfg.Key("storage_type").MustString(string(options.StorageTypeLegacy)))
o.StorageOptions.DataPath = apiserverCfg.Key("storage_path").MustString(filepath.Join(cfg.DataPath, "grafana-apiserver"))
o.StorageOptions.Address = apiserverCfg.Key("address").MustString(o.StorageOptions.Address)
// unified storage modes
unifiedStorageCfg := cfg.UnifiedStorage
o.StorageOptions.DualWriterDesiredModes = unifiedStorageCfg
o.StorageOptions.DualWriterDesiredModes = map[string]grafanarest.DualWriterMode{
// TODO: use the new config from HGAPI after https://github.com/grafana/hosted-grafana/pull/5707
playlist.GROUPRESOURCE: 2,
}
// TODO: ensure backwards compatibility with production
// remove this after changing the unified_storage key format in HGAPI
if _, ok := o.StorageOptions.DualWriterDesiredModes[playlist.RESOURCE+"."+playlist.GROUP]; ok {
o.StorageOptions.DualWriterDesiredModes[playlist.RESOURCE+"."+playlist.GROUP] = o.StorageOptions.DualWriterDesiredModes[playlist.GROUPRESOURCE]
}
// remove this after changing the unified_storage_mode key format in HGAPI
o.StorageOptions.DualWriterDesiredModes[playlist.RESOURCE+"."+playlist.GROUP] = o.StorageOptions.DualWriterDesiredModes[playlist.GROUPRESOURCE]
o.ExtraOptions.DevMode = features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerEnsureKubectlAccess)
o.ExtraOptions.ExternalAddress = host
+8
View File
@@ -721,6 +721,14 @@ 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
@@ -94,6 +94,7 @@ enableNativeHTTPHistogram,experimental,@grafana/grafana-backend-services-squad,f
disableClassicHTTPHistogram,experimental,@grafana/grafana-backend-services-squad,false,true,false
formatString,GA,@grafana/dataviz-squad,false,false,true
transformationsVariableSupport,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
datasourceQueryTypes,experimental,@grafana/grafana-app-platform-squad,false,true,false
1 Name Stage Owner requiresDevMode RequiresRestart FrontendOnly
94 disableClassicHTTPHistogram experimental @grafana/grafana-backend-services-squad false true false
95 formatString GA @grafana/dataviz-squad false false true
96 transformationsVariableSupport GA @grafana/dataviz-squad false false true
97 kubernetesPlaylists GA @grafana/grafana-app-platform-squad false true false
98 kubernetesSnapshots experimental @grafana/grafana-app-platform-squad false true false
99 kubernetesDashboards experimental @grafana/grafana-app-platform-squad false false true
100 datasourceQueryTypes experimental @grafana/grafana-app-platform-squad false true false
+4
View File
@@ -387,6 +387,10 @@ const (
// Allows using variables in transformations
FlagTransformationsVariableSupport = "transformationsVariableSupport"
// 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"
@@ -1438,7 +1438,6 @@
"name": "kubernetesPlaylists",
"resourceVersion": "1720021873452",
"creationTimestamp": "2023-10-05T19:00:36Z",
"deletionTimestamp": "2024-07-30T19:34:12Z",
"annotations": {
"grafana.app/updatedTimestamp": "2024-07-03 15:51:13.452477 +0000 UTC"
}