Skip to content

Commit

Permalink
PMM-11640 Enable backup management feature by default (#1855)
Browse files Browse the repository at this point in the history
* PMM-11640 Enable backup management by default

* PMM-11640 Cleanup env variables

* PMM-11640 Fix telemetry config
  • Loading branch information
artemgavrilov authored Mar 13, 2023
1 parent 0628b3e commit 9486707
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 12 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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=<public key>
Expand Down
2 changes: 1 addition & 1 deletion managed/models/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions managed/models/settings_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/backup/artifacts_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/backup/locations_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion managed/services/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion managed/services/telemetry/config.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions managed/utils/envvars/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 9486707

Please sign in to comment.