block automatic major version upgrade with annotation for single cluster

This commit is contained in:
Felix Kunde 2024-07-03 17:27:00 +02:00
parent 37d6993439
commit af2d0f7d92
11 changed files with 30 additions and 0 deletions

View File

@ -158,6 +158,8 @@ spec:
major_version_upgrade:
type: object
properties:
ignore_auto_version_upgrade_key:
type: string
major_version_upgrade_mode:
type: string
default: "off"

View File

@ -82,6 +82,9 @@ configUsers:
super_username: postgres
configMajorVersionUpgrade:
# key name for annotation to ignore globally enabled major version upgrades
# ignore_auto_version_upgrade_key: ""
# "off": no upgrade, "manual": manifest triggers action, "full": minimal version violation triggers too
major_version_upgrade_mode: "off"
# upgrades will only be carried out for clusters of listed teams when mode is "off"

View File

@ -257,6 +257,14 @@ CRD-configuration, they are grouped under the `major_version_upgrade` key.
which violate the configured allowed `minimal_major_version` when
`major_version_upgrade_mode` is set to `"full"`. The default is `"16"`.
* **ignore_auto_version_upgrade_key**
Even if automatic major version upgrades are generally desired for most
clusters there might be exceptions where you want to be under full control
of the starting time to execute the upgrade script in Spilo manually.
With this option you can define an annotation key that can be used as a
toggle in cluster manifests to ignore globally enabled (or allowed per team)
automatic major version upgrade. The default is empty.
## Kubernetes resources
Parameters to configure cluster-related Kubernetes objects created by the

View File

@ -72,6 +72,7 @@ data:
# ignored_annotations: ""
# infrastructure_roles_secret_name: "postgresql-infrastructure-roles"
# infrastructure_roles_secrets: "secretname:monitoring-roles,userkey:user,passwordkey:password,rolekey:inrole"
# ignore_auto_version_upgrade_key: ""
# ignore_instance_limits_annotation_key: ""
# inherited_annotations: owned-by
# inherited_labels: application,environment

View File

@ -156,6 +156,8 @@ spec:
major_version_upgrade:
type: object
properties:
ignore_auto_version_upgrade_key:
type: string
major_version_upgrade_mode:
type: string
default: "off"

View File

@ -36,6 +36,7 @@ configuration:
replication_username: standby
super_username: postgres
major_version_upgrade:
# ignore_auto_version_upgrade_key: ""
major_version_upgrade_mode: "off"
# major_version_upgrade_team_allow_list:
# - acid

View File

@ -1254,6 +1254,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
"major_version_upgrade": {
Type: "object",
Properties: map[string]apiextv1.JSONSchemaProps{
"ignore_auto_version_upgrade_key": {
Type: "string",
},
"major_version_upgrade_mode": {
Type: "string",
},

View File

@ -47,6 +47,7 @@ type PostgresUsersConfiguration struct {
// MajorVersionUpgradeConfiguration defines how to execute major version upgrades of Postgres.
type MajorVersionUpgradeConfiguration struct {
IgnoreAutoVersionUpgradeKey string `json:"ignore_auto_version_upgrade_key,omitempty"`
MajorVersionUpgradeMode string `json:"major_version_upgrade_mode" default:"off"` // off - no actions, manual - manifest triggers action, full - manifest and minimal version violation trigger upgrade
MajorVersionUpgradeTeamAllowList []string `json:"major_version_upgrade_team_allow_list,omitempty"`
MinimalMajorVersion string `json:"minimal_major_version" default:"12"`

View File

@ -67,6 +67,13 @@ func (c *Cluster) majorVersionUpgrade() error {
return nil
}
ignoreAutoVersionUpgradeKey := c.OpConfig.IgnoreAutoVersionUpgradeKey
if ignoreAutoVersionUpgradeKey != "" {
if value, exists := c.ObjectMeta.Annotations[ignoreAutoVersionUpgradeKey]; exists && value == "true" {
return nil
}
}
desiredVersion := c.GetDesiredMajorVersionAsInt()
if c.currentMajorVersion >= desiredVersion {

View File

@ -60,6 +60,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
result.PasswordRotationUserRetention = util.CoalesceUInt32(fromCRD.PostgresUsersConfiguration.DeepCopy().PasswordRotationUserRetention, 180)
// major version upgrade config
result.IgnoreAutoVersionUpgradeKey = fromCRD.MajorVersionUpgrade.IgnoreAutoVersionUpgradeKey
result.MajorVersionUpgradeMode = util.Coalesce(fromCRD.MajorVersionUpgrade.MajorVersionUpgradeMode, "off")
result.MajorVersionUpgradeTeamAllowList = fromCRD.MajorVersionUpgrade.MajorVersionUpgradeTeamAllowList
result.MinimalMajorVersion = util.Coalesce(fromCRD.MajorVersionUpgrade.MinimalMajorVersion, "12")

View File

@ -243,6 +243,7 @@ type Config struct {
EnablePgVersionEnvVar bool `name:"enable_pgversion_env_var" default:"true"`
EnableSpiloWalPathCompat bool `name:"enable_spilo_wal_path_compat" default:"false"`
EnableTeamIdClusternamePrefix bool `name:"enable_team_id_clustername_prefix" default:"false"`
IgnoreAutoVersionUpgradeKey string `name:"ignore_auto_version_upgrade_key"`
MajorVersionUpgradeMode string `name:"major_version_upgrade_mode" default:"off"`
MajorVersionUpgradeTeamAllowList []string `name:"major_version_upgrade_team_allow_list" default:""`
MinimalMajorVersion string `name:"minimal_major_version" default:"12"`