Skip to content

Commit d2a7676

Browse files
andrewlecuyerJonathan S. Katz
authored andcommitted
Do not Delete All Cluster pgtasks After Successful rmdata Job
The PostgreSQL Operator Job controller currently deletes any/all pgtasks for a cluster after the successful completion of any rmdata job. Therefore, while the rmdata application itself has logic for removing pgtasks, such as removing all cluster pgtasks when the entire PostgreSQL cluster is deleted, other resources (pgtasks) are deleted regardless of the specific rmdata job executed. This can lead to confusion and unintended side effects, since a successful rmdata Job can result in the deletion of resources, specifically pgtasks, that were not in the scope of the rmdata Job itself for deletion. For instance, the rmdata job executed as a result of removing a replica after scaling down the cluster results in the deletion of all pgtasks, for that cluster, even though the rmdata job submitted for the replica is specifically configured not to remove pgtasks. This change therefore ensures that the Job controller itself no longer arbitrarily deletes cluster resources, namely the pgtasks associated with the cluster. Instead the deletion of cluster resources is left to the rmdata Jobs, which alone are responsible for ensuring the proper cluster resource are deleted depending on the type of rmdata Job submitted.
1 parent 47076dc commit d2a7676

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

controller/jobcontroller.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,7 @@ func handleRmdata(job *apiv1.Job, restClient *rest.RESTClient, clientset *kubern
562562
labels := job.GetObjectMeta().GetLabels()
563563
clusterName := labels[config.LABEL_PG_CLUSTER]
564564

565-
//delete any pgtask for this cluster
566-
log.Debugf("deleting pgtask for rmdata job name is %s", job.ObjectMeta.Name)
567-
err = kubeapi.Deletepgtasks(restClient, config.LABEL_PG_CLUSTER+"="+clusterName, namespace)
568-
if err != nil {
569-
return err
570-
}
571-
572-
err = kubeapi.DeleteJob(clientset, job.Name, namespace)
573-
if err != nil {
565+
if err = kubeapi.DeleteJob(clientset, job.Name, namespace); err != nil {
574566
log.Error(err)
575567
}
576568

0 commit comments

Comments
 (0)