Skip to content

Commit 323a465

Browse files
authored
t3c: sort peers in strategies.yaml (#7182)
1 parent 0e2058b commit 323a465

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
5151
- [#7137](https://github.com/apache/trafficcontrol/pull/7137) *Traffic Control Cache Config (t3c)* parent.config simulate topology for non topo delivery services.
5252
- [#7153](https://github.com/apache/trafficcontrol/pull/7153) *Traffic Control Cache Config (t3c)* Adds an extra T3C check for validity of an ssl cert (crash fix).
5353
- [#3965](https://github.com/apache/trafficcontrol/pull/3965) *Traffic Router* Traffic Router now always includes a `Content-Length` header in the response.
54+
- [#7182](https://github.com/apache/trafficcontrol/pull/7182) Sort peers used in strategy.yaml to prevent false positive for reload.
5455

5556
## [7.0.0] - 2022-07-19
5657
### Added

lib/go-atscfg/parentabstraction.go

+6
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ func (sp ParentAbstractionServiceParent) Key() string {
232232
return sp.FQDN + ":" + strconv.Itoa(sp.Port)
233233
}
234234

235+
type peersSort []*ParentAbstractionServiceParent
236+
237+
func (a peersSort) Len() int { return len(a) }
238+
func (a peersSort) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
239+
func (a peersSort) Less(i, j int) bool { return a[i].Key() < a[j].Key() }
240+
235241
func RemoveParentDuplicates(inputs []*ParentAbstractionServiceParent, seens map[string]struct{}) ([]*ParentAbstractionServiceParent, map[string]struct{}) {
236242
if seens == nil {
237243
seens = make(map[string]struct{})

lib/go-atscfg/parentdotconfig.go

+2
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ func makeParentDotConfigData(
402402
parentAbstraction.Peers = append(parentAbstraction.Peers, peer)
403403
}
404404

405+
sort.Sort(peersSort(parentAbstraction.Peers))
406+
405407
cgServerIDs := map[int]struct{}{}
406408
for serverID, _ := range cgServers {
407409
cgServerIDs[serverID] = struct{}{}

0 commit comments

Comments
 (0)