@@ -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