Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t3c: strategies.yaml hash_key only for consistent_hash #7204

Merged
merged 4 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7137](https://github.com/apache/trafficcontrol/pull/7137) *Traffic Control Cache Config (t3c)* parent.config simulate topology for non topo delivery services.
- [#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).
- [#3965](https://github.com/apache/trafficcontrol/pull/3965) *Traffic Router* Traffic Router now always includes a `Content-Length` header in the response.
- [#7182](https://github.com/apache/trafficcontrol/pull/7182) Sort peers used in strategy.yaml to prevent false positive for reload.
- [#6533](https://github.com/apache/trafficcontrol/issues/6533) *TR should not rename/recreate log files on rollover
- [#7182](https://github.com/apache/trafficcontrol/pull/7182) *Traffic Control Cache Config (t3c)* Sort peers used in strategy.yaml to prevent false positive for reload.
ocket8888 marked this conversation as resolved.
Show resolved Hide resolved
- [#7204](https://github.com/apache/trafficcontrol/pull/7204) *Traffic Control Cache Config (t3c)* strategies.yaml hash_key only for consistent_hash

## [7.0.0] - 2022-07-19
### Added
Expand Down
10 changes: 6 additions & 4 deletions lib/go-atscfg/strategiesdotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ func getStrategyStrategiesSection(pa *ParentAbstraction) string {
for _, svc := range pa.Services {
txt += "\n" + ` - strategy: '` + getStrategyName(svc.Name) + `'`
txt += "\n" + ` policy: ` + getStrategyPolicy(svc.RetryPolicy)
if !svc.IgnoreQueryStringInParentSelection {
txt += "\n" + ` hash_key: path+query`
} else {
txt += "\n" + ` hash_key: path`
if svc.RetryPolicy == ParentAbstractionServiceRetryPolicyConsistentHash {
if !svc.IgnoreQueryStringInParentSelection {
txt += "\n" + ` hash_key: path+query`
} else {
txt += "\n" + ` hash_key: path`
}
}
txt += "\n" + ` go_direct: ` + strconv.FormatBool(svc.GoDirect)
if getStrategySecondaryMode(svc.SecondaryMode) == "peering_ring" {
Expand Down
20 changes: 20 additions & 0 deletions lib/go-atscfg/strategiesdotconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,15 @@ func TestMakeStrategiesDotYAMLFirstLastNoTopoParams(t *testing.T) {
if 0 < len(missing) {
t.Errorf("Missing required string(s) from ds/line: %s/%v\n%v", *ds.XMLID, missing, txt)
}

excludes := []string{
`hash_key`,
}

excluding := missingFrom(txt, excludes)
if 1 != len(excludes) {
t.Errorf("Excluded required string(s) from ds/line: %s/%v\n%v", *ds.XMLID, excluding, txt)
}
}
}

Expand Down Expand Up @@ -1783,6 +1792,7 @@ func TestMakeStrategiesDotYAMLFirstInnerLastParams(t *testing.T) {

needs := []string{
` policy: consistent_hash`,
` hash_key: path`,
` go_direct: false`,
` max_simple_retries: 12`,
` max_unavailable_retries: 22`,
Expand All @@ -1809,6 +1819,7 @@ func TestMakeStrategiesDotYAMLFirstInnerLastParams(t *testing.T) {

needs := []string{
` policy: consistent_hash`,
` hash_key: path`,
` go_direct: false`,
` max_simple_retries: 13`,
` max_unavailable_retries: 23`,
Expand Down Expand Up @@ -1846,5 +1857,14 @@ func TestMakeStrategiesDotYAMLFirstInnerLastParams(t *testing.T) {
if 0 < len(missing) {
t.Errorf("Missing required string(s) from line: %v\n%v", missing, txt)
}

excludes := []string{
`hash_key`,
}

excluding := missingFrom(txt, excludes)
if 1 != len(excludes) {
t.Errorf("Excluded required string(s) from ds/line: %s/%v\n%v", *ds.XMLID, excluding, txt)
}
}
}