From 3e68731600f1fe55129d151836efffb9c29c674e Mon Sep 17 00:00:00 2001 From: Yuri Tseretyan Date: Wed, 8 Jan 2025 14:31:35 -0500 Subject: [PATCH] Alerting: Enable flag alertingApiServer by default (#98282) * enable flag alertingApiServer by default * remove feature flag toggle in integration tests * disable flag for old API tests --- .../configure-grafana/feature-toggles/index.md | 2 +- pkg/services/featuremgmt/registry.go | 3 ++- pkg/services/featuremgmt/toggles_gen.csv | 2 +- pkg/services/featuremgmt/toggles_gen.json | 12 ++++++++---- .../alerting/api_alertmanager_configuration_test.go | 2 ++ pkg/tests/api/alerting/api_alertmanager_test.go | 4 ++++ .../notifications/receivers/receiver_test.go | 7 +------ .../notifications/routingtree/routing_tree_test.go | 7 +------ .../templategroup/templates_group_test.go | 7 +------ .../notifications/timeinterval/timeinterval_test.go | 7 +------ pkg/tests/testinfra/testinfra.go | 9 +++++++++ 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index 57b70a34f93..c558e69fbaa 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -74,6 +74,7 @@ Most [generally available](https://grafana.com/docs/release-life-cycle/#general- | `pluginProxyPreserveTrailingSlash` | Preserve plugin proxy trailing slash. | | | `pinNavItems` | Enables pinning of nav items | Yes | | `openSearchBackendFlowEnabled` | Enables the backend query flow for Open Search datasource plugin | Yes | +| `alertingApiServer` | Register Alerting APIs with the K8s API server | Yes | | `cloudWatchRoundUpEndTime` | Round up end time for metric queries to the next minute to avoid missing data | Yes | | `cloudwatchMetricInsightsCrossAccount` | Enables cross account observability for Cloudwatch Metric Insights query builder | Yes | | `newFiltersUI` | Enables new combobox style UI for the Ad hoc filters variable in scenes architecture | Yes | @@ -204,7 +205,6 @@ Experimental features might be changed or removed without prior notice. | `alertingCentralAlertHistory` | Enables the new central alert history. | | `sqlQuerybuilderFunctionParameters` | Enables SQL query builder function parameters | | `failWrongDSUID` | Throws an error if a datasource has an invalid UIDs | -| `alertingApiServer` | Register Alerting APIs with the K8s API server | | `dataplaneAggregator` | Enable grafana dataplane aggregator | | `lokiSendDashboardPanelNames` | Send dashboard and panel names to Loki when querying | | `alertingPrometheusRulesPrimary` | Uses Prometheus rules as the primary source of truth for ruler-enabled data sources | diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 962cc9f32c2..bd14243b4f4 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -1371,9 +1371,10 @@ var ( { Name: "alertingApiServer", Description: "Register Alerting APIs with the K8s API server", - Stage: FeatureStageExperimental, + Stage: FeatureStageGeneralAvailability, Owner: grafanaAlertingSquad, RequiresRestart: true, + Expression: "true", }, { Name: "cloudWatchRoundUpEndTime", diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index 3cbc361006b..2e47f1f28cc 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -179,7 +179,7 @@ failWrongDSUID,experimental,@grafana/plugins-platform-backend,false,false,false zanzana,experimental,@grafana/identity-access-team,false,false,false reloadDashboardsOnParamsChange,experimental,@grafana/dashboards-squad,false,false,false enableScopesInMetricsExplore,experimental,@grafana/dashboards-squad,false,false,false -alertingApiServer,experimental,@grafana/alerting-squad,false,true,false +alertingApiServer,GA,@grafana/alerting-squad,false,true,false cloudWatchRoundUpEndTime,GA,@grafana/aws-datasources,false,false,false cloudwatchMetricInsightsCrossAccount,GA,@grafana/aws-datasources,false,false,true prometheusAzureOverrideAudience,deprecated,@grafana/partner-datasources,false,false,false diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index 7614f4bbe49..b196d4f9cc6 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -118,14 +118,18 @@ { "metadata": { "name": "alertingApiServer", - "resourceVersion": "1718908755156", - "creationTimestamp": "2024-06-20T20:52:03Z" + "resourceVersion": "1734627512749", + "creationTimestamp": "2024-06-20T20:52:03Z", + "annotations": { + "grafana.app/updatedTimestamp": "2024-12-19 16:58:32.7498017 +0000 UTC" + } }, "spec": { "description": "Register Alerting APIs with the K8s API server", - "stage": "experimental", + "stage": "GA", "codeowner": "@grafana/alerting-squad", - "requiresRestart": true + "requiresRestart": true, + "expression": "true" } }, { diff --git a/pkg/tests/api/alerting/api_alertmanager_configuration_test.go b/pkg/tests/api/alerting/api_alertmanager_configuration_test.go index b85d4f0d8ca..f8f95fbc58c 100644 --- a/pkg/tests/api/alerting/api_alertmanager_configuration_test.go +++ b/pkg/tests/api/alerting/api_alertmanager_configuration_test.go @@ -17,6 +17,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/grafana/grafana/pkg/services/featuremgmt" apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" "github.com/grafana/grafana/pkg/services/org" "github.com/grafana/grafana/pkg/services/org/orgimpl" @@ -398,6 +399,7 @@ func TestIntegrationAlertmanagerConfigurationPersistSecrets(t *testing.T) { EnableUnifiedAlerting: true, DisableAnonymous: true, AppModeProduction: true, + DisableFeatureToggles: []string{featuremgmt.FlagAlertingApiServer}, }) grafanaListedAddr, env := testinfra.StartGrafanaEnv(t, dir, path) diff --git a/pkg/tests/api/alerting/api_alertmanager_test.go b/pkg/tests/api/alerting/api_alertmanager_test.go index d51faf1c531..79747f40b32 100644 --- a/pkg/tests/api/alerting/api_alertmanager_test.go +++ b/pkg/tests/api/alerting/api_alertmanager_test.go @@ -22,6 +22,7 @@ import ( "github.com/grafana/grafana/pkg/expr" "github.com/grafana/grafana/pkg/infra/db" "github.com/grafana/grafana/pkg/infra/tracing" + "github.com/grafana/grafana/pkg/services/featuremgmt" apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models" ngstore "github.com/grafana/grafana/pkg/services/ngalert/store" @@ -49,6 +50,9 @@ func TestIntegrationAMConfigAccess(t *testing.T) { EnableUnifiedAlerting: true, DisableAnonymous: true, AppModeProduction: true, + DisableFeatureToggles: []string{ + featuremgmt.FlagAlertingApiServer, + }, }) grafanaListedAddr, env := testinfra.StartGrafanaEnv(t, dir, path) diff --git a/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go b/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go index 67938652c89..d7b3435afe8 100644 --- a/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go +++ b/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go @@ -35,7 +35,6 @@ import ( "github.com/grafana/grafana/pkg/services/accesscontrol/resourcepermissions" "github.com/grafana/grafana/pkg/services/authz/zanzana" "github.com/grafana/grafana/pkg/services/dashboards" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/folder/foldertest" alertingac "github.com/grafana/grafana/pkg/services/ngalert/accesscontrol" "github.com/grafana/grafana/pkg/services/ngalert/api" @@ -59,11 +58,7 @@ func TestMain(m *testing.M) { } func getTestHelper(t *testing.T) *apis.K8sTestHelper { - return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{ - EnableFeatureToggles: []string{ - featuremgmt.FlagAlertingApiServer, - }, - }) + return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{}) } func TestIntegrationResourceIdentifier(t *testing.T) { diff --git a/pkg/tests/apis/alerting/notifications/routingtree/routing_tree_test.go b/pkg/tests/apis/alerting/notifications/routingtree/routing_tree_test.go index 97e11f215ad..bbf00e76238 100644 --- a/pkg/tests/apis/alerting/notifications/routingtree/routing_tree_test.go +++ b/pkg/tests/apis/alerting/notifications/routingtree/routing_tree_test.go @@ -27,7 +27,6 @@ import ( "github.com/grafana/grafana/pkg/services/accesscontrol/resourcepermissions" "github.com/grafana/grafana/pkg/services/authz/zanzana" "github.com/grafana/grafana/pkg/services/dashboards" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/folder/foldertest" "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" "github.com/grafana/grafana/pkg/services/ngalert/store" @@ -44,11 +43,7 @@ func TestMain(m *testing.M) { } func getTestHelper(t *testing.T) *apis.K8sTestHelper { - return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{ - EnableFeatureToggles: []string{ - featuremgmt.FlagAlertingApiServer, - }, - }) + return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{}) } func TestIntegrationNotAllowedMethods(t *testing.T) { diff --git a/pkg/tests/apis/alerting/notifications/templategroup/templates_group_test.go b/pkg/tests/apis/alerting/notifications/templategroup/templates_group_test.go index 8e9fb85fc6f..26f2c10fdd8 100644 --- a/pkg/tests/apis/alerting/notifications/templategroup/templates_group_test.go +++ b/pkg/tests/apis/alerting/notifications/templategroup/templates_group_test.go @@ -22,7 +22,6 @@ import ( "github.com/grafana/grafana/pkg/services/accesscontrol/resourcepermissions" "github.com/grafana/grafana/pkg/services/authz/zanzana" "github.com/grafana/grafana/pkg/services/dashboards" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/folder/foldertest" "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" "github.com/grafana/grafana/pkg/services/ngalert/store" @@ -38,11 +37,7 @@ func TestMain(m *testing.M) { } func getTestHelper(t *testing.T) *apis.K8sTestHelper { - return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{ - EnableFeatureToggles: []string{ - featuremgmt.FlagAlertingApiServer, - }, - }) + return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{}) } func TestIntegrationResourceIdentifier(t *testing.T) { diff --git a/pkg/tests/apis/alerting/notifications/timeinterval/timeinterval_test.go b/pkg/tests/apis/alerting/notifications/timeinterval/timeinterval_test.go index 9bda66ef9e1..52d7cbdb1f8 100644 --- a/pkg/tests/apis/alerting/notifications/timeinterval/timeinterval_test.go +++ b/pkg/tests/apis/alerting/notifications/timeinterval/timeinterval_test.go @@ -28,7 +28,6 @@ import ( "github.com/grafana/grafana/pkg/services/accesscontrol/resourcepermissions" "github.com/grafana/grafana/pkg/services/authz/zanzana" "github.com/grafana/grafana/pkg/services/dashboards" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/folder/foldertest" "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models" @@ -49,11 +48,7 @@ func TestMain(m *testing.M) { } func getTestHelper(t *testing.T) *apis.K8sTestHelper { - return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{ - EnableFeatureToggles: []string{ - featuremgmt.FlagAlertingApiServer, - }, - }) + return apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{}) } func TestIntegrationResourceIdentifier(t *testing.T) { diff --git a/pkg/tests/testinfra/testinfra.go b/pkg/tests/testinfra/testinfra.go index 882bb710f17..84ebf182703 100644 --- a/pkg/tests/testinfra/testinfra.go +++ b/pkg/tests/testinfra/testinfra.go @@ -331,6 +331,14 @@ func CreateGrafDir(t *testing.T, opts GrafanaOpts) (string, string) { _, err = featureSection.NewKey("enable", strings.Join(opts.EnableFeatureToggles, " ")) require.NoError(t, err) } + if len(opts.DisableFeatureToggles) > 0 { + featureSection, err := cfg.NewSection("feature_toggles") + require.NoError(t, err) + for _, toggle := range opts.DisableFeatureToggles { + _, err = featureSection.NewKey(toggle, "false") + require.NoError(t, err) + } + } if opts.NGAlertAdminConfigPollInterval != 0 { ngalertingSection, err := cfg.NewSection("unified_alerting") require.NoError(t, err) @@ -490,6 +498,7 @@ func SQLiteIntegrationTest(t *testing.T) { type GrafanaOpts struct { EnableCSP bool EnableFeatureToggles []string + DisableFeatureToggles []string NGAlertAdminConfigPollInterval time.Duration NGAlertAlertmanagerConfigPollInterval time.Duration NGAlertSchedulerBaseInterval time.Duration