add a toggle for this option
This commit is contained in:
parent
d0b462a6cd
commit
33ec2202e6
|
|
@ -131,6 +131,10 @@ Those are top-level keys, containing both leaf keys and groups.
|
|||
container, change the [operator deployment manually](../../manifests/postgres-operator.yaml#L20).
|
||||
The default is `false`.
|
||||
|
||||
* **should_delete_unused_pvc**
|
||||
Tells the operator to delete persistent volume claims of no longer running pods. That removes respective persistent volumes because operator configures them with the 'Delete' reclaim policy. Note operator deletes unused PVCs for clusters created both before and after this option is turned on. Deletion is not guaranteed: When it fails, operator retries at next Sync() event.
|
||||
The default is `false`.
|
||||
|
||||
## Postgres users
|
||||
|
||||
Parameters describing Postgres users. In a CRD-configuration, they are grouped
|
||||
|
|
|
|||
|
|
@ -88,5 +88,6 @@ data:
|
|||
# teams_api_url: http://fake-teams-api.default.svc.cluster.local
|
||||
# toleration: ""
|
||||
# wal_s3_bucket: ""
|
||||
# should_delete_unused_pvc: "false"
|
||||
watched_namespace: "*" # listen to all namespaces
|
||||
workers: "4"
|
||||
|
|
|
|||
|
|
@ -634,8 +634,7 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
|||
}
|
||||
}()
|
||||
|
||||
// delete persistent volume claim after scale down
|
||||
if oldSpec.Spec.NumberOfInstances > newSpec.Spec.NumberOfInstances {
|
||||
if c.OpConfig.ShouldDeleteUnusedPVC && oldSpec.Spec.NumberOfInstances > newSpec.Spec.NumberOfInstances {
|
||||
c.logger.Debug("deleting pvc of shut down pods")
|
||||
|
||||
for i := oldSpec.Spec.NumberOfInstances - 1; i >= newSpec.Spec.NumberOfInstances; i-- {
|
||||
|
|
|
|||
|
|
@ -111,8 +111,9 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
|||
|
||||
// remove unused PVCs in case deleting them during scale down failed; see Update()
|
||||
// the last pvc stays until the cluster is explicitly deleted as opposed to being scaled down to 0 pods
|
||||
if c.getNumberOfInstances(&c.Spec) > 0 {
|
||||
if c.OpConfig.ShouldDeleteUnusedPVC && c.getNumberOfInstances(&c.Spec) > 0 {
|
||||
|
||||
// XXX that also deletes PVC of pods shut down before this change is deployed
|
||||
for i := c.getNumberOfInstances(&c.Spec); ; i++ {
|
||||
podIndex := strconv.Itoa(int(i))
|
||||
pvcName := "pgdata-" + c.Name + "-" + podIndex
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ type Config struct {
|
|||
ProtectedRoles []string `name:"protected_role_names" default:"admin"`
|
||||
PostgresSuperuserTeams []string `name:"postgres_superuser_teams" default:""`
|
||||
SetMemoryRequestToLimit bool `name:"set_memory_request_to_limit" default:"false"`
|
||||
ShouldDeleteUnusedPVC bool `name:"should_delete_unused_pvc" default:"false"`
|
||||
}
|
||||
|
||||
// MustMarshal marshals the config or panics
|
||||
|
|
|
|||
Loading…
Reference in New Issue