Skip to content

Commit

Permalink
add automatic self-healing when using slice plugin to t3c (#7719)
Browse files Browse the repository at this point in the history
* add self healing for slice plugin by default

* adding auto self healing with slice plugin on mids

* add self-healing to the slice plugin automatically

* add tests for automatic self-healing when using the slice plugin

* Added documentation note for self-healing

* changed the way self-healing will be added to remap line

* removed tests that are not needed

* put back tests that were removed by mistake

* put blank line back

* added comments and change log entry

* fixed broken test, with 2 exact same delivery services

* fixed issue where empty param could add empty pparam to remap line

* added tests for issue where empty param could add empty pparam to remap line

* commit for rebase

* fixed a couple typos

* Added tests for no self healing param

* Added ability to remove auto self-healing for slice plugin

* updated deliveryservice documentation

* removed git merge lines

* updated to use positive bools rather than negative

* changed scope of selfHeal param

* changed to error instead of fatal
  • Loading branch information
jpappa200 committed Sep 27, 2023
1 parent 0bc433d commit 806b0d0
Show file tree
Hide file tree
Showing 4 changed files with 356 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7652](https://github.com/apache/trafficcontrol/pull/7652) *Traffic Control Cache Config (t3c)*: added rpmdb checks and use package data from t3c-apply-metadata.json if rpmdb is corrupt.
- [#7674](https://github.com/apache/trafficcontrol/issues/7674) *Traffic Ops*: Add the ability to indicate if a server failed its revalidate/config update.
- [#7784](https://github.com/apache/trafficcontrol/pull/7784) *Traffic Portal*: Added revert certificate functionality to the ssl-keys page.
- [#7719](https://github.com/apache/trafficcontrol/pull/7719) *t3c* self-healing will be added automatically when using the slice plugin.

### Changed
- [#7776](https://github.com/apache/trafficcontrol/pull/7776) *tc-health-client*: Added error message while issues interacting with Traffic Ops.
Expand Down
2 changes: 2 additions & 0 deletions docs/source/overview/delivery_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ Describes how HTTP "Range Requests" should be handled by the Delivery Service at
3
Use the `slice <https://github.com/apache/trafficserver/tree/master/plugins/experimental/slice>`_ plugin to slice range based requests into deterministic chunks. (Aliased as "3 - Use slice plugin" in Traffic Portal forms)

.. note:: The ``-–consider-ims`` parameter will automatically be added to the remap line by :term:`t3c` for self healing. If any other range request parameters are being used you must also include ``--consider-ims`` to enable self healing. Automatic self healing can be disabled by adding a remap.config parameter with a value of ``no_self_healing``

.. versionadded:: ATCv4.1

.. note:: Range Request Handling can only be implemented on :term:`cache servers` using :abbr:`ATS (Apache Traffic Server)` because of its dependence on :abbr:`ATS (Apache Traffic Server)` plugins. The value may be set on any Delivery Service, but will have no effect when the :term:`cache servers` that ultimately end up serving the content are e.g. Grove, Nginx, etc.
Expand Down
31 changes: 23 additions & 8 deletions lib/go-atscfg/remapdotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const RemapConfigTemplateLast = `template.last`
const DefaultFirstRemapConfigTemplateString = `map {{{Source}}} {{{Destination}}} {{{Strategy}}} {{{Dscp}}} {{{HeaderRewrite}}} {{{DropQstring}}} {{{Signing}}} {{{RegexRemap}}} {{{Cachekey}}} {{{RangeRequests}}} {{{Pacing}}} {{{RawText}}}`
const DefaultLastRemapConfigTemplateString = `map {{{Source}}} {{{Destination}}} {{{Strategy}}} {{{HeaderRewrite}}} {{{Cachekey}}} {{{RangeRequests}}} {{{RawText}}}`
const DefaultInnerRemapConfigTemplateString = DefaultLastRemapConfigTemplateString
const selfHealParam = `no_self_healing`

type LineTemplates map[string]*mustache.Template

Expand Down Expand Up @@ -223,23 +224,31 @@ func MakeRemapDotConfig(
// This sticks the DS parameters in a map.
// remap.config parameters use "<plugin>.pparam" key
// cachekey.config parameters retain the 'cachekey.config' key.
func classifyConfigParams(configParams []tc.ParameterV5) map[string][]tc.ParameterV5 {
func classifyConfigParams(configParams []tc.ParameterV5) (map[string][]tc.ParameterV5, bool) {
configParamMap := map[string][]tc.ParameterV5{}
selfHeal := true
for _, param := range configParams {
key := param.ConfigFile
if "remap.config" == key {
key = param.Name
if param.Value == selfHealParam {
selfHeal = false
continue
}
}
configParamMap[key] = append(configParamMap[key], param)
}
return configParamMap
return configParamMap, selfHeal
}

// For general <plugin>.pparam parameters.
func paramsStringFor(parameters []tc.ParameterV5, warnings *[]string) (paramsString string) {
uniquemap := map[string]int{}

for _, param := range parameters {
if strings.TrimSpace(param.Value) == "" {
continue
}
paramsString += " @pparam=" + param.Value

// Try to extract argument
Expand Down Expand Up @@ -407,9 +416,10 @@ func getServerConfigRemapDotConfigForMid(
cachekeyArgs = getQStringIgnoreRemap(atsMajorVersion)
}

selfHeal := true
dsConfigParamsMap := map[string][]tc.ParameterV5{}
if nil != ds.ProfileID {
dsConfigParamsMap = classifyConfigParams(profilesConfigParams[*ds.ProfileID])
dsConfigParamsMap, selfHeal = classifyConfigParams(profilesConfigParams[*ds.ProfileID])
}

if len(dsConfigParamsMap) > 0 {
Expand All @@ -421,8 +431,11 @@ func getServerConfigRemapDotConfigForMid(
}

if ds.RangeRequestHandling != nil && (*ds.RangeRequestHandling == tc.RangeRequestHandlingCacheRangeRequest || *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice) {
remapTags.RangeRequests = `@plugin=cache_range_requests.so` +
paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings)
crrParam := paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings)
remapTags.RangeRequests = `@plugin=cache_range_requests.so` + crrParam
if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && !strings.Contains(crrParam, "--consider-ims") && selfHeal {
remapTags.RangeRequests += ` @pparam=--consider-ims`
}
}

isLastCache, err := serverIsLastCacheForDS(server, &ds, nameTopologies, cacheGroups)
Expand Down Expand Up @@ -694,7 +707,7 @@ func buildEdgeRemapLine(
remapTags.HeaderRewrite = `@plugin=header_rewrite.so @pparam=` + edgeHeaderRewriteConfigFileName(ds.XMLID)
}

dsConfigParamsMap := classifyConfigParams(remapConfigParams)
dsConfigParamsMap, selfHeal := classifyConfigParams(remapConfigParams)

if ds.SigningAlgorithm != nil && *ds.SigningAlgorithm != "" {
if *ds.SigningAlgorithm == tc.SigningAlgorithmURLSig {
Expand Down Expand Up @@ -772,8 +785,10 @@ func buildEdgeRemapLine(
}

if crr {
rangeReqTxt += `@plugin=cache_range_requests.so ` +
paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings)
rangeReqTxt += `@plugin=cache_range_requests.so ` + paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings)
if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && !strings.Contains(rangeReqTxt, "--consider-ims") && selfHeal {
rangeReqTxt += ` @pparam=--consider-ims`
}
}
}

Expand Down

0 comments on commit 806b0d0

Please sign in to comment.