You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/10/08 20:21:18 UTC
[GitHub] dewrich closed pull request #2869: Update grovetccfg to generate
proper remap rules for deliveryservies.
dewrich closed pull request #2869: Update grovetccfg to generate proper remap rules for deliveryservies.
URL: https://github.com/apache/trafficcontrol/pull/2869
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/grove/grovetccfg/grovetccfg.go b/grove/grovetccfg/grovetccfg.go
index a507af863..20867eed9 100644
--- a/grove/grovetccfg/grovetccfg.go
+++ b/grove/grovetccfg/grovetccfg.go
@@ -965,32 +965,31 @@ func createRulesOld(
}
rule.PluginsShared = map[string]json.RawMessage{}
- for _, parent := range parents {
- to, proxyURLStr := buildTo(parent, protocolStr.To, ds.OrgServerFQDN, dsType)
+ // if the delivery service skips the mid's ie, http_no_cache, http_live, and dns_live
+ // only add the url rule to the origin.
+ if dsTypeSkipsMid(dsType) {
+ var proxyURLStr = ""
proxyURL, err := url.Parse(proxyURLStr)
if err != nil {
- return remap.RemapRules{}, fmt.Errorf("error parsing deliveryservice %v parent %v proxy_url: %v", ds.XMLID, parent.HostName, proxyURLStr)
+ return remap.RemapRules{}, fmt.Errorf("error parsing deliveryservice %v proxy_url: %v", ds.XMLID, proxyURLStr)
}
-
ruleTo := remapdata.RemapRuleTo{
RemapRuleToBase: remapdata.RemapRuleToBase{
- URL: to,
+ URL: ds.OrgServerFQDN,
Weight: &weight,
RetryNum: &retryNum,
},
- ProxyURL: proxyURL,
RetryCodes: DefaultRetryCodes(),
+ ProxyURL: proxyURL,
Timeout: &timeout,
}
rule.To = append(rule.To, ruleTo)
- // TODO get from TO?
rule.RetryNum = &retryNum
rule.Timeout = &timeout
rule.RetryCodes = DefaultRetryCodes()
rule.QueryString = queryStringRule
rule.DSCP = ds.DSCP
rule.ConnectionClose = DefaultRuleConnectionClose
- rule.ParentSelection = &parentSelection
rule.Allow = acl
rule.Plugins = map[string]interface{}{}
rule.Plugins["modify_headers"] = toClientHeaders
@@ -1000,6 +999,43 @@ func createRulesOld(
return remap.RemapRules{}, fmt.Errorf("parsing deliveryservice '%v' remap text '%v' marshalling JSON: %v", ds.XMLID, ds.RemapText, err)
}
rule.PluginsShared[web.RemapTextKey] = remapTextJSON
+ } else {
+ for _, parent := range parents {
+ to, proxyURLStr := buildTo(parent, protocolStr.To, ds.OrgServerFQDN, dsType)
+ proxyURL, err := url.Parse(proxyURLStr)
+ if err != nil {
+ return remap.RemapRules{}, fmt.Errorf("error parsing deliveryservice %v parent %v proxy_url: %v", ds.XMLID, parent.HostName, proxyURLStr)
+ }
+
+ ruleTo := remapdata.RemapRuleTo{
+ RemapRuleToBase: remapdata.RemapRuleToBase{
+ URL: to,
+ Weight: &weight,
+ RetryNum: &retryNum,
+ },
+ ProxyURL: proxyURL,
+ RetryCodes: DefaultRetryCodes(),
+ Timeout: &timeout,
+ }
+ rule.To = append(rule.To, ruleTo)
+ // TODO get from TO?
+ rule.RetryNum = &retryNum
+ rule.Timeout = &timeout
+ rule.RetryCodes = DefaultRetryCodes()
+ rule.QueryString = queryStringRule
+ rule.DSCP = ds.DSCP
+ rule.ConnectionClose = DefaultRuleConnectionClose
+ rule.ParentSelection = &parentSelection
+ rule.Allow = acl
+ rule.Plugins = map[string]interface{}{}
+ rule.Plugins["modify_headers"] = toClientHeaders
+ rule.Plugins["modify_parent_request_headers"] = toOriginHeaders
+ remapTextJSON, err := json.Marshal(ds.RemapText)
+ if err != nil {
+ return remap.RemapRules{}, fmt.Errorf("parsing deliveryservice '%v' remap text '%v' marshalling JSON: %v", ds.XMLID, ds.RemapText, err)
+ }
+ rule.PluginsShared[web.RemapTextKey] = remapTextJSON
+ }
}
rules = append(rules, rule)
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services