mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-09-30 14:01:46 +02:00
add option to prevent PVC removal on cluster deletion (#2579)
* add option to prevent PVC removal on cluster deletion * Update docs/reference/operator_parameters.md Co-authored-by: Motte <37443982+dmotte@users.noreply.github.com>
This commit is contained in:
@@ -1320,6 +1320,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||
"enable_init_containers": {
|
||||
Type: "boolean",
|
||||
},
|
||||
"enable_persistent_volume_claim_deletion": {
|
||||
Type: "boolean",
|
||||
},
|
||||
"enable_pod_antiaffinity": {
|
||||
Type: "boolean",
|
||||
},
|
||||
|
||||
@@ -102,6 +102,7 @@ type KubernetesMetaConfiguration struct {
|
||||
PodAntiAffinityTopologyKey string `json:"pod_antiaffinity_topology_key,omitempty"`
|
||||
PodManagementPolicy string `json:"pod_management_policy,omitempty"`
|
||||
PersistentVolumeClaimRetentionPolicy map[string]string `json:"persistent_volume_claim_retention_policy,omitempty"`
|
||||
EnablePersistentVolumeClaimDeletion *bool `json:"enable_persistent_volume_claim_deletion,omitempty"`
|
||||
EnableReadinessProbe bool `json:"enable_readiness_probe,omitempty"`
|
||||
EnableCrossNamespaceSecret bool `json:"enable_cross_namespace_secret,omitempty"`
|
||||
EnableFinalizers *bool `json:"enable_finalizers,omitempty"`
|
||||
|
||||
@@ -272,6 +272,11 @@ func (in *KubernetesMetaConfiguration) DeepCopyInto(out *KubernetesMetaConfigura
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.EnablePersistentVolumeClaimDeletion != nil {
|
||||
in, out := &in.EnablePersistentVolumeClaimDeletion, &out.EnablePersistentVolumeClaimDeletion
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.EnableFinalizers != nil {
|
||||
in, out := &in.EnableFinalizers, &out.EnableFinalizers
|
||||
*out = new(bool)
|
||||
|
||||
@@ -261,8 +261,12 @@ func (c *Cluster) deleteStatefulSet() error {
|
||||
return fmt.Errorf("could not delete pods: %v", err)
|
||||
}
|
||||
|
||||
if err := c.deletePersistentVolumeClaims(); err != nil {
|
||||
return fmt.Errorf("could not delete PersistentVolumeClaims: %v", err)
|
||||
if c.OpConfig.EnablePersistentVolumeClaimDeletion != nil && *c.OpConfig.EnablePersistentVolumeClaimDeletion {
|
||||
if err := c.deletePersistentVolumeClaims(); err != nil {
|
||||
return fmt.Errorf("could not delete PersistentVolumeClaims: %v", err)
|
||||
}
|
||||
} else {
|
||||
c.logger.Info("not deleting PersistentVolumeClaims because disabled in configuration")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -122,6 +122,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||
result.PodPriorityClassName = fromCRD.Kubernetes.PodPriorityClassName
|
||||
result.PodManagementPolicy = util.Coalesce(fromCRD.Kubernetes.PodManagementPolicy, "ordered_ready")
|
||||
result.PersistentVolumeClaimRetentionPolicy = fromCRD.Kubernetes.PersistentVolumeClaimRetentionPolicy
|
||||
result.EnablePersistentVolumeClaimDeletion = util.CoalesceBool(fromCRD.Kubernetes.EnablePersistentVolumeClaimDeletion, util.True())
|
||||
result.EnableReadinessProbe = fromCRD.Kubernetes.EnableReadinessProbe
|
||||
result.MasterPodMoveTimeout = util.CoalesceDuration(time.Duration(fromCRD.Kubernetes.MasterPodMoveTimeout), "10m")
|
||||
result.EnablePodAntiAffinity = fromCRD.Kubernetes.EnablePodAntiAffinity
|
||||
|
||||
@@ -249,6 +249,7 @@ type Config struct {
|
||||
PatroniAPICheckInterval time.Duration `name:"patroni_api_check_interval" default:"1s"`
|
||||
PatroniAPICheckTimeout time.Duration `name:"patroni_api_check_timeout" default:"5s"`
|
||||
EnablePatroniFailsafeMode *bool `name:"enable_patroni_failsafe_mode" default:"false"`
|
||||
EnablePersistentVolumeClaimDeletion *bool `name:"enable_persistent_volume_claim_deletion" default:"true"`
|
||||
PersistentVolumeClaimRetentionPolicy map[string]string `name:"persistent_volume_claim_retention_policy" default:"when_deleted:retain,when_scaled:retain"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user