Skip to content

Commit a0bc139

Browse files
andrewlecuyerjkatz
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: CrunchyData#2106
1 parent 08e8e56 commit a0bc139

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
@@ -170,6 +170,14 @@ func (c *Controller) handleBackrestStanzaCreateUpdate(job *apiv1.Job) error {
170170
_, _ = backrest.CreateInitialBackup(c.Client, job.ObjectMeta.Namespace,
171171
clusterName, backrestRepoPodName)
172172

173+
// now that the initial backup has been initiated, proceed with deleting the stanza-create
174+
// pgtask and associated Job. This will ensure any subsequent updates to the stanza-create
175+
// Job do not trigger more initial backup Jobs.
176+
if err := backrest.CleanStanzaCreateResources(namespace, clusterName, c.Client); err != nil {
177+
log.Error(err)
178+
return err
179+
}
180+
173181
}
174182
return nil
175183
}

0 commit comments

Comments
 (0)