Skip to content

Commit b24a778

Browse files
committed
fix pgbackrest tls error after migration
1 parent 760381f commit b24a778

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

percona/certmanager/certmanager.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,10 @@ func (c *controller) ApplyPGBackRestClientCertificate(ctx context.Context, clust
602602
certDuration = cluster.Spec.TLS.PGBackRestCertValidityDuration.Duration
603603
}
604604

605+
// The common name must match what pgBackRest expects in its tls-server-auth option.
606+
// All instances in the cluster share a single client certificate identified by cluster UID.
607+
commonName := "pgbackrest@" + string(cluster.GetUID())
608+
605609
existing := &v1.Certificate{}
606610
err := c.cl.Get(ctx, types.NamespacedName{Name: certName, Namespace: cluster.Namespace}, existing)
607611
if err == nil {
@@ -630,6 +634,12 @@ func (c *controller) ApplyPGBackRestClientCertificate(ctx context.Context, clust
630634
needsUpdate = true
631635
}
632636

637+
if existing.Spec.CommonName != commonName {
638+
existing.Spec.CommonName = commonName
639+
existing.Spec.DNSNames = []string{commonName}
640+
needsUpdate = true
641+
}
642+
633643
if !needsUpdate {
634644
return nil
635645
}
@@ -640,10 +650,6 @@ func (c *controller) ApplyPGBackRestClientCertificate(ctx context.Context, clust
640650
return errors.Wrap(err, "failed to get pgbackrest client certificate")
641651
}
642652

643-
// The common name must match what pgBackRest expects in its tls-server-auth option.
644-
// All instances in the cluster share a single client certificate identified by cluster UID.
645-
commonName := "pgbackrest@" + string(cluster.GetUID())
646-
647653
cert := &v1.Certificate{
648654
ObjectMeta: metav1.ObjectMeta{
649655
Name: certName,

0 commit comments

Comments
 (0)