Skip to content

Commit

Permalink
Add backup deployment pod label
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer committed Jul 7, 2023
1 parent 2e5847b commit 85a7d7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions api/v1beta2/foundationdb_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const (
// deployments to a cluster.
BackupDeploymentLabel = "foundationdb.org/backup-for"

// BackupDeploymentPodLabel provides the label to select Pods for a specific Backup deployment.
BackupDeploymentPodLabel = "foundationdb.org/deployment-name"

// PublicIPSourceAnnotation is an annotation key that specifies where a pod
// gets its public IP from.
PublicIPSourceAnnotation = "foundationdb.org/public-ip-source"
Expand Down
4 changes: 2 additions & 2 deletions internal/pod_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,9 @@ func GetBackupDeployment(backup *fdbv1beta2.FoundationDBBackup) (*appsv1.Deploym
if podTemplate.ObjectMeta.Labels == nil {
podTemplate.ObjectMeta.Labels = make(map[string]string, 1)
}
podTemplate.ObjectMeta.Labels["foundationdb.org/deployment-name"] = deployment.ObjectMeta.Name
podTemplate.ObjectMeta.Labels[fdbv1beta2.BackupDeploymentPodLabel] = deployment.ObjectMeta.Name
deployment.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{
"foundationdb.org/deployment-name": deployment.ObjectMeta.Name,
fdbv1beta2.BackupDeploymentPodLabel: deployment.ObjectMeta.Name,
}}

podTemplate.Spec.Volumes = append(podTemplate.Spec.Volumes,
Expand Down
6 changes: 3 additions & 3 deletions internal/pod_models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,7 @@ var _ = Describe("pod_models", func() {
Expect(len(deployment.ObjectMeta.OwnerReferences)).To(Equal(1))
Expect(deployment.ObjectMeta.OwnerReferences[0].UID).To(Equal(cluster.ObjectMeta.UID))
Expect(deployment.ObjectMeta.Labels).To(Equal(map[string]string{
"foundationdb.org/backup-for": string(cluster.ObjectMeta.UID),
fdbv1beta2.BackupDeploymentLabel: string(cluster.ObjectMeta.UID),
}))
Expect(deployment.ObjectMeta.Annotations).To(Equal(map[string]string{
"foundationdb.org/last-applied-spec": "a1d6ee086624f097243eb14aefbedf84a9016ba0f85640f11020bf50ec9e6d9b",
Expand All @@ -2913,10 +2913,10 @@ var _ = Describe("pod_models", func() {

It("should set the labels for the pod selector", func() {
Expect(*deployment.Spec.Selector).To(Equal(metav1.LabelSelector{MatchLabels: map[string]string{
"foundationdb.org/deployment-name": "operator-test-1-backup-agents",
fdbv1beta2.BackupDeploymentPodLabel: "operator-test-1-backup-agents",
}}))
Expect(deployment.Spec.Template.ObjectMeta.Labels).To(Equal(map[string]string{
"foundationdb.org/deployment-name": "operator-test-1-backup-agents",
fdbv1beta2.BackupDeploymentPodLabel: "operator-test-1-backup-agents",
}))
})

Expand Down

0 comments on commit 85a7d7f

Please sign in to comment.