From 9486707d7401e18834e4e640e17ba31afb8c88a0 Mon Sep 17 00:00:00 2001 From: Artem Gavrilov Date: Mon, 13 Mar 2023 12:23:00 +0200 Subject: [PATCH] PMM-11640 Enable backup management feature by default (#1855) * PMM-11640 Enable backup management by default * PMM-11640 Cleanup env variables * PMM-11640 Fix telemetry config --- docker-compose.yml | 2 -- managed/models/settings.go | 2 +- managed/models/settings_helpers.go | 4 ++-- managed/services/management/backup/artifacts_service.go | 2 +- managed/services/management/backup/locations_service.go | 2 +- managed/services/management/backup/restore_history_service.go | 2 +- managed/services/server/server.go | 2 +- managed/services/telemetry/config.default.yml | 2 +- managed/utils/envvars/parser.go | 4 ++-- 9 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 14b9e50efc..887adbce90 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,6 @@ services: - ENABLE_DBAAS=${ENABLE_DBAAS:-0} - AWS_ACCESS_KEY=${AWS_ACCESS_KEY} - AWS_SECRET_KEY=${AWS_SECRET_KEY} - - ENABLE_BACKUP_MANAGEMENT=1 - ENABLE_RBAC=${ENABLE_RBAC:-0} - LESS_LOG_NOISE=1 - PERCONA_TEST_VERSION_SERVICE_URL=${PERCONA_TEST_VERSION_SERVICE_URL} @@ -104,7 +103,6 @@ services: - ENABLE_DBAAS=${ENABLE_DBAAS:-0} - AWS_ACCESS_KEY=${AWS_ACCESS_KEY} - AWS_SECRET_KEY=${AWS_SECRET_KEY} - - ENABLE_BACKUP_MANAGEMENT=1 # - PERCONA_TEST_PLATFORM_ADDRESS=https://check.localhost # - PERCONA_TEST_PLATFORM_INSECURE=1 # - PERCONA_TEST_PLATFORM_PUBLIC_KEY= diff --git a/managed/models/settings.go b/managed/models/settings.go index 2f21af8522..590920bde1 100644 --- a/managed/models/settings.go +++ b/managed/models/settings.go @@ -91,7 +91,7 @@ type Settings struct { } `json:"azure"` BackupManagement struct { - Enabled bool `json:"enabled"` + Disabled bool `json:"disabled"` } `json:"backup_management"` // PMMServerID is generated on the first start of PMM server. diff --git a/managed/models/settings_helpers.go b/managed/models/settings_helpers.go index 01b6d64765..0f55e4fc13 100644 --- a/managed/models/settings_helpers.go +++ b/managed/models/settings_helpers.go @@ -302,11 +302,11 @@ func UpdateSettings(q reform.DBTX, params *ChangeSettingsParams) (*Settings, err } if params.DisableBackupManagement { - settings.BackupManagement.Enabled = false + settings.BackupManagement.Disabled = true } if params.EnableBackupManagement { - settings.BackupManagement.Enabled = true + settings.BackupManagement.Disabled = false } if params.DefaultRoleID != 0 { diff --git a/managed/services/management/backup/artifacts_service.go b/managed/services/management/backup/artifacts_service.go index af3112e82a..d16ee37a0b 100644 --- a/managed/services/management/backup/artifacts_service.go +++ b/managed/services/management/backup/artifacts_service.go @@ -58,7 +58,7 @@ func (s *ArtifactsService) Enabled() bool { s.l.WithError(err).Error("can't get settings") return false } - return settings.BackupManagement.Enabled + return !settings.BackupManagement.Disabled } // ListArtifacts returns a list of all artifacts. diff --git a/managed/services/management/backup/locations_service.go b/managed/services/management/backup/locations_service.go index fbe8e7ad77..b8c2aede00 100644 --- a/managed/services/management/backup/locations_service.go +++ b/managed/services/management/backup/locations_service.go @@ -54,7 +54,7 @@ func (s *LocationsService) Enabled() bool { s.l.WithError(err).Error("can't get settings") return false } - return settings.BackupManagement.Enabled + return !settings.BackupManagement.Disabled } // ListLocations returns list of all available backup locations. diff --git a/managed/services/management/backup/restore_history_service.go b/managed/services/management/backup/restore_history_service.go index 22bbde72ec..e54ee8c95a 100644 --- a/managed/services/management/backup/restore_history_service.go +++ b/managed/services/management/backup/restore_history_service.go @@ -51,7 +51,7 @@ func (s *RestoreHistoryService) Enabled() bool { s.l.WithError(err).Error("can't get settings") return false } - return settings.BackupManagement.Enabled + return !settings.BackupManagement.Disabled } // ListRestoreHistory returns a list of restore history. diff --git a/managed/services/server/server.go b/managed/services/server/server.go index 255c5ab55b..36db793abf 100644 --- a/managed/services/server/server.go +++ b/managed/services/server/server.go @@ -450,7 +450,7 @@ func (s *Server) convertSettings(settings *models.Settings, connectedToPlatform PmmPublicAddress: settings.PMMPublicAddress, AlertingEnabled: !settings.Alerting.Disabled, - BackupManagementEnabled: settings.BackupManagement.Enabled, + BackupManagementEnabled: !settings.BackupManagement.Disabled, ConnectedToPlatform: connectedToPlatform, TelemetrySummaries: s.telemetryService.GetSummaries(), diff --git a/managed/services/telemetry/config.default.yml b/managed/services/telemetry/config.default.yml index e001df4378..f9657ea5f6 100644 --- a/managed/services/telemetry/config.default.yml +++ b/managed/services/telemetry/config.default.yml @@ -34,7 +34,7 @@ telemetry: - id: PMMServerBackupManagementEnabled source: PMMDB_SELECT - query: (CASE WHEN backup_management->'enabled' = 'true' THEN '1' ELSE '0' END) AS backup_management_enabled FROM settings s, jsonb_extract_path(s.settings, 'backup_management') AS backup_management + query: (CASE WHEN backup_management->'disabled' = 'false' THEN '1' ELSE '0' END) AS backup_management_enabled FROM settings s, jsonb_extract_path(s.settings, 'backup_management') AS backup_management summary: "PMM Server Backup Management feature enabled" data: - metric_name: "pmm_server_backup_management_enabled" diff --git a/managed/utils/envvars/parser.go b/managed/utils/envvars/parser.go index ea4112798a..77b712d8a9 100644 --- a/managed/utils/envvars/parser.go +++ b/managed/utils/envvars/parser.go @@ -140,8 +140,8 @@ func ParseEnvVars(envs []string) (envSettings *models.ChangeSettingsParams, errs if err != nil { err = fmt.Errorf("invalid value %q for environment variable %q", v, k) } - case "ENABLE_BACKUP_MANAGEMENT": - envSettings.EnableBackupManagement, err = strconv.ParseBool(v) + case "DISABLE_BACKUP_MANAGEMENT": + envSettings.DisableBackupManagement, err = strconv.ParseBool(v) if err != nil { err = fmt.Errorf("invalid value %q for environment variable %q", v, k) }