Skip to content

Commit 72e2359

Browse files
committed
fix(backups): reloads repo-host when secrets are updated
Signed-off-by: Juliana Oliveira <[email protected]>
1 parent f8d4e13 commit 72e2359

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

internal/controller/postgrescluster/pgbackrest.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,22 @@ func (r *Reconciler) generateRepoHostIntent(ctx context.Context, postgresCluster
595595
naming.LabelData: naming.DataPGBackRest,
596596
})
597597

598+
podAnnotations := naming.Merge(annotations)
599+
// Tracks pgbackrest secret version in order to trigger repo-host updates upon change.
600+
// Fixes a problem where repo-host certificates become stale.
601+
existingSecret := &corev1.Secret{}
602+
secretKey := client.ObjectKey{
603+
Name: naming.PGBackRestSecret(postgresCluster).Name,
604+
Namespace: postgresCluster.GetNamespace(),
605+
}
606+
607+
if err := r.Client.Get(ctx, secretKey, existingSecret); err == nil {
608+
if podAnnotations == nil {
609+
podAnnotations = make(map[string]string)
610+
}
611+
podAnnotations["postgres-operator.crunchydata.com/pgbackrest-secret-version"] = existingSecret.ResourceVersion
612+
}
613+
598614
repo := &appsv1.StatefulSet{
599615
TypeMeta: metav1.TypeMeta{
600616
APIVersion: appsv1.SchemeGroupVersion.String(),
@@ -614,7 +630,7 @@ func (r *Reconciler) generateRepoHostIntent(ctx context.Context, postgresCluster
614630
Template: corev1.PodTemplateSpec{
615631
ObjectMeta: metav1.ObjectMeta{
616632
Labels: labels,
617-
Annotations: annotations,
633+
Annotations: podAnnotations,
618634
},
619635
},
620636
},

0 commit comments

Comments
 (0)