merge main

This commit is contained in:
Ryan McKinley
2024-06-20 22:26:33 +03:00
42 changed files with 725 additions and 147 deletions
+3 -3
View File
@@ -19,7 +19,7 @@ const (
StorageTypeLegacy StorageType = "legacy"
StorageTypeUnified StorageType = "unified"
StorageTypeUnifiedGrpc StorageType = "unified-grpc"
StorageTypeUnifiedExp StorageType = "unified-exp"
StorageTypeUnifiedNext StorageType = "unified-next"
)
type StorageOptions struct {
@@ -45,10 +45,10 @@ func (o *StorageOptions) AddFlags(fs *pflag.FlagSet) {
func (o *StorageOptions) Validate() []error {
errs := []error{}
switch o.StorageType {
case StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedExp:
case StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext:
// no-op
default:
errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedExp))
errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext))
}
if _, _, err := net.SplitHostPort(o.Address); err != nil {
+1 -1
View File
@@ -262,7 +262,7 @@ func (s *service) start(ctx context.Context) error {
return err
}
case grafanaapiserveroptions.StorageTypeUnifiedExp:
case grafanaapiserveroptions.StorageTypeUnifiedNext:
if !s.features.IsEnabledGlobally(featuremgmt.FlagUnifiedStorage) {
return fmt.Errorf("unified storage requires the unifiedStorage feature flag")
}
+11
View File
@@ -1344,6 +1344,17 @@ var (
HideFromDocs: true,
HideFromAdminPage: true,
},
{
Name: "passScopeToDashboardApi",
Description: "Enables the passing of scopes to dashboards fetching in Grafana",
FrontendOnly: false,
Stage: FeatureStageExperimental,
Owner: grafanaDashboardsSquad,
RequiresRestart: false,
AllowSelfServe: false,
HideFromDocs: true,
HideFromAdminPage: true,
},
}
)
+1
View File
@@ -178,3 +178,4 @@ ssoSettingsLDAP,experimental,@grafana/identity-access-team,false,false,false
failWrongDSUID,experimental,@grafana/plugins-platform-backend,false,false,false
databaseReadReplica,experimental,@grafana/grafana-backend-services-squad,false,false,false
zanzana,experimental,@grafana/identity-access-team,false,false,false
passScopeToDashboardApi,experimental,@grafana/dashboards-squad,false,false,false
1 Name Stage Owner requiresDevMode RequiresRestart FrontendOnly
178 failWrongDSUID experimental @grafana/plugins-platform-backend false false false
179 databaseReadReplica experimental @grafana/grafana-backend-services-squad false false false
180 zanzana experimental @grafana/identity-access-team false false false
181 passScopeToDashboardApi experimental @grafana/dashboards-squad false false false
+4
View File
@@ -722,4 +722,8 @@ const (
// FlagZanzana
// Use openFGA as authorization engine.
FlagZanzana = "zanzana"
// FlagPassScopeToDashboardApi
// Enables the passing of scopes to dashboards fetching in Grafana
FlagPassScopeToDashboardApi = "passScopeToDashboardApi"
)
+15 -1
View File
@@ -1678,6 +1678,20 @@
"requiresDevMode": true
}
},
{
"metadata": {
"name": "passScopeToDashboardApi",
"resourceVersion": "1718290335877",
"creationTimestamp": "2024-06-13T14:52:15Z"
},
"spec": {
"description": "Enables the passing of scopes to dashboards fetching in Grafana",
"stage": "experimental",
"codeowner": "@grafana/dashboards-squad",
"hideFromAdminPage": true,
"hideFromDocs": true
}
},
{
"metadata": {
"name": "pdfTables",
@@ -2335,4 +2349,4 @@
}
}
]
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ func (sc *SmtpClient) Send(ctx context.Context, messages ...*Message) (int, erro
emailsSentFailed.Inc()
}
err = fmt.Errorf("failed to send notification to email addresses: %s: %w", strings.Join(msg.To, ";"), innerError)
err = fmt.Errorf("failed to send email: %w", innerError)
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
+21
View File
@@ -58,6 +58,27 @@ func WrapDatabaseDriverWithHooks(dbType string, tracer tracing.Tracer) string {
return driverWithHooks
}
// WrapDatabaseDriverWithHooks creates a fake database driver that
// executes pre and post functions which we use to gather metrics about
// database queries. It also registers the metrics.
func WrapDatabaseReplDriverWithHooks(dbType string, tracer tracing.Tracer) string {
drivers := map[string]driver.Driver{
migrator.SQLite: &sqlite3.SQLiteDriver{},
migrator.MySQL: &mysql.MySQLDriver{},
migrator.Postgres: &pq.Driver{},
}
d, exist := drivers[dbType]
if !exist {
return dbType
}
driverWithHooks := dbType + "ReplicaWithHooks"
sql.Register(driverWithHooks, sqlhooks.Wrap(d, &databaseQueryWrapper{log: log.New("sqlstore.metrics"), tracer: tracer}))
core.RegisterDriver(driverWithHooks, &databaseQueryWrapperDriver{dbType: dbType})
return driverWithHooks
}
// databaseQueryWrapper satisfies the sqlhook.databaseQueryWrapper interface
// which allow us to wrap all SQL queries with a `Before` & `After` hook.
type databaseQueryWrapper struct {
+1 -1
View File
@@ -118,7 +118,7 @@ func (ss *SQLStore) initReadOnlyEngine(engine *xorm.Engine) error {
ss.dbCfg = dbCfg
if ss.cfg.DatabaseInstrumentQueries {
ss.dbCfg.Type = WrapDatabaseDriverWithHooks(ss.dbCfg.Type, ss.tracer)
ss.dbCfg.Type = WrapDatabaseReplDriverWithHooks(ss.dbCfg.Type, ss.tracer)
}
if engine == nil {