Skip to content

Commit 4ed3c93

Browse files
committed
Ensure stable ordering/consistency of pools.yaml contents
rndc keys and predictable ips need to match by index as they are "per bind". This patch removes sorting on IPs etc which will interfere with this association.
1 parent 5f20345 commit 4ed3c93

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

pkg/designate/generate_bind9_pools_yaml.go

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,34 @@ func GeneratePoolsYamlDataAndHash(BindMap, MdnsMap, NsRecordsMap map[string]stri
8989
return nsRecords[i].Priority < nsRecords[j].Priority
9090
})
9191

92-
bindIPs := make([]string, 0, len(BindMap))
93-
for _, ip := range BindMap {
94-
bindIPs = append(bindIPs, ip)
92+
bindIPs := make([]string, len(BindMap))
93+
key_tmpl := "bind_address_%d"
94+
for i := 0; i < len(BindMap); i++ {
95+
bindIPs[i] = BindMap[fmt.Sprintf(key_tmpl, i)]
9596
}
96-
sort.Strings(bindIPs)
9797

9898
masterHosts := make([]string, 0, len(MdnsMap))
9999
for _, host := range MdnsMap {
100100
masterHosts = append(masterHosts, host)
101101
}
102102
sort.Strings(masterHosts)
103103

104-
nameservers := make([]Nameserver, len(bindIPs))
105-
for i, bindIP := range bindIPs {
106-
nameservers[i] = Nameserver{
107-
Host: bindIP,
108-
Port: 53,
109-
}
110-
}
111-
112104
targets := make([]Target, len(bindIPs))
113-
for i, bindIP := range bindIPs {
105+
nameservers := make([]Nameserver, len(bindIPs))
106+
for i := 0; i < len(bindIPs); i++ {
114107
masters := make([]Master, len(masterHosts))
115108
for j, masterHost := range masterHosts {
116109
masters[j] = Master{
117110
Host: masterHost,
118111
Port: 5354,
119112
}
120113
}
114+
bindIP := bindIPs[i]
121115

116+
nameservers[i] = Nameserver{
117+
Host: bindIP,
118+
Port: 53,
119+
}
122120
targets[i] = Target{
123121
Type: "bind9",
124122
Description: fmt.Sprintf("BIND9 Server %d (%s)", i, bindIP),
@@ -133,15 +131,6 @@ func GeneratePoolsYamlDataAndHash(BindMap, MdnsMap, NsRecordsMap map[string]stri
133131
}
134132
}
135133

136-
sort.Slice(targets, func(i, j int) bool {
137-
return targets[i].Options.Host < targets[j].Options.Host
138-
})
139-
140-
for i := range targets {
141-
targets[i].Description = fmt.Sprintf("BIND9 Server %d (%s)", i, targets[i].Options.Host)
142-
targets[i].Options.RNDCKeyFile = fmt.Sprintf("%s/%s-%d", RndcConfDir, DesignateRndcKey, i)
143-
}
144-
145134
// Catalog zone is an optional section
146135
// catalogZone := &CatalogZone{
147136
// FQDN: "example.org.",

0 commit comments

Comments
 (0)