k8s: remove dependency on app_mode development (#85474)

* k8s: remove dependency on app_mode development

* remove dev conditions on storage server

* remove logic to drop entity tables
This commit is contained in:
Georges Chaudy
2024-05-03 10:28:15 +02:00
committed by GitHub
parent fd58168c3b
commit dd0e646e92
8 changed files with 10 additions and 66 deletions

View File

@@ -115,6 +115,7 @@ Experimental features might be changed or removed without prior notice.
| `scenes` | Experimental framework to build interactive dashboards |
| `disableSecretsCompatibility` | Disable duplicated secret storage in legacy tables |
| `logRequestsInstrumentedAsUnknown` | Logs the path for requests that are instrumented as unknown |
| `unifiedStorage` | SQL-based k8s storage |
| `showDashboardValidationWarnings` | Show warnings when dashboards do not validate against the schema |
| `mysqlAnsiQuotes` | Use double quotes to escape keyword in a MySQL query |
| `alertingBacktesting` | Rule backtesting API for alerting |
@@ -185,7 +186,6 @@ The following toggles require explicitly setting Grafana's [app mode]({{< relref
| Feature toggle name | Description |
| -------------------------------------- | -------------------------------------------------------------- |
| `unifiedStorage` | SQL-based k8s storage |
| `grafanaAPIServerWithExperimentalAPIs` | Register experimental APIs with the k8s API server |
| `grafanaAPIServerEnsureKubectlAccess` | Start an additional https handler and write kubectl options |
| `panelTitleSearchInV1` | Enable searching for dashboards using panel title in search v1 |

View File

@@ -106,14 +106,6 @@ func (s *ModuleServer) Run() error {
s.notifySystemd("READY=1")
s.log.Debug("Waiting on services...")
// Only allow individual dskit modules to run in dev mode.
if s.cfg.Env != setting.Dev {
if len(s.cfg.Target) > 1 || s.cfg.Target[0] != "all" {
s.log.Error("dskit module targeting is only supported in dev mode. Falling back to 'all'")
s.cfg.Target = []string{"all"}
}
}
m := modules.New(s.cfg.Target)
// only run the instrumentation server module if were not running a module that already contains an http server

View File

@@ -243,7 +243,7 @@ func (s *service) start(ctx context.Context) error {
case grafanaapiserveroptions.StorageTypeUnified:
if !s.features.IsEnabledGlobally(featuremgmt.FlagUnifiedStorage) {
return fmt.Errorf("unified storage requires the unifiedStorage feature flag (and app_mode = development)")
return fmt.Errorf("unified storage requires the unifiedStorage feature flag")
}
eDB, err := dbimpl.ProvideEntityDB(s.db, s.cfg, s.features)

View File

@@ -224,7 +224,7 @@ var (
Name: "unifiedStorage",
Description: "SQL-based k8s storage",
Stage: FeatureStageExperimental,
RequiresDevMode: true,
RequiresDevMode: false,
RequiresRestart: true, // new SQL tables created
Owner: grafanaAppPlatformSquad,
},

View File

@@ -27,7 +27,7 @@ logRequestsInstrumentedAsUnknown,experimental,@grafana/hosted-grafana-team,false
topnav,deprecated,@grafana/grafana-frontend-platform,false,false,false
returnToPrevious,GA,@grafana/grafana-frontend-platform,false,false,true
grpcServer,preview,@grafana/grafana-app-platform-squad,false,false,false
unifiedStorage,experimental,@grafana/grafana-app-platform-squad,true,true,false
unifiedStorage,experimental,@grafana/grafana-app-platform-squad,false,true,false
cloudWatchCrossAccountQuerying,GA,@grafana/aws-datasources,false,false,false
showDashboardValidationWarnings,experimental,@grafana/dashboards-squad,false,false,false
mysqlAnsiQuotes,experimental,@grafana/search-and-storage,false,false,false
1 Name Stage Owner requiresDevMode RequiresRestart FrontendOnly
27 topnav deprecated @grafana/grafana-frontend-platform false false false
28 returnToPrevious GA @grafana/grafana-frontend-platform false false true
29 grpcServer preview @grafana/grafana-app-platform-squad false false false
30 unifiedStorage experimental @grafana/grafana-app-platform-squad true false true false
31 cloudWatchCrossAccountQuerying GA @grafana/aws-datasources false false false
32 showDashboardValidationWarnings experimental @grafana/dashboards-squad false false false
33 mysqlAnsiQuotes experimental @grafana/search-and-storage false false false

View File

@@ -437,14 +437,16 @@
{
"metadata": {
"name": "unifiedStorage",
"resourceVersion": "1713545444177",
"creationTimestamp": "2024-04-19T16:50:44Z"
"resourceVersion": "1714723955745",
"creationTimestamp": "2024-04-19T16:50:44Z",
"annotations": {
"grafana.app/updatedTimestamp": "2024-05-03 08:12:35.745103 +0000 UTC"
}
},
"spec": {
"description": "SQL-based k8s storage",
"stage": "experimental",
"codeowner": "@grafana/grafana-app-platform-squad",
"requiresDevMode": true,
"requiresRestart": true
}
},

View File

@@ -17,8 +17,6 @@ There are 2 main tables, the `entity` table stores a "current" view of the objec
The minimum config settings required are:
```ini
; dev mode is required
app_mode = development
; need to specify target here for override to work later
target = all

View File

@@ -1,12 +1,8 @@
package migrations
import (
"context"
"fmt"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/sqlstore/session"
"github.com/grafana/grafana/pkg/services/store/entity/db"
)
@@ -24,51 +20,7 @@ func MigrateEntityStore(db db.EntityDBInterface, features featuremgmt.FeatureTog
mg := migrator.NewScopedMigrator(engine, db.GetCfg(), "entity")
mg.AddCreateMigration()
marker := initEntityTables(mg)
// While this feature is under development, we can completly wipe and recreate
// The initial plan is to keep the source of truth in existing SQL tables, and mirrot it
// to a kubernetes model. Once the kubernetes model needs to be preserved,
// this code should be removed
exists, err := engine.IsTableExist("entity_migration_log")
if err != nil {
return err
}
if exists {
log, err := mg.GetMigrationLog()
if err != nil {
return err
}
_, found := log[marker]
if !found && len(log) > 0 {
// Remove the migration log (and potential other orphan tables)
tables := []string{"entity_migration_log"}
ctx := context.Background()
sess, err := db.GetSession()
if err != nil {
return err
}
err = sess.WithTransaction(ctx, func(tx *session.SessionTx) error {
for _, t := range tables {
_, err := tx.Exec(ctx, fmt.Sprintf("DROP TABLE IF EXISTS %s", t))
if err != nil {
return err
}
}
return nil
})
if err != nil {
return err
}
// remove old entries from in-memory log
for id := range log {
mg.RemoveMigrationLogs(id)
}
}
}
initEntityTables(mg)
// since it's a new feature enable migration locking by default
return mg.Start(true, 0)