Skip to content

Commit c1bfc2c

Browse files
authored
do not block delete because of emtpy child resources (#2538)
1 parent 3d9d025 commit c1bfc2c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/cluster/resources.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ func (c *Cluster) deleteStatefulSet() error {
243243
c.setProcessName("deleting statefulset")
244244
c.logger.Debugln("deleting statefulset")
245245
if c.Statefulset == nil {
246-
return fmt.Errorf("there is no statefulset in the cluster")
246+
c.logger.Debug("there is no statefulset in the cluster")
247+
return nil
247248
}
248249

249250
err := c.KubeClient.StatefulSets(c.Statefulset.Namespace).Delete(context.TODO(), c.Statefulset.Name, c.deleteOptions)
@@ -447,7 +448,8 @@ func (c *Cluster) updatePodDisruptionBudget(pdb *policyv1.PodDisruptionBudget) e
447448
func (c *Cluster) deletePodDisruptionBudget() error {
448449
c.logger.Debug("deleting pod disruption budget")
449450
if c.PodDisruptionBudget == nil {
450-
return fmt.Errorf("there is no pod disruption budget in the cluster")
451+
c.logger.Debug("there is no pod disruption budget in the cluster")
452+
return nil
451453
}
452454

453455
pdbName := util.NameFromMeta(c.PodDisruptionBudget.ObjectMeta)
@@ -485,7 +487,8 @@ func (c *Cluster) deleteEndpoint(role PostgresRole) error {
485487
c.setProcessName("deleting endpoint")
486488
c.logger.Debugln("deleting endpoint")
487489
if c.Endpoints[role] == nil {
488-
return fmt.Errorf("there is no %s endpoint in the cluster", role)
490+
c.logger.Debugf("there is no %s endpoint in the cluster", role)
491+
return nil
489492
}
490493

491494
if err := c.KubeClient.Endpoints(c.Endpoints[role].Namespace).Delete(context.TODO(), c.Endpoints[role].Name, c.deleteOptions); err != nil {

0 commit comments

Comments
 (0)