Skip to content

Commit 744b9b5

Browse files
andrewlecuyerJonathan S. Katz
authored andcommitted
Clean Stanza Create pgtask & Job After Init
When a PostgreSQL cluster is initialized for the first time, the stanza create pgtask and the Kubernetes Job associated with it are now automatically deleted. This ensures that subsequent update events in the Job controller for a stanza-create Job do not trigger additional "initial backups" Jobs for the cluster. Issue: [ch10277] Issue: #2106
1 parent 67b44d7 commit 744b9b5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/controller/job/backresthandler.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ func (c *Controller) handleBackrestStanzaCreateUpdate(job *apiv1.Job) error {
229229
backrestoperator.CreateInitialBackup(c.Client, job.ObjectMeta.Namespace,
230230
clusterName, backrestRepoPodName)
231231

232+
// now that the initial backup has been initiated, proceed with deleting the stanza-create
233+
// pgtask and associated Job. This will ensure any subsequent updates to the stanza-create
234+
// Job do not trigger more initial backup Jobs.
235+
if err := backrest.CleanStanzaCreateResources(namespace, clusterName, c.Client); err != nil {
236+
log.Error(err)
237+
return err
238+
}
239+
232240
}
233241
return nil
234242
}

0 commit comments

Comments
 (0)