mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-17 17:17:53 +02:00
better backwards compatibility with old DNS name format for LBs (#2171)
* better backwards compatibility with legacy DNS name format for LBs * improve docs on DNS string
This commit is contained in:
+18
-9
@@ -506,7 +506,7 @@ func (c *Cluster) roleLabelsSet(shouldAddExtraLabels bool, role PostgresRole) la
|
||||
}
|
||||
|
||||
func (c *Cluster) dnsName(role PostgresRole) string {
|
||||
var dnsString string
|
||||
var dnsString, oldDnsString string
|
||||
|
||||
if role == Master {
|
||||
dnsString = c.masterDNSName()
|
||||
@@ -517,10 +517,12 @@ func (c *Cluster) dnsName(role PostgresRole) string {
|
||||
// if cluster name starts with teamID we might need to provide backwards compatibility
|
||||
clusterNameWithoutTeamPrefix, _ := acidv1.ExtractClusterName(c.Name, c.Spec.TeamID)
|
||||
if clusterNameWithoutTeamPrefix != "" {
|
||||
if role == Replica {
|
||||
clusterNameWithoutTeamPrefix = fmt.Sprintf("%s-repl", clusterNameWithoutTeamPrefix)
|
||||
if role == Master {
|
||||
oldDnsString = c.oldMasterDNSName(clusterNameWithoutTeamPrefix)
|
||||
} else {
|
||||
oldDnsString = c.oldReplicaDNSName(clusterNameWithoutTeamPrefix)
|
||||
}
|
||||
dnsString = fmt.Sprintf("%s,%s", dnsString, c.oldDNSFormat(clusterNameWithoutTeamPrefix))
|
||||
dnsString = fmt.Sprintf("%s,%s", dnsString, oldDnsString)
|
||||
}
|
||||
|
||||
return dnsString
|
||||
@@ -542,11 +544,18 @@ func (c *Cluster) replicaDNSName() string {
|
||||
"hostedzone", c.OpConfig.DbHostedZone))
|
||||
}
|
||||
|
||||
func (c *Cluster) oldDNSFormat(clusterName string) string {
|
||||
return fmt.Sprintf("%s.%s.%s",
|
||||
clusterName,
|
||||
c.teamName(),
|
||||
c.OpConfig.DbHostedZone)
|
||||
func (c *Cluster) oldMasterDNSName(clusterName string) string {
|
||||
return strings.ToLower(c.OpConfig.MasterLegacyDNSNameFormat.Format(
|
||||
"cluster", clusterName,
|
||||
"team", c.teamName(),
|
||||
"hostedzone", c.OpConfig.DbHostedZone))
|
||||
}
|
||||
|
||||
func (c *Cluster) oldReplicaDNSName(clusterName string) string {
|
||||
return strings.ToLower(c.OpConfig.ReplicaLegacyDNSNameFormat.Format(
|
||||
"cluster", clusterName,
|
||||
"team", c.teamName(),
|
||||
"hostedzone", c.OpConfig.DbHostedZone))
|
||||
}
|
||||
|
||||
func (c *Cluster) credentialSecretName(username string) string {
|
||||
|
||||
Reference in New Issue
Block a user