CloudMigrations: Remove feature toggle and introduce config setting to disable it (#114223)
This commit is contained in:
@@ -2179,6 +2179,8 @@ enabled = true
|
||||
|
||||
###################################### Cloud Migration ######################################
|
||||
[cloud_migration]
|
||||
# Set to false to disable the Cloud Migration feature
|
||||
enabled = true
|
||||
# Set to true to enable target-side migration UI
|
||||
is_target = false
|
||||
# Token used to send requests to grafana com
|
||||
|
||||
@@ -2071,6 +2071,8 @@ default_datasource_uid =
|
||||
|
||||
###################################### Cloud Migration ######################################
|
||||
[cloud_migration]
|
||||
# Set to false to disable the Cloud Migration feature
|
||||
;enabled = true
|
||||
# Set to true to enable target-side migration UI
|
||||
;is_target = false
|
||||
# Token used to send requests to grafana com
|
||||
|
||||
@@ -42,7 +42,6 @@ Most [generally available](https://grafana.com/docs/release-life-cycle/#general-
|
||||
| `dashboardSceneSolo` | Enables rendering dashboards using scenes for solo panels | Yes |
|
||||
| `dashboardScene` | Enables dashboard rendering using scenes for all roles | Yes |
|
||||
| `alertingQueryOptimization` | Optimizes eligible queries in order to reduce load on datasources | |
|
||||
| `onPremToCloudMigrations` | Enable the Grafana Migration Assistant, which helps you easily migrate various on-prem resources to your Grafana Cloud stack. | Yes |
|
||||
| `cloudWatchNewLabelParsing` | Updates CloudWatch label parsing to be more accurate | Yes |
|
||||
| `pluginProxyPreserveTrailingSlash` | Preserve plugin proxy trailing slash. | |
|
||||
| `azureMonitorPrometheusExemplars` | Allows configuration of Azure Monitor as a data source that can provide Prometheus exemplars | Yes |
|
||||
|
||||
@@ -306,6 +306,7 @@ export interface GrafanaConfig {
|
||||
sharedWithMeFolderUID: string;
|
||||
rootFolderUID: string;
|
||||
localFileSystemAvailable: boolean;
|
||||
cloudMigrationEnabled: boolean;
|
||||
cloudMigrationIsTarget: boolean;
|
||||
cloudMigrationPollIntervalMs: number;
|
||||
pluginCatalogURL: string;
|
||||
|
||||
@@ -410,11 +410,6 @@ export interface FeatureToggles {
|
||||
*/
|
||||
jitterAlertRulesWithinGroups?: boolean;
|
||||
/**
|
||||
* Enable the Grafana Migration Assistant, which helps you easily migrate various on-prem resources to your Grafana Cloud stack.
|
||||
* @default true
|
||||
*/
|
||||
onPremToCloudMigrations?: boolean;
|
||||
/**
|
||||
* Enable the secrets management API and services under app platform
|
||||
*/
|
||||
secretsManagementAppPlatform?: boolean;
|
||||
|
||||
@@ -241,6 +241,7 @@ export class GrafanaBootConfig {
|
||||
sharedWithMeFolderUID?: string;
|
||||
rootFolderUID?: string;
|
||||
localFileSystemAvailable?: boolean;
|
||||
cloudMigrationEnabled?: boolean;
|
||||
cloudMigrationIsTarget?: boolean;
|
||||
cloudMigrationPollIntervalMs = 2000;
|
||||
reportingStaticContext?: Record<string, string>;
|
||||
|
||||
+1
-2
@@ -121,8 +121,7 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
r.Get("/admin/provisioning", reqOrgAdmin, hs.Index)
|
||||
r.Get("/admin/provisioning/*", reqOrgAdmin, hs.Index)
|
||||
|
||||
//nolint:staticcheck // not yet migrated to OpenFeature
|
||||
if hs.Features.IsEnabledGlobally(featuremgmt.FlagOnPremToCloudMigrations) {
|
||||
if hs.Cfg.CloudMigration.Enabled {
|
||||
r.Get("/admin/migrate-to-cloud", authorize(cloudmigration.MigrationAssistantAccess), hs.Index)
|
||||
}
|
||||
|
||||
|
||||
@@ -287,6 +287,7 @@ type FrontendSettingsDTO struct {
|
||||
PublicDashboardAccessToken string `json:"publicDashboardAccessToken"`
|
||||
PublicDashboardsEnabled bool `json:"publicDashboardsEnabled"`
|
||||
|
||||
CloudMigrationEnabled bool `json:"cloudMigrationEnabled"`
|
||||
CloudMigrationIsTarget bool `json:"cloudMigrationIsTarget"`
|
||||
CloudMigrationPollIntervalMs int `json:"cloudMigrationPollIntervalMs"`
|
||||
|
||||
|
||||
@@ -191,8 +191,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
|
||||
hasAccess := accesscontrol.HasAccess(hs.AccessControl, c)
|
||||
trustedTypesDefaultPolicyEnabled := (hs.Cfg.CSPEnabled && strings.Contains(hs.Cfg.CSPTemplate, "require-trusted-types-for")) || (hs.Cfg.CSPReportOnlyEnabled && strings.Contains(hs.Cfg.CSPReportOnlyTemplate, "require-trusted-types-for"))
|
||||
//nolint:staticcheck // not yet migrated to OpenFeature
|
||||
isCloudMigrationTarget := hs.Features.IsEnabled(c.Req.Context(), featuremgmt.FlagOnPremToCloudMigrations) && hs.Cfg.CloudMigration.IsTarget
|
||||
isCloudMigrationTarget := hs.Cfg.CloudMigration.Enabled && hs.Cfg.CloudMigration.IsTarget
|
||||
featureToggles := hs.Features.GetEnabled(c.Req.Context())
|
||||
// this is needed for backwards compatibility with external plugins
|
||||
// we should remove this once we can be sure that no external plugins rely on this
|
||||
@@ -260,6 +259,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
PluginRestrictedAPIsBlockList: hs.Cfg.PluginRestrictedAPIsBlockList,
|
||||
PublicDashboardAccessToken: c.PublicDashboardAccessToken,
|
||||
PublicDashboardsEnabled: hs.Cfg.PublicDashboardsEnabled,
|
||||
CloudMigrationEnabled: hs.Cfg.CloudMigration.Enabled,
|
||||
CloudMigrationIsTarget: isCloudMigrationTarget,
|
||||
CloudMigrationPollIntervalMs: int(hs.Cfg.CloudMigration.FrontendPollInterval.Milliseconds()),
|
||||
SharedWithMeFolderUID: folder.SharedWithMeFolderUID,
|
||||
|
||||
@@ -61,7 +61,6 @@ type Service struct {
|
||||
|
||||
isSyncSnapshotStatusFromGMSRunning int32
|
||||
|
||||
features featuremgmt.FeatureToggles
|
||||
gmsClient gmsclient.Client
|
||||
objectStorage objectstorage.ObjectStorage
|
||||
|
||||
@@ -119,8 +118,7 @@ func ProvideService(
|
||||
libraryElementsService libraryelements.Service,
|
||||
ngAlert *ngalert.AlertNG,
|
||||
) (cloudmigration.Service, error) {
|
||||
//nolint:staticcheck // not yet migrated to OpenFeature
|
||||
if !features.IsEnabledGlobally(featuremgmt.FlagOnPremToCloudMigrations) {
|
||||
if !cfg.CloudMigration.Enabled {
|
||||
return &NoopServiceImpl{}, nil
|
||||
}
|
||||
|
||||
@@ -132,7 +130,6 @@ func ProvideService(
|
||||
store: &sqlStore{db: db, secretsStore: secretsStore, secretsService: secretsService},
|
||||
log: log.New(LogPrefix),
|
||||
cfg: cfg,
|
||||
features: features,
|
||||
dsService: dsService,
|
||||
tracer: tracer,
|
||||
metrics: newMetrics(),
|
||||
|
||||
@@ -907,6 +907,7 @@ func setUpServiceTest(t *testing.T, cfgOverrides ...configOverrides) cloudmigrat
|
||||
_, err = section.NewKey("domain", "localhost:1234")
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg.CloudMigration.Enabled = true
|
||||
cfg.CloudMigration.IsDeveloperMode = true // ensure local implementations are used
|
||||
cfg.CloudMigration.SnapshotFolder = filepath.Join(os.TempDir(), uuid.NewString())
|
||||
|
||||
@@ -919,15 +920,11 @@ func setUpServiceTest(t *testing.T, cfgOverrides ...configOverrides) cloudmigrat
|
||||
},
|
||||
}
|
||||
|
||||
featureToggles := featuremgmt.WithFeatures(
|
||||
featuremgmt.FlagOnPremToCloudMigrations,
|
||||
)
|
||||
featureToggles := featuremgmt.WithFeatures()
|
||||
|
||||
sqlStore := sqlstore.NewTestStore(t,
|
||||
sqlstore.WithCfg(cfg),
|
||||
sqlstore.WithFeatureFlags(
|
||||
featuremgmt.FlagOnPremToCloudMigrations,
|
||||
),
|
||||
sqlstore.WithFeatureFlags(),
|
||||
)
|
||||
|
||||
kvStore := kvstore.ProvideService(sqlStore)
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
@@ -43,7 +42,6 @@ func TestGetAlertMuteTimings(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
s := setUpServiceTest(t).(*Service)
|
||||
s.features = featuremgmt.WithFeatures(featuremgmt.FlagOnPremToCloudMigrations)
|
||||
|
||||
user := &user.SignedInUser{OrgID: 1}
|
||||
|
||||
|
||||
@@ -667,13 +667,6 @@ var (
|
||||
HideFromDocs: true,
|
||||
RequiresRestart: true,
|
||||
},
|
||||
{
|
||||
Name: "onPremToCloudMigrations",
|
||||
Description: "Enable the Grafana Migration Assistant, which helps you easily migrate various on-prem resources to your Grafana Cloud stack.",
|
||||
Stage: FeatureStageGeneralAvailability,
|
||||
Owner: grafanaOperatorExperienceSquad,
|
||||
Expression: "true",
|
||||
},
|
||||
{
|
||||
Name: "secretsManagementAppPlatform",
|
||||
Description: "Enable the secrets management API and services under app platform",
|
||||
|
||||
Generated
-1
@@ -92,7 +92,6 @@ kubernetesFeatureToggles,experimental,@grafana/grafana-operator-experience-squad
|
||||
cloudRBACRoles,preview,@grafana/identity-access-team,false,true,false
|
||||
alertingQueryOptimization,GA,@grafana/alerting-squad,false,false,false
|
||||
jitterAlertRulesWithinGroups,preview,@grafana/alerting-squad,false,true,false
|
||||
onPremToCloudMigrations,GA,@grafana/grafana-operator-experience-squad,false,false,false
|
||||
secretsManagementAppPlatform,experimental,@grafana/grafana-operator-experience-squad,false,false,false
|
||||
secretsManagementAppPlatformUI,experimental,@grafana/grafana-operator-experience-squad,false,false,false
|
||||
alertingSaveStatePeriodic,privatePreview,@grafana/alerting-squad,false,false,false
|
||||
|
||||
|
Generated
-4
@@ -275,10 +275,6 @@ const (
|
||||
// Distributes alert rule evaluations more evenly over time, including spreading out rules within the same group. Disables sequential evaluation if enabled.
|
||||
FlagJitterAlertRulesWithinGroups = "jitterAlertRulesWithinGroups"
|
||||
|
||||
// FlagOnPremToCloudMigrations
|
||||
// Enable the Grafana Migration Assistant, which helps you easily migrate various on-prem resources to your Grafana Cloud stack.
|
||||
FlagOnPremToCloudMigrations = "onPremToCloudMigrations"
|
||||
|
||||
// FlagSecretsManagementAppPlatform
|
||||
// Enable the secrets management API and services under app platform
|
||||
FlagSecretsManagementAppPlatform = "secretsManagementAppPlatform"
|
||||
|
||||
+2
-1
@@ -2412,7 +2412,8 @@
|
||||
"metadata": {
|
||||
"name": "onPremToCloudMigrations",
|
||||
"resourceVersion": "1763734583253",
|
||||
"creationTimestamp": "2024-01-22T16:09:08Z"
|
||||
"creationTimestamp": "2024-01-22T16:09:08Z",
|
||||
"deletionTimestamp": "2025-11-20T09:59:41Z"
|
||||
},
|
||||
"spec": {
|
||||
"description": "Enable the Grafana Migration Assistant, which helps you easily migrate various on-prem resources to your Grafana Cloud stack.",
|
||||
|
||||
@@ -44,8 +44,7 @@ func (s *ServiceImpl) getAdminNode(c *contextmodel.ReqContext) (*navtree.NavLink
|
||||
Text: "Organizations", SubTitle: "Isolated instances of Grafana running on the same server", Id: "global-orgs", Url: s.cfg.AppSubURL + "/admin/orgs", Icon: "building",
|
||||
})
|
||||
}
|
||||
//nolint:staticcheck // not yet migrated to OpenFeature
|
||||
if hasAccess(cloudmigration.MigrationAssistantAccess) && s.features.IsEnabled(ctx, featuremgmt.FlagOnPremToCloudMigrations) {
|
||||
if hasAccess(cloudmigration.MigrationAssistantAccess) && s.cfg.CloudMigration.Enabled {
|
||||
generalNodeLinks = append(generalNodeLinks, &navtree.NavLink{
|
||||
Text: "Migrate to Grafana Cloud",
|
||||
Id: "migrate-to-cloud",
|
||||
|
||||
@@ -35,12 +35,14 @@ type CloudMigrationSettings struct {
|
||||
TokenExpiresAfter time.Duration
|
||||
FrontendPollInterval time.Duration
|
||||
|
||||
Enabled bool
|
||||
IsTarget bool
|
||||
IsDeveloperMode bool
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readCloudMigrationSettings() {
|
||||
cloudMigration := cfg.Raw.Section("cloud_migration")
|
||||
cfg.CloudMigration.Enabled = cloudMigration.Key("enabled").MustBool(true)
|
||||
cfg.CloudMigration.IsTarget = cloudMigration.Key("is_target").MustBool(false)
|
||||
cfg.CloudMigration.GcomAPIToken = cloudMigration.Key("gcom_api_token").MustString("")
|
||||
cfg.CloudMigration.AuthAPIUrl = cloudMigration.Key("auth_api_url").MustString("")
|
||||
|
||||
@@ -376,7 +376,7 @@ export function getAppRoutes(): RouteDescriptor[] {
|
||||
() => import(/* webpackChunkName: "ServerStats" */ 'app/features/admin/ServerStats')
|
||||
),
|
||||
},
|
||||
config.featureToggles.onPremToCloudMigrations && {
|
||||
config.cloudMigrationEnabled && {
|
||||
path: '/admin/migrate-to-cloud',
|
||||
roles: () => contextSrv.evaluatePermission([AccessControlAction.MigrationAssistantMigrate]),
|
||||
component: SafeDynamicImport(
|
||||
|
||||
Reference in New Issue
Block a user