add a toggle for this option

This commit is contained in:
Sergey Dudoladov
2020-03-25 09:11:51 +01:00
parent d0b462a6cd
commit 33ec2202e6
5 changed files with 9 additions and 3 deletions
+1 -2
View File
@@ -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-- {
+2 -1
View File
@@ -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
+1
View File
@@ -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