mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-09 10:25:52 +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:
@@ -3875,7 +3875,7 @@ func TestGenerateLogicalBackupJob(t *testing.T) {
|
||||
ResourceRequests: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("100m"), Memory: k8sutil.StringToPointer("100Mi")},
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("1"), Memory: k8sutil.StringToPointer("500Mi")},
|
||||
},
|
||||
expectedLabel: map[string]string{configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedLabel: map[string]string{"application": "spilo-logical-backup", configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedAnnotation: nil,
|
||||
},
|
||||
{
|
||||
@@ -3900,7 +3900,7 @@ func TestGenerateLogicalBackupJob(t *testing.T) {
|
||||
ResourceRequests: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("10m"), Memory: k8sutil.StringToPointer("50Mi")},
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("300m"), Memory: k8sutil.StringToPointer("300Mi")},
|
||||
},
|
||||
expectedLabel: map[string]string{configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedLabel: map[string]string{"application": "spilo-logical-backup", configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedAnnotation: nil,
|
||||
},
|
||||
{
|
||||
@@ -3923,7 +3923,7 @@ func TestGenerateLogicalBackupJob(t *testing.T) {
|
||||
ResourceRequests: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("50m"), Memory: k8sutil.StringToPointer("100Mi")},
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("250m"), Memory: k8sutil.StringToPointer("500Mi")},
|
||||
},
|
||||
expectedLabel: map[string]string{configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedLabel: map[string]string{"application": "spilo-logical-backup", configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedAnnotation: nil,
|
||||
},
|
||||
{
|
||||
@@ -3946,7 +3946,7 @@ func TestGenerateLogicalBackupJob(t *testing.T) {
|
||||
ResourceRequests: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("100m"), Memory: k8sutil.StringToPointer("200Mi")},
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("1"), Memory: k8sutil.StringToPointer("200Mi")},
|
||||
},
|
||||
expectedLabel: map[string]string{configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedLabel: map[string]string{"application": "spilo-logical-backup", configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedAnnotation: nil,
|
||||
},
|
||||
{
|
||||
@@ -3968,7 +3968,7 @@ func TestGenerateLogicalBackupJob(t *testing.T) {
|
||||
ResourceRequests: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("100m"), Memory: k8sutil.StringToPointer("100Mi")},
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("1"), Memory: k8sutil.StringToPointer("500Mi")},
|
||||
},
|
||||
expectedLabel: map[string]string{"labelKey": "labelValue", "cluster-name": clusterName, "team": teamId},
|
||||
expectedLabel: map[string]string{"application": "spilo-logical-backup", "labelKey": "labelValue", "cluster-name": clusterName, "team": teamId},
|
||||
expectedAnnotation: nil,
|
||||
},
|
||||
{
|
||||
@@ -3990,7 +3990,7 @@ func TestGenerateLogicalBackupJob(t *testing.T) {
|
||||
ResourceRequests: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("100m"), Memory: k8sutil.StringToPointer("100Mi")},
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("1"), Memory: k8sutil.StringToPointer("500Mi")},
|
||||
},
|
||||
expectedLabel: map[string]string{configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedLabel: map[string]string{"application": "spilo-logical-backup", configResources.ClusterNameLabel: clusterName, "team": teamId},
|
||||
expectedAnnotation: map[string]string{"annotationKey": "annotationValue"},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user