Skip to content

Commit 3accf8a

Browse files
committed
Fixed configmap prefix in the cleanup function, few typos and logs
1 parent 4a45bc1 commit 3accf8a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

pkg/controller/postgresql.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func (c *Controller) postgresqlUpdate(prev, cur interface{}) {
554554

555555
if pgNew.Annotations[restoreAnnotationKey] == restoreAnnotationValue {
556556
c.logger.Debugf("restore-in-place: postgresqlUpdate called for cluster %q", pgNew.Name)
557-
c.handlerRestoreInPlace(pgOld, pgNew)
557+
c.handleRestoreInPlace(pgOld, pgNew)
558558
return
559559
}
560560

@@ -614,9 +614,9 @@ func (c *Controller) validateRestoreInPlace(pgOld, pgNew *acidv1.Postgresql) err
614614
return nil
615615
}
616616

617-
// handlerRestoreInPlace starts an asynchronous point-in-time-restore.
617+
// handleRestoreInPlace starts an asynchronous point-in-time-restore.
618618
// It creates a ConfigMap to store the state and then deletes the old Postgresql CR.
619-
func (c *Controller) handlerRestoreInPlace(pgOld, pgNew *acidv1.Postgresql) {
619+
func (c *Controller) handleRestoreInPlace(pgOld, pgNew *acidv1.Postgresql) {
620620
c.logger.Infof("restore-in-place: starting asynchronous restore-in-place for cluster %q", pgNew.Name)
621621

622622
if err := c.validateRestoreInPlace(pgOld, pgNew); err != nil {
@@ -675,7 +675,6 @@ func (c *Controller) handlerRestoreInPlace(pgOld, pgNew *acidv1.Postgresql) {
675675
err = c.KubeClient.Postgresqls(pgOld.Namespace).Delete(context.TODO(), pgOld.Name, metav1.DeleteOptions{})
676676
if err != nil && !errors.IsNotFound(err) {
677677
c.logger.Errorf("restore-in-place: could not delete postgresql CR %q: %v", pgOld.Name, err)
678-
// Consider deleting the ConfigMap here to allow a retry
679678
return
680679
}
681680
c.logger.Infof("restore-in-place: initiated deletion of postgresql CR %q", pgOld.Name)
@@ -745,7 +744,7 @@ func (c *Controller) processInProgressCm(namespace string) error {
745744
return fmt.Errorf("restore-in-place: could not list in-progress restore ConfigMaps: %v", err)
746745
}
747746
if len(inProgressCmList.Items) > 0 {
748-
c.logger.Debugf("restore-in-place: found %d in-progress restore(s) to process", len(inProgressCmList.Items))
747+
c.logger.Infof("restore-in-place: found %d in-progress restore(s) to process", len(inProgressCmList.Items))
749748
}
750749

751750
for _, cm := range inProgressCmList.Items {
@@ -770,14 +769,13 @@ func (c *Controller) processSingleInProgressCm(cm v1.ConfigMap) error {
770769
if err != nil {
771770
if errors.IsAlreadyExists(err) {
772771
c.logger.Infof("restore-in-place: Postgresql CR %q already exists, cleaning up restore ConfigMap", newPgSpec.Name)
773-
// fallthrough to delete
772+
return nil
774773
} else {
775774
return fmt.Errorf("could not re-create Postgresql CR %q for restore: %v", newPgSpec.Name, err)
776775
}
777-
} else {
778-
c.logger.Infof("restore-in-place: successfully re-created Postgresql CR %q to complete restore", newPgSpec.Name)
779776
}
780-
777+
// If err is nil (creation successful)
778+
c.logger.Infof("restore-in-place: successfully re-created Postgresql CR %q to complete restore", newPgSpec.Name)
781779
return nil
782780
}
783781

@@ -801,7 +799,7 @@ func (c *Controller) cleanupRestores() error {
801799
c.logger.Debugf("Pitr backup retention is %s", retention.String())
802800

803801
for _, cm := range cmList.Items {
804-
if !strings.HasPrefix(cm.Name, "pitr-") {
802+
if !strings.HasPrefix(cm.Name, "pitr-state-") {
805803
continue
806804
}
807805

0 commit comments

Comments
 (0)