From 84c36cb9dcaac9112a92f0adf5b20aa099d23eb9 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 8 Aug 2023 15:44:55 -0400 Subject: [PATCH 01/22] add self healing for slice plugin by default --- lib/go-atscfg/remapdotconfig.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index 5f9b0e277e..99e8d95f24 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -757,6 +757,7 @@ func buildEdgeRemapLine( rangeReqTxt := "" if ds.RangeRequestHandling != nil { crr := false + addIms := false if *ds.RangeRequestHandling == tc.RangeRequestHandlingBackgroundFetch { rangeReqTxt = `@plugin=background_fetch.so @pparam=--config=bg_fetch.config` + @@ -767,6 +768,7 @@ func buildEdgeRemapLine( paramsStringFor(dsConfigParamsMap["slice.pparam"], &warnings) rangeReqTxt += ` ` crr = true + addIms = true } else if *ds.RangeRequestHandling == tc.RangeRequestHandlingCacheRangeRequest { crr = true } @@ -775,6 +777,9 @@ func buildEdgeRemapLine( rangeReqTxt += `@plugin=cache_range_requests.so ` + paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) } + if addIms { + rangeReqTxt += `@pparam=--consider-ims ` + } } // Hack for moving the range directive into the raw remap text From 9eaf3ba874b9ca3004414c067336c1e60797d396 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 9 Aug 2023 13:24:28 -0400 Subject: [PATCH 02/22] adding auto self healing with slice plugin on mids --- lib/go-atscfg/remapdotconfig.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index 99e8d95f24..9659fe5757 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -423,6 +423,9 @@ 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) + if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice { + remapTags.RangeRequests += ` @pparam=--consider-ims` + } } isLastCache, err := serverIsLastCacheForDS(server, &ds, nameTopologies, cacheGroups) From 7f2c5f2df883e57c0b46d84459fe1dca09ccf8bf Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 15 Aug 2023 16:24:13 -0400 Subject: [PATCH 03/22] add self-healing to the slice plugin automatically --- lib/go-atscfg/remapdotconfig.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index 9659fe5757..384fd5aaa0 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -423,7 +423,7 @@ 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) - if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice { + if !strings.Contains(remapTags.RangeRequests, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice { remapTags.RangeRequests += ` @pparam=--consider-ims` } } @@ -760,7 +760,6 @@ func buildEdgeRemapLine( rangeReqTxt := "" if ds.RangeRequestHandling != nil { crr := false - addIms := false if *ds.RangeRequestHandling == tc.RangeRequestHandlingBackgroundFetch { rangeReqTxt = `@plugin=background_fetch.so @pparam=--config=bg_fetch.config` + @@ -771,7 +770,6 @@ func buildEdgeRemapLine( paramsStringFor(dsConfigParamsMap["slice.pparam"], &warnings) rangeReqTxt += ` ` crr = true - addIms = true } else if *ds.RangeRequestHandling == tc.RangeRequestHandlingCacheRangeRequest { crr = true } @@ -779,9 +777,9 @@ func buildEdgeRemapLine( if crr { rangeReqTxt += `@plugin=cache_range_requests.so ` + paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) - } - if addIms { - rangeReqTxt += `@pparam=--consider-ims ` + if !strings.Contains(rangeReqTxt, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && ds.RangeSliceBlockSize != nil { + rangeReqTxt += ` @pparam=--consider-ims` + } } } From d6a03f8255c11b63d266d02d96cc5ad67e4850b7 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 15 Aug 2023 16:25:17 -0400 Subject: [PATCH 04/22] add tests for automatic self-healing when using the slice plugin --- lib/go-atscfg/remapdotconfig_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index 5776656703..f7f061ead2 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -1686,7 +1686,9 @@ func TestMakeRemapDotConfigMidSlicePluginRangeRequestHandling(t *testing.T) { txt := cfg.Text txt = strings.TrimSpace(txt) - + if !strings.Contains(txt, "@pparam=--consider-ims") { + t.Fatalf("expected '--consider-ims' param with 'cache_range_requests.so' when using slice plugin to enable self healing, actual: %s", txt) + } testComment(t, txt, hdr) txtLines := strings.Split(txt, "\n") @@ -5562,6 +5564,10 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlice(t *testing.T) { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) } + if !strings.Contains(remapLine, "@pparam=--consider-ims") { + t.Errorf("expected remap on edge server with ds slice range request handling to contain parameter --consider-ims for self healing, actual '%s", txt) + } + if !strings.Contains(remapLine, "pparam=--blockbytes=262144") { t.Errorf("expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) } @@ -5702,6 +5708,10 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) } + if strings.Count(remapLine, "--consider-ims") > 1 { + t.Errorf("expected remap on mid server with ds slice range request handling to contain one occurance of plugin arg --consider-ims, actual '%s'", txt) + } + if strings.Contains(remapLine, "pparam=--blockbytes") { t.Errorf("did not expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) } @@ -5852,6 +5862,10 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) } + if strings.Count(remapLine, "--consider-ims") > 1 { + t.Errorf("expected remap on edge server with ds slice range request handling to contain one occurance of plugin arg --consider-ims, actual '%s'", txt) + } + if !strings.Contains(remapLine, "--no-modify-cachekey") { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --no-modify-cachekey, actual '%v'", txt) } From 86991375737a9fa2b691bdb82161242cb711a861 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 17 Aug 2023 17:01:56 -0400 Subject: [PATCH 05/22] Added documentation note for self-healing --- docs/source/overview/delivery_services.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/overview/delivery_services.rst b/docs/source/overview/delivery_services.rst index cda8b4d5ea..fe4b26d7c8 100644 --- a/docs/source/overview/delivery_services.rst +++ b/docs/source/overview/delivery_services.rst @@ -676,6 +676,8 @@ Describes how HTTP "Range Requests" should be handled by the Delivery Service at 3 Use the `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. + .. 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. From 42a977617314bc4ab6378082881aa099b34d79b6 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 17 Aug 2023 17:02:33 -0400 Subject: [PATCH 06/22] changed the way self-healing will be added to remap line --- lib/go-atscfg/remapdotconfig.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index 384fd5aaa0..07c91b927f 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -421,9 +421,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) - if !strings.Contains(remapTags.RangeRequests, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice { + rqParam := paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) + remapTags.RangeRequests = `@plugin=cache_range_requests.so` + if rqParam != "" { + remapTags.RangeRequests += rqParam + } else if !strings.Contains(remapTags.RangeRequests, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice { remapTags.RangeRequests += ` @pparam=--consider-ims` } } @@ -775,10 +777,12 @@ func buildEdgeRemapLine( } if crr { - rangeReqTxt += `@plugin=cache_range_requests.so ` + - paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) - if !strings.Contains(rangeReqTxt, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && ds.RangeSliceBlockSize != nil { - rangeReqTxt += ` @pparam=--consider-ims` + rqParam := paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) + rangeReqTxt += `@plugin=cache_range_requests.so ` + if rqParam != "" { + rangeReqTxt += rqParam + } else if !strings.Contains(rangeReqTxt, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && ds.RangeSliceBlockSize != nil { + rangeReqTxt += `@pparam=--consider-ims` } } } From 6b8f742d11d01fd34ddefff4660b4d84704c8fba Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 17 Aug 2023 17:03:30 -0400 Subject: [PATCH 07/22] removed tests that are not needed --- lib/go-atscfg/remapdotconfig_test.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index f7f061ead2..33e4795102 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -5704,14 +5704,6 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) } - if !strings.Contains(remapLine, "--consider-ims") { - t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) - } - - if strings.Count(remapLine, "--consider-ims") > 1 { - t.Errorf("expected remap on mid server with ds slice range request handling to contain one occurance of plugin arg --consider-ims, actual '%s'", txt) - } - if strings.Contains(remapLine, "pparam=--blockbytes") { t.Errorf("did not expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) } @@ -5858,14 +5850,6 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) } - if !strings.Contains(remapLine, "--consider-ims") { - t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) - } - - if strings.Count(remapLine, "--consider-ims") > 1 { - t.Errorf("expected remap on edge server with ds slice range request handling to contain one occurance of plugin arg --consider-ims, actual '%s'", txt) - } - if !strings.Contains(remapLine, "--no-modify-cachekey") { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --no-modify-cachekey, actual '%v'", txt) } From 0bdb54af683b38b60cbcd7937f690a9fa3e61701 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 17 Aug 2023 17:08:53 -0400 Subject: [PATCH 08/22] put back tests that were removed by mistake --- lib/go-atscfg/remapdotconfig_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index 33e4795102..74526d248b 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -5704,6 +5704,10 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) } + if !strings.Contains(remapLine, "--consider-ims") { + t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) + } + if strings.Contains(remapLine, "pparam=--blockbytes") { t.Errorf("did not expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) } @@ -5850,6 +5854,10 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) } + if !strings.Contains(remapLine, "--consider-ims") { + t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) + } + if !strings.Contains(remapLine, "--no-modify-cachekey") { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --no-modify-cachekey, actual '%v'", txt) } From fb6218468bcb395f535919c0ce475ca9d360e838 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 17 Aug 2023 17:12:25 -0400 Subject: [PATCH 09/22] put blank line back --- lib/go-atscfg/remapdotconfig_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index 74526d248b..7948f3298d 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -1686,6 +1686,7 @@ func TestMakeRemapDotConfigMidSlicePluginRangeRequestHandling(t *testing.T) { txt := cfg.Text txt = strings.TrimSpace(txt) + if !strings.Contains(txt, "@pparam=--consider-ims") { t.Fatalf("expected '--consider-ims' param with 'cache_range_requests.so' when using slice plugin to enable self healing, actual: %s", txt) } From 632e5e95313680bb37429793c151a2903b482ea0 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 18 Aug 2023 12:35:41 -0400 Subject: [PATCH 10/22] added comments and change log entry --- CHANGELOG.md | 2 ++ lib/go-atscfg/remapdotconfig.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8397a7b1eb..0564768041 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [8.0.0] - 2023-09-20 ### Added +<<<<<<< HEAD - [#7672](https://github.com/apache/trafficcontrol/pull/7672) *Traffic Control Health Client*: Added peer monitor flag while using `strategies.yaml`. - [#7609](https://github.com/apache/trafficcontrol/pull/7609) *Traffic Portal*: Added Scope Query Param to SSO login. - [#7450](https://github.com/apache/trafficcontrol/pull/7450) *Traffic Ops*: Removed hypnotoad section and added listen field to traffic_ops_golang section in order to simplify cdn config. @@ -53,6 +54,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. diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index 07c91b927f..48b2b2049a 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -425,6 +425,7 @@ func getServerConfigRemapDotConfigForMid( remapTags.RangeRequests = `@plugin=cache_range_requests.so` if rqParam != "" { remapTags.RangeRequests += rqParam + //this check may seem excessive, but I want to be sure we don't have --consider-ims in remap twice } else if !strings.Contains(remapTags.RangeRequests, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice { remapTags.RangeRequests += ` @pparam=--consider-ims` } @@ -781,6 +782,7 @@ func buildEdgeRemapLine( rangeReqTxt += `@plugin=cache_range_requests.so ` if rqParam != "" { rangeReqTxt += rqParam + //this check may seem excessive, but I want to be sure we don't have --consider-ims in remap twice } else if !strings.Contains(rangeReqTxt, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && ds.RangeSliceBlockSize != nil { rangeReqTxt += `@pparam=--consider-ims` } From 264add40ef03c83da9e2846b9f2ffd6a53e6877d Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 18 Aug 2023 16:36:57 -0400 Subject: [PATCH 11/22] fixed broken test, with 2 exact same delivery services --- lib/go-atscfg/remapdotconfig_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index 7948f3298d..ab856590a1 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -1599,7 +1599,7 @@ func TestMakeRemapDotConfigMidSlicePluginRangeRequestHandling(t *testing.T) { ds.Active = tc.DSActiveStateActive ds2 := DeliveryService{} - ds2.ID = util.Ptr(48) + ds2.ID = util.Ptr(50) dsType2 := "HTTP_LIVE_NATNL" ds2.Type = &dsType2 ds2.OrgServerFQDN = util.Ptr("origin.example.test") @@ -1629,6 +1629,10 @@ func TestMakeRemapDotConfigMidSlicePluginRangeRequestHandling(t *testing.T) { Server: server.ID, DeliveryService: *ds.ID, }, + DeliveryServiceServer{ + Server: *server.ID, + DeliveryService: *ds2.ID, + }, } dsRegexes := []tc.DeliveryServiceRegexes{ @@ -6416,6 +6420,10 @@ func TestMakeRemapDotConfigRawRemapWithoutRangeDirective(t *testing.T) { t.Errorf("expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) } + if !strings.Contains(remapLine, "@pparam=--consider-ims") { + t.Errorf("expected remap on edge server with ds slice range request handling to contain --consider-ims for self-healing, actual '%v'", txt) + } + if !strings.HasSuffix(remapLine, "@plugin=tslua.so @pparam=my-range-manipulator.lua # ds 'mydsname' topology ''") { t.Errorf("expected raw remap without range directive at end of remap line, actual '%v'", txt) } From a0d7ffd73627c7e1bfd078d5d6c8ae57a16d2cc8 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Mon, 21 Aug 2023 14:47:43 -0400 Subject: [PATCH 12/22] fixed issue where empty param could add empty pparam to remap line --- lib/go-atscfg/remapdotconfig.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index 48b2b2049a..c52c2b2a10 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -240,6 +240,9 @@ func paramsStringFor(parameters []tc.ParameterV5, warnings *[]string) (paramsStr uniquemap := map[string]int{} for _, param := range parameters { + if strings.TrimSpace(param.Value) == "" { + continue + } paramsString += " @pparam=" + param.Value // Try to extract argument From 66211738dc02b7eceebda3b1d58aee1ba6ca7d37 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Mon, 21 Aug 2023 14:48:12 -0400 Subject: [PATCH 13/22] added tests for issue where empty param could add empty pparam to remap line --- lib/go-atscfg/remapdotconfig_test.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index ab856590a1..258d8a095e 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -5666,6 +5666,12 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { Value: "notinconfig", Profiles: []byte(`["global"]`), }, + tc.Parameter{ + Name: "cache_range_requests.pparam", + ConfigFile: "remap.config", + Value: "", + Profiles: []byte(`["dsprofile"]`), + }, } cdn := &tc.CDNV5{ @@ -5696,7 +5702,7 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { } remapLine := txtLines[2] - + words := strings.Fields(remapLine) if !strings.HasPrefix(remapLine, "map") { t.Errorf("expected to start with 'map', actual '%v'", txt) } @@ -5716,6 +5722,11 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { if strings.Contains(remapLine, "pparam=--blockbytes") { t.Errorf("did not expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) } + for _, word := range words { + if word == "@pparam=" { + t.Errorf("expected remap on mid server with empty 'cache_range_requests.pparam' to be skipped and not have empty '@pparam=' on remapline, actual %s", txt) + } + } } func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { @@ -5812,6 +5823,12 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { Value: "notinconfig", Profiles: []byte(`["global"]`), }, + tc.Parameter{ + Name: "cache_range_requests.pparam", + ConfigFile: "remap.config", + Value: "", + Profiles: []byte(`["dsprofile"]`), + }, } cdn := &tc.CDNV5{ @@ -5842,6 +5859,7 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { } remapLine := txtLines[2] + words := strings.Fields(remapLine) if !strings.HasPrefix(remapLine, "map") { t.Errorf("expected to start with 'map', actual '%v'", txt) @@ -5870,6 +5888,11 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { if !strings.Contains(remapLine, "pparam=--blockbytes=262144") { t.Errorf("expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) } + for _, word := range words { + if word == "@pparam=" { + t.Errorf("expected remap on edge server with empty 'cache_range_requests.pparam' to be skipped and not have empty '@pparam=' on remapline, actual %s", txt) + } + } } func TestMakeRemapDotConfigRawRemapRangeDirective(t *testing.T) { From f8f7c163ced47ebb4ea5026b1eb34c0694051716 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 14 Sep 2023 10:29:28 -0400 Subject: [PATCH 14/22] commit for rebase --- lib/go-atscfg/remapdotconfig.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index c52c2b2a10..f264aa51ee 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -428,8 +428,8 @@ func getServerConfigRemapDotConfigForMid( remapTags.RangeRequests = `@plugin=cache_range_requests.so` if rqParam != "" { remapTags.RangeRequests += rqParam - //this check may seem excessive, but I want to be sure we don't have --consider-ims in remap twice - } else if !strings.Contains(remapTags.RangeRequests, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice { + } + if !strings.Contains(remapTags.RangeRequests, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && rqParam != "" { remapTags.RangeRequests += ` @pparam=--consider-ims` } } From 09ca0341ddcd815a0882290d1c4f9c91ed3e8bb1 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 21 Sep 2023 10:33:23 -0400 Subject: [PATCH 15/22] fixed a couple typos --- lib/go-atscfg/remapdotconfig_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index 258d8a095e..d361ece7f3 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -1630,7 +1630,7 @@ func TestMakeRemapDotConfigMidSlicePluginRangeRequestHandling(t *testing.T) { DeliveryService: *ds.ID, }, DeliveryServiceServer{ - Server: *server.ID, + Server: server.ID, DeliveryService: *ds2.ID, }, } @@ -5666,7 +5666,7 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { Value: "notinconfig", Profiles: []byte(`["global"]`), }, - tc.Parameter{ + tc.ParameterV5{ Name: "cache_range_requests.pparam", ConfigFile: "remap.config", Value: "", @@ -5823,7 +5823,7 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { Value: "notinconfig", Profiles: []byte(`["global"]`), }, - tc.Parameter{ + tc.ParameterV5{ Name: "cache_range_requests.pparam", ConfigFile: "remap.config", Value: "", From 8515a1c471b4fef8e70c62d99bf64ebdc1d26469 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Sep 2023 16:47:29 -0400 Subject: [PATCH 16/22] Added tests for no self healing param --- lib/go-atscfg/remapdotconfig_test.go | 314 +++++++++++++++++++++++++-- 1 file changed, 301 insertions(+), 13 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index d361ece7f3..b47fbd0904 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -5578,7 +5578,7 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlice(t *testing.T) { } } -func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { +func TestMakeRemapDotConfigMidRangeRequestSliceNoAutoSelfHeal(t *testing.T) { hdr := "myHeaderComment" server := makeTestRemapServer() @@ -5654,12 +5654,6 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { } remapConfigParams := []tc.ParameterV5{ - tc.ParameterV5{ - Name: "cache_range_requests.pparam", - ConfigFile: "remap.config", - Value: "--consider-ims", - Profiles: []byte(`["dsprofile"]`), - }, tc.ParameterV5{ Name: "not_location", ConfigFile: "cachekey.config", @@ -5669,7 +5663,7 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { tc.ParameterV5{ Name: "cache_range_requests.pparam", ConfigFile: "remap.config", - Value: "", + Value: selfHealParam, Profiles: []byte(`["dsprofile"]`), }, } @@ -5715,8 +5709,8 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) } - if !strings.Contains(remapLine, "--consider-ims") { - t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) + if strings.Contains(remapLine, "--consider-ims") { + t.Errorf("expected remap on mid server with ds slice range request handling and '%s' param to not contain cache_range_requests plugin arg --consider-ims, actual '%v'", selfHealParam, txt) } if strings.Contains(remapLine, "pparam=--blockbytes") { @@ -5729,11 +5723,11 @@ func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { } } -func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { +func TestMakeRemapDotConfigMidRangeRequestSlicePparam(t *testing.T) { hdr := "myHeaderComment" server := makeTestRemapServer() - server.Type = "EDGE" + server.Type = "MID" servers := []Server{} ds := DeliveryService{} @@ -5811,6 +5805,145 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { Value: "--consider-ims", Profiles: []byte(`["dsprofile"]`), }, + tc.ParameterV5{ + Name: "not_location", + ConfigFile: "cachekey.config", + Value: "notinconfig", + Profiles: []byte(`["global"]`), + }, + } + + cdn := &tc.CDNV5{ + DomainName: "cdndomain.example", + Name: "my-cdn-name", + } + + topologies := []tc.TopologyV5{} + cgs := []tc.CacheGroupNullableV5{} + serverCapabilities := map[int]map[ServerCapability]struct{}{} + dsRequiredCapabilities := map[int]map[ServerCapability]struct{}{} + configDir := `/opt/trafficserver/etc/trafficserver` + + cfg, err := MakeRemapDotConfig(server, servers, dses, dss, dsRegexes, serverParams, cdn, remapConfigParams, topologies, cgs, serverCapabilities, dsRequiredCapabilities, configDir, &RemapDotConfigOpts{HdrComment: hdr}) + if err != nil { + t.Fatal(err) + } + txt := cfg.Text + + txt = strings.TrimSpace(txt) + + testComment(t, txt, hdr) + + txtLines := strings.Split(txt, "\n") + + if len(txtLines) != 3 { // comment, blank, and remap + t.Fatalf("expected a comment header, a blank line, and 1 remaps from HTTP_TO_HTTPS DS, actual: '%v' count %v", txt, len(txtLines)) + } + + remapLine := txtLines[2] + words := strings.Fields(remapLine) + if !strings.HasPrefix(remapLine, "map") { + t.Errorf("expected to start with 'map', actual '%v'", txt) + } + + if strings.Contains(remapLine, "slice.so") { + t.Errorf("did not expected remap on mid server with ds slice range request handling to contain slice plugin, actual '%v'", txt) + } + + if !strings.Contains(remapLine, "cache_range_requests.so") { + t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) + } + + if !strings.Contains(remapLine, "--consider-ims") { + t.Errorf("expected remap on mid server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) + } + + if strings.Contains(remapLine, "pparam=--blockbytes") { + t.Errorf("did not expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) + } + for _, word := range words { + if word == "@pparam=" { + t.Errorf("expected remap on mid server with empty 'cache_range_requests.pparam' to be skipped and not have empty '@pparam=' on remapline, actual %s", txt) + } + } +} + +func TestMakeRemapDotConfigEdgeRangeRequestSliceNoAutoSelfHeal(t *testing.T) { + hdr := "myHeaderComment" + + server := makeTestRemapServer() + server.Type = "EDGE" + servers := []Server{} + + ds := DeliveryService{} + ds.ID = util.Ptr(48) + dsType := "HTTP_LIVE_NATNL" + ds.Type = &dsType + ds.OrgServerFQDN = util.Ptr("origin.example.test") + ds.MidHeaderRewrite = util.Ptr("") + ds.RangeRequestHandling = util.Ptr(tc.RangeRequestHandlingSlice) + ds.RemapText = util.Ptr("myremaptext") + ds.EdgeHeaderRewrite = nil + ds.SigningAlgorithm = util.Ptr("foo") + ds.XMLID = "mydsname" + ds.QStringIgnore = util.Ptr(int(tc.QueryStringIgnoreIgnoreInCacheKeyAndPassUp)) + ds.RegexRemap = util.Ptr("") + ds.FQPacingRate = util.Ptr(0) + ds.DSCP = 0 + ds.RoutingName = "myroutingname" + ds.MultiSiteOrigin = false + ds.OriginShield = util.Ptr("myoriginshield") + ds.ProfileID = util.Ptr(49) + ds.ProfileName = util.Ptr("dsprofile") + ds.Protocol = util.Ptr(int(tc.DSProtocolHTTPToHTTPS)) + ds.AnonymousBlockingEnabled = false + ds.Active = tc.DSActiveStateActive + ds.RangeSliceBlockSize = util.Ptr(262144) + + dses := []DeliveryService{ds} + + dss := []DeliveryServiceServer{ + DeliveryServiceServer{ + Server: server.ID, + DeliveryService: *ds.ID, + }, + } + + dsRegexes := []tc.DeliveryServiceRegexes{ + tc.DeliveryServiceRegexes{ + DSName: ds.XMLID, + Regexes: []tc.DeliveryServiceRegex{ + tc.DeliveryServiceRegex{ + Type: string(tc.DSMatchTypeHostRegex), + SetNumber: 0, + Pattern: `myliteralpattern__http__foo`, + }, + }, + }, + } + + serverParams := []tc.ParameterV5{ + tc.ParameterV5{ + Name: "trafficserver", + ConfigFile: "package", + Value: "9", + Profiles: []byte(`["global"]`), + }, + tc.ParameterV5{ + Name: "serverpkgval", + ConfigFile: "package", + Value: "serverpkgval __HOSTNAME__ foo", + Profiles: []byte(server.Profiles[0]), + }, + tc.ParameterV5{ + Name: "dscp_remap_no", + ConfigFile: "package", + Value: "notused", + Profiles: []byte(server.Profiles[0]), + }, + } + + remapConfigParams := []tc.ParameterV5{ tc.ParameterV5{ Name: "cache_range_requests.pparam", ConfigFile: "remap.config", @@ -5826,7 +5959,7 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { tc.ParameterV5{ Name: "cache_range_requests.pparam", ConfigFile: "remap.config", - Value: "", + Value: selfHealParam, Profiles: []byte(`["dsprofile"]`), }, } @@ -5877,6 +6010,161 @@ func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) } + if strings.Contains(remapLine, "--consider-ims") { + t.Errorf("expected remap on edge server with ds slice range request handling and '%s' param to not contain cache_range_requests plugin arg --consider-ims, actual '%v'", selfHealParam, txt) + } + + if !strings.Contains(remapLine, "--no-modify-cachekey") { + t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --no-modify-cachekey, actual '%v'", txt) + } + + if !strings.Contains(remapLine, "pparam=--blockbytes=262144") { + t.Errorf("expected remap on edge server with ds slice range request handling to contain block size for the slice plugin, actual '%v'", txt) + } + for _, word := range words { + if word == "@pparam=" { + t.Errorf("expected remap on edge server with empty 'cache_range_requests.pparam' to be skipped and not have empty '@pparam=' on remapline, actual %s", txt) + } + } +} + +func TestMakeRemapDotConfigEdgeRangeRequestSlicePparam(t *testing.T) { + hdr := "myHeaderComment" + + server := makeTestRemapServer() + server.Type = "EDGE" + servers := []Server{} + + ds := DeliveryService{} + ds.ID = util.Ptr(48) + dsType := "HTTP_LIVE_NATNL" + ds.Type = &dsType + ds.OrgServerFQDN = util.Ptr("origin.example.test") + ds.MidHeaderRewrite = util.Ptr("") + ds.RangeRequestHandling = util.Ptr(tc.RangeRequestHandlingSlice) + ds.RemapText = util.Ptr("myremaptext") + ds.EdgeHeaderRewrite = nil + ds.SigningAlgorithm = util.Ptr("foo") + ds.XMLID = "mydsname" + ds.QStringIgnore = util.Ptr(int(tc.QueryStringIgnoreIgnoreInCacheKeyAndPassUp)) + ds.RegexRemap = util.Ptr("") + ds.FQPacingRate = util.Ptr(0) + ds.DSCP = 0 + ds.RoutingName = "myroutingname" + ds.MultiSiteOrigin = false + ds.OriginShield = util.Ptr("myoriginshield") + ds.ProfileID = util.Ptr(49) + ds.ProfileName = util.Ptr("dsprofile") + ds.Protocol = util.Ptr(int(tc.DSProtocolHTTPToHTTPS)) + ds.AnonymousBlockingEnabled = false + ds.Active = tc.DSActiveStateActive + ds.RangeSliceBlockSize = util.Ptr(262144) + + dses := []DeliveryService{ds} + + dss := []DeliveryServiceServer{ + DeliveryServiceServer{ + Server: server.ID, + DeliveryService: *ds.ID, + }, + } + + dsRegexes := []tc.DeliveryServiceRegexes{ + tc.DeliveryServiceRegexes{ + DSName: ds.XMLID, + Regexes: []tc.DeliveryServiceRegex{ + tc.DeliveryServiceRegex{ + Type: string(tc.DSMatchTypeHostRegex), + SetNumber: 0, + Pattern: `myliteralpattern__http__foo`, + }, + }, + }, + } + + serverParams := []tc.ParameterV5{ + tc.ParameterV5{ + Name: "trafficserver", + ConfigFile: "package", + Value: "9", + Profiles: []byte(`["global"]`), + }, + tc.ParameterV5{ + Name: "serverpkgval", + ConfigFile: "package", + Value: "serverpkgval __HOSTNAME__ foo", + Profiles: []byte(server.Profiles[0]), + }, + tc.ParameterV5{ + Name: "dscp_remap_no", + ConfigFile: "package", + Value: "notused", + Profiles: []byte(server.Profiles[0]), + }, + } + + remapConfigParams := []tc.ParameterV5{ + tc.ParameterV5{ + Name: "cache_range_requests.pparam", + ConfigFile: "remap.config", + Value: "--no-modify-cachekey", + Profiles: []byte(`["dsprofile"]`), + }, + tc.ParameterV5{ + Name: "not_location", + ConfigFile: "cachekey.config", + Value: "notinconfig", + Profiles: []byte(`["global"]`), + }, + } + + cdn := &tc.CDNV5{ + DomainName: "cdndomain.example", + Name: "my-cdn-name", + } + + topologies := []tc.TopologyV5{} + cgs := []tc.CacheGroupNullableV5{} + serverCapabilities := map[int]map[ServerCapability]struct{}{} + dsRequiredCapabilities := map[int]map[ServerCapability]struct{}{} + configDir := `/opt/trafficserver/etc/trafficserver` + + cfg, err := MakeRemapDotConfig(server, servers, dses, dss, dsRegexes, serverParams, cdn, remapConfigParams, topologies, cgs, serverCapabilities, dsRequiredCapabilities, configDir, &RemapDotConfigOpts{HdrComment: hdr}) + if err != nil { + t.Fatal(err) + } + txt := cfg.Text + + txt = strings.TrimSpace(txt) + + testComment(t, txt, hdr) + + txtLines := strings.Split(txt, "\n") + + if len(txtLines) != 3 { // comment, blank, and remap + t.Fatalf("expected a comment header, a blank line, and 1 remaps from HTTP_TO_HTTPS DS, actual: '%v' count %v", txt, len(txtLines)) + } + + remapLine := txtLines[2] + t.Log(remapLine) + words := strings.Fields(remapLine) + + if !strings.HasPrefix(remapLine, "map") { + t.Errorf("expected to start with 'map', actual '%v'", txt) + } + + if 1 != strings.Count(remapLine, "cachekey.so") { + t.Errorf("expected remap on edge server to contain a single cachekey plugin, actual '%v'", txt) + } + + if !strings.Contains(remapLine, "slice.so") { + t.Errorf("expected remap on edge server with ds slice range request handling to contain background fetch plugin, actual '%v'", txt) + } + + if !strings.Contains(remapLine, "cache_range_requests.so") { + t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin, actual '%v'", txt) + } + if !strings.Contains(remapLine, "--consider-ims") { t.Errorf("expected remap on edge server with ds slice range request handling to contain cache_range_requests plugin arg --consider-ims, actual '%v'", txt) } From 5fb4b383e7b65d0380f93f2817ca8a53cce683ef Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Sep 2023 16:49:04 -0400 Subject: [PATCH 17/22] Added ability to remove auto self-healing for slice plugin --- lib/go-atscfg/remapdotconfig.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index f264aa51ee..4bff603bbf 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -75,6 +75,8 @@ const DefaultInnerRemapConfigTemplateString = DefaultLastRemapConfigTemplateStri type LineTemplates map[string]*mustache.Template var RemapLineTemplates = LineTemplates{} +var selfHealParam = `no_self_healing` +var noSelfHeal bool // This parses but also maintains a cache of parsed templates func (lts *LineTemplates) parse(templateString string) (*mustache.Template, error) { @@ -229,6 +231,10 @@ func classifyConfigParams(configParams []tc.ParameterV5) map[string][]tc.Paramet key := param.ConfigFile if "remap.config" == key { key = param.Name + if param.Value == selfHealParam { + noSelfHeal = true + continue + } } configParamMap[key] = append(configParamMap[key], param) } @@ -410,6 +416,7 @@ func getServerConfigRemapDotConfigForMid( cachekeyArgs = getQStringIgnoreRemap(atsMajorVersion) } + noSelfHeal = false dsConfigParamsMap := map[string][]tc.ParameterV5{} if nil != ds.ProfileID { dsConfigParamsMap = classifyConfigParams(profilesConfigParams[*ds.ProfileID]) @@ -424,12 +431,9 @@ func getServerConfigRemapDotConfigForMid( } if ds.RangeRequestHandling != nil && (*ds.RangeRequestHandling == tc.RangeRequestHandlingCacheRangeRequest || *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice) { - rqParam := paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) - remapTags.RangeRequests = `@plugin=cache_range_requests.so` - if rqParam != "" { - remapTags.RangeRequests += rqParam - } - if !strings.Contains(remapTags.RangeRequests, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && rqParam != "" { + 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") && !noSelfHeal { remapTags.RangeRequests += ` @pparam=--consider-ims` } } @@ -703,6 +707,7 @@ func buildEdgeRemapLine( remapTags.HeaderRewrite = `@plugin=header_rewrite.so @pparam=` + edgeHeaderRewriteConfigFileName(ds.XMLID) } + noSelfHeal = false dsConfigParamsMap := classifyConfigParams(remapConfigParams) if ds.SigningAlgorithm != nil && *ds.SigningAlgorithm != "" { @@ -781,13 +786,9 @@ func buildEdgeRemapLine( } if crr { - rqParam := paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) - rangeReqTxt += `@plugin=cache_range_requests.so ` - if rqParam != "" { - rangeReqTxt += rqParam - //this check may seem excessive, but I want to be sure we don't have --consider-ims in remap twice - } else if !strings.Contains(rangeReqTxt, `@pparam=--consider-ims`) && *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && ds.RangeSliceBlockSize != nil { - rangeReqTxt += `@pparam=--consider-ims` + rangeReqTxt += `@plugin=cache_range_requests.so ` + paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) + if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && !strings.Contains(rangeReqTxt, "--consider-ims") && !noSelfHeal { + rangeReqTxt += ` @pparam=--consider-ims` } } } From 02996dd60219924b8efbbbe3a106bcbb9b29cb0a Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Sep 2023 17:50:34 -0400 Subject: [PATCH 18/22] updated deliveryservice documentation --- docs/source/overview/delivery_services.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/overview/delivery_services.rst b/docs/source/overview/delivery_services.rst index fe4b26d7c8..0c949812a0 100644 --- a/docs/source/overview/delivery_services.rst +++ b/docs/source/overview/delivery_services.rst @@ -676,7 +676,7 @@ Describes how HTTP "Range Requests" should be handled by the Delivery Service at 3 Use the `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. + .. 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 From 390c89e0377d14f840b6b214df8e9ec66bdaf053 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Mon, 25 Sep 2023 15:08:14 -0400 Subject: [PATCH 19/22] removed git merge lines --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0564768041..38b8a05112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [8.0.0] - 2023-09-20 ### Added -<<<<<<< HEAD - [#7672](https://github.com/apache/trafficcontrol/pull/7672) *Traffic Control Health Client*: Added peer monitor flag while using `strategies.yaml`. - [#7609](https://github.com/apache/trafficcontrol/pull/7609) *Traffic Portal*: Added Scope Query Param to SSO login. - [#7450](https://github.com/apache/trafficcontrol/pull/7450) *Traffic Ops*: Removed hypnotoad section and added listen field to traffic_ops_golang section in order to simplify cdn config. From 6bb58904b4edeeaddc61dc743303d5d52e41ac62 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Mon, 25 Sep 2023 15:50:10 -0400 Subject: [PATCH 20/22] updated to use positive bools rather than negative --- lib/go-atscfg/remapdotconfig.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index 4bff603bbf..d66bc7b13f 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -71,12 +71,12 @@ 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 var RemapLineTemplates = LineTemplates{} -var selfHealParam = `no_self_healing` -var noSelfHeal bool +var selfHeal = true // This parses but also maintains a cache of parsed templates func (lts *LineTemplates) parse(templateString string) (*mustache.Template, error) { @@ -232,7 +232,7 @@ func classifyConfigParams(configParams []tc.ParameterV5) map[string][]tc.Paramet if "remap.config" == key { key = param.Name if param.Value == selfHealParam { - noSelfHeal = true + selfHeal = false continue } } @@ -416,7 +416,7 @@ func getServerConfigRemapDotConfigForMid( cachekeyArgs = getQStringIgnoreRemap(atsMajorVersion) } - noSelfHeal = false + selfHeal = true dsConfigParamsMap := map[string][]tc.ParameterV5{} if nil != ds.ProfileID { dsConfigParamsMap = classifyConfigParams(profilesConfigParams[*ds.ProfileID]) @@ -433,7 +433,7 @@ func getServerConfigRemapDotConfigForMid( if ds.RangeRequestHandling != nil && (*ds.RangeRequestHandling == tc.RangeRequestHandlingCacheRangeRequest || *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice) { 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") && !noSelfHeal { + if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && !strings.Contains(crrParam, "--consider-ims") && selfHeal { remapTags.RangeRequests += ` @pparam=--consider-ims` } } @@ -707,7 +707,7 @@ func buildEdgeRemapLine( remapTags.HeaderRewrite = `@plugin=header_rewrite.so @pparam=` + edgeHeaderRewriteConfigFileName(ds.XMLID) } - noSelfHeal = false + selfHeal = true dsConfigParamsMap := classifyConfigParams(remapConfigParams) if ds.SigningAlgorithm != nil && *ds.SigningAlgorithm != "" { @@ -787,7 +787,7 @@ func buildEdgeRemapLine( if crr { rangeReqTxt += `@plugin=cache_range_requests.so ` + paramsStringFor(dsConfigParamsMap["cache_range_requests.pparam"], &warnings) - if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && !strings.Contains(rangeReqTxt, "--consider-ims") && !noSelfHeal { + if *ds.RangeRequestHandling == tc.RangeRequestHandlingSlice && !strings.Contains(rangeReqTxt, "--consider-ims") && selfHeal { rangeReqTxt += ` @pparam=--consider-ims` } } From bb75b6fcbd1cf65839973390d36c82f059d7c8e9 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 26 Sep 2023 14:16:05 -0400 Subject: [PATCH 21/22] changed scope of selfHeal param --- lib/go-atscfg/remapdotconfig.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/go-atscfg/remapdotconfig.go b/lib/go-atscfg/remapdotconfig.go index d66bc7b13f..945417a834 100644 --- a/lib/go-atscfg/remapdotconfig.go +++ b/lib/go-atscfg/remapdotconfig.go @@ -76,7 +76,6 @@ const selfHealParam = `no_self_healing` type LineTemplates map[string]*mustache.Template var RemapLineTemplates = LineTemplates{} -var selfHeal = true // This parses but also maintains a cache of parsed templates func (lts *LineTemplates) parse(templateString string) (*mustache.Template, error) { @@ -225,8 +224,9 @@ func MakeRemapDotConfig( // This sticks the DS parameters in a map. // remap.config parameters use ".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 { @@ -238,7 +238,7 @@ func classifyConfigParams(configParams []tc.ParameterV5) map[string][]tc.Paramet } configParamMap[key] = append(configParamMap[key], param) } - return configParamMap + return configParamMap, selfHeal } // For general .pparam parameters. @@ -416,10 +416,10 @@ func getServerConfigRemapDotConfigForMid( cachekeyArgs = getQStringIgnoreRemap(atsMajorVersion) } - selfHeal = true + 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 { @@ -707,8 +707,7 @@ func buildEdgeRemapLine( remapTags.HeaderRewrite = `@plugin=header_rewrite.so @pparam=` + edgeHeaderRewriteConfigFileName(ds.XMLID) } - selfHeal = true - dsConfigParamsMap := classifyConfigParams(remapConfigParams) + dsConfigParamsMap, selfHeal := classifyConfigParams(remapConfigParams) if ds.SigningAlgorithm != nil && *ds.SigningAlgorithm != "" { if *ds.SigningAlgorithm == tc.SigningAlgorithmURLSig { From c9b045cdd96c4f8d455fa0e16141c917ec476c6a Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 26 Sep 2023 14:37:31 -0400 Subject: [PATCH 22/22] changed to error instead of fatal --- lib/go-atscfg/remapdotconfig_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/go-atscfg/remapdotconfig_test.go b/lib/go-atscfg/remapdotconfig_test.go index b47fbd0904..2a9502d4f6 100644 --- a/lib/go-atscfg/remapdotconfig_test.go +++ b/lib/go-atscfg/remapdotconfig_test.go @@ -1692,7 +1692,7 @@ func TestMakeRemapDotConfigMidSlicePluginRangeRequestHandling(t *testing.T) { txt = strings.TrimSpace(txt) if !strings.Contains(txt, "@pparam=--consider-ims") { - t.Fatalf("expected '--consider-ims' param with 'cache_range_requests.so' when using slice plugin to enable self healing, actual: %s", txt) + t.Errorf("expected '--consider-ims' param with 'cache_range_requests.so' when using slice plugin to enable self healing, actual: %s", txt) } testComment(t, txt, hdr)