mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-01 19:04:53 +02:00
Add cluster_labels and annotations to logical backup CronJob and Jobs (#3085)
* Add cluster_labels and annotations to logical backup CronJob and Jobs When using the logical backup feature, the CronJob and its created Jobs were missing the cluster_labels and annotations that are applied to other cluster resources. This made it difficult to filter or identify backup jobs using the same labels as other cluster components. Changes: - Added ObjectMeta with labels and annotations to JobTemplateSpec - Updated CronJob ObjectMeta to use the merged labels (including 'application: spilo-logical-backup') - Updated tests to expect the new labels
This commit is contained in:
@@ -1769,6 +1769,16 @@ func (c *Cluster) syncLogicalBackupJob() error {
|
||||
}
|
||||
c.logger.Info("the logical backup job is synced")
|
||||
}
|
||||
if !reflect.DeepEqual(job.Labels, desiredJob.Labels) {
|
||||
patchData, err := metaLabelsPatch(desiredJob.Labels)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not form patch for the logical backup job %q labels: %v", jobName, err)
|
||||
}
|
||||
_, err = c.KubeClient.CronJobs(c.Namespace).Patch(context.TODO(), jobName, types.MergePatchType, []byte(patchData), metav1.PatchOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not patch labels of the logical backup job %q: %v", jobName, err)
|
||||
}
|
||||
}
|
||||
if changed, _ := c.compareAnnotations(job.Annotations, desiredJob.Annotations, nil); changed {
|
||||
patchData, err := metaAnnotationsPatch(desiredJob.Annotations)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user