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 2022/01/28 23:55:37 UTC

[GitHub] [trafficcontrol] traeak opened a new pull request #6529: Add DS parameter LastRawRemap to allow raw text in remap.config

traeak opened a new pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529


   <!--
   Thank you for contributing! Please be sure to read our contribution guidelines: https://github.com/apache/trafficcontrol/blob/master/CONTRIBUTING.md
   If this closes or relates to an existing issue, please reference it using one of the following:
   
   Closes: #ISSUE
   Related: #ISSUE
   
   If this PR fixes a security vulnerability, DO NOT submit! Instead, contact
   the Apache Traffic Control Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://apache.org/security regarding vulnerability disclosure.
   -->
   
   
   <!-- **^ Add meaningful description above** --><hr/>
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this PR.
   Feel free to add the name of a tool or script that is affected but not on the list.
   -->
   - Documentation
   - Traffic Control Cache Config (T3C, formerly ORT)
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your PR.
   If your PR has tests (and most should), provide the steps needed to run the tests.
   If not, please provide step-by-step instructions to test the PR manually and explain why your PR does not need tests. -->
   
   Create a Parameter named LastRawRemap with config file remap.config and anything in value.  For MID/Last configuration, pull  configs with t3c and note the contents appended to remap.config
   
   ## If this is a bugfix, which Traffic Control versions contained the bug?
   <!-- Delete this section if the PR is not a bugfix, or if the bug is only in the master branch.
   Examples:
   - 5.1.2
   - 5.1.3 (RC1)
    -->
   
   
   ## PR submission checklist
   - [x] This PR has tests <!-- If not, please delete this text and explain why this PR does not need tests. -->
   - [x] This PR has documentation <!-- If not, please delete this text and explain why this PR does not need documentation. -->
   - [x] This PR has a CHANGELOG.md entry <!-- A fix for a bug from an ATC release, an improvement, or a new feature should have a changelog entry. -->
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://apache.org/security) for details)
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 merged pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
ocket8888 merged pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796027787



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -364,9 +413,17 @@ func getServerConfigRemapDotConfigForEdge(
 				if ds.ProfileID != nil {
 					profileremapConfigParams = profilesRemapConfigParams[*ds.ProfileID]
 				}
-				remapWarns := []string{}
-				remapText, remapWarns, err = buildEdgeRemapLine(atsMajorVersion, server, serverPackageParamData, remapText, ds, line.From, line.To, profileremapConfigParams, cacheGroups, nameTopologies)
+				var remapWarns []string
+				var dsLines RemapLines
+				dsLines, remapWarns, err = buildEdgeRemapLine(atsMajorVersion, server, serverPackageParamData, remapText, ds, line.From, line.To, profileremapConfigParams, cacheGroups, nameTopologies)
 				warnings = append(warnings, remapWarns...)
+				remapText = dsLines.Text
+
+				// Add to pre/post remap lines if this is last tier
+				if 0 < len(dsLines.Pre) || 0 < len(dsLines.Post) {

Review comment:
       Nitpick: This C idiom is confusing and unnecessary in Go




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] traeak commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
traeak commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796131853



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -364,9 +413,17 @@ func getServerConfigRemapDotConfigForEdge(
 				if ds.ProfileID != nil {
 					profileremapConfigParams = profilesRemapConfigParams[*ds.ProfileID]
 				}
-				remapWarns := []string{}
-				remapText, remapWarns, err = buildEdgeRemapLine(atsMajorVersion, server, serverPackageParamData, remapText, ds, line.From, line.To, profileremapConfigParams, cacheGroups, nameTopologies)
+				var remapWarns []string
+				var dsLines RemapLines
+				dsLines, remapWarns, err = buildEdgeRemapLine(atsMajorVersion, server, serverPackageParamData, remapText, ds, line.From, line.To, profileremapConfigParams, cacheGroups, nameTopologies)
 				warnings = append(warnings, remapWarns...)
+				remapText = dsLines.Text
+
+				// Add to pre/post remap lines if this is last tier
+				if 0 < len(dsLines.Pre) || 0 < len(dsLines.Post) {

Review comment:
       Little goes on the left or smaller values on the left is a very consistent rule to follow.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796032312



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -289,16 +313,39 @@ func getServerConfigRemapDotConfigForMid(
 		if midRemap != "" {
 			midRemaps[remapFrom] = *ds.OrgServerFQDN + midRemap
 		}
+
+		// Any raw pre or post pend
+		dsPreRemaps, dsPostRemaps := lastPrePostRemapLinesFor(dsConfigParamsMap, *ds.XMLID)
+
+		// Add to pre/post remap lines if this is last tier
+		if 0 < len(dsPreRemaps) || 0 < len(dsPostRemaps) {

Review comment:
       Nitpick: `0<` isn't a Go idiom, harder to read and not necessary




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r798011839



##########
File path: docs/source/overview/profiles_and_parameters.rst
##########
@@ -621,6 +621,11 @@ The following plugins have support for adding args with following parameter Conf
 	| cachekey.pparam        | cachekey.pparam     | ``-o``                       | ``@pparam=-o``                       |
 	+------------------------+---------------------+------------------------------+--------------------------------------+
 
+In order to support difficult configurations at MID/LAST, a
+:term:`Delivery Service` profile parameter is available with parameters
+``LastRawRemapPre`` and ``LastRawRemapPost``, config file ``remap.config``
+and Value the raw remap lines.  The Value in this parameter will be pre
+or post pended to the end of ``remap.config``.

Review comment:
       New special Parameters should be their own sections like the others - this paragraph appears under the `records.config` ConfigFile section, but these Parameters are not related to Parameters with the ConfigFile `records.config`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796155908



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -289,16 +313,39 @@ func getServerConfigRemapDotConfigForMid(
 		if midRemap != "" {
 			midRemaps[remapFrom] = *ds.OrgServerFQDN + midRemap
 		}
+
+		// Any raw pre or post pend
+		dsPreRemaps, dsPostRemaps := lastPrePostRemapLinesFor(dsConfigParamsMap, *ds.XMLID)
+
+		// Add to pre/post remap lines if this is last tier
+		if 0 < len(dsPreRemaps) || 0 < len(dsPostRemaps) {
+			isLastCache, err := serverIsLastCacheForDS(server, &ds, nameTopologies, cacheGroups)
+			if err != nil {
+				warnings = append(warnings, "ds '"+*ds.XMLID+"' errors determining last tier "+err.Error())

Review comment:
       Looking at the code, it looks like the only way that function can fail, is if the data from TO is fundamentally broken.
   It's things like
   (1) The Server JSON has no CacheGroup
   (2) A Topology entry references an index that doesn't exist
   (3) A Topology references a CacheGroup name that doesn't exist.
   
   It's all fundamentally-broken-data kind of stuff. I vote fail the config gen, return an error.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] traeak commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
traeak commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796144036



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -289,16 +313,39 @@ func getServerConfigRemapDotConfigForMid(
 		if midRemap != "" {
 			midRemaps[remapFrom] = *ds.OrgServerFQDN + midRemap
 		}
+
+		// Any raw pre or post pend
+		dsPreRemaps, dsPostRemaps := lastPrePostRemapLinesFor(dsConfigParamsMap, *ds.XMLID)
+
+		// Add to pre/post remap lines if this is last tier
+		if 0 < len(dsPreRemaps) || 0 < len(dsPostRemaps) {
+			isLastCache, err := serverIsLastCacheForDS(server, &ds, nameTopologies, cacheGroups)
+			if err != nil {
+				warnings = append(warnings, "ds '"+*ds.XMLID+"' errors determining last tier "+err.Error())

Review comment:
       should it continue or fail?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796033355



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -289,16 +313,39 @@ func getServerConfigRemapDotConfigForMid(
 		if midRemap != "" {
 			midRemaps[remapFrom] = *ds.OrgServerFQDN + midRemap
 		}
+
+		// Any raw pre or post pend
+		dsPreRemaps, dsPostRemaps := lastPrePostRemapLinesFor(dsConfigParamsMap, *ds.XMLID)
+
+		// Add to pre/post remap lines if this is last tier
+		if 0 < len(dsPreRemaps) || 0 < len(dsPostRemaps) {
+			isLastCache, err := serverIsLastCacheForDS(server, &ds, nameTopologies, cacheGroups)
+			if err != nil {
+				warnings = append(warnings, "ds '"+*ds.XMLID+"' errors determining last tier "+err.Error())

Review comment:
       If this fails, it just keeps going and generates the line without the pre and post directives? I think the warning should probably say that, it's not clear from the warning that that happened.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796029725



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -401,14 +470,16 @@ func buildEdgeRemapLine(
 	remapConfigParams []tc.Parameter,
 	cacheGroups map[tc.CacheGroupName]tc.CacheGroupNullable,
 	nameTopologies map[TopologyName]tc.Topology,
-) (string, []string, error) {
+) (RemapLines, []string, error) {
 	warnings := []string{}
+	var remapLines RemapLines

Review comment:
       Nitpick: the cache config code generally tries to use the idiom of always declaring variables with `:=`. 
   There's no reason for Go to have multiple ways to declare variables, and IMO it's a slight readability improvement to always use `:=`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r796030542



##########
File path: lib/go-atscfg/remapdotconfig.go
##########
@@ -202,6 +202,28 @@ func cachekeyArgsFor(configParamsMap map[string][]tc.Parameter, warnings *[]stri
 	return
 }
 
+// Returns any pre or post raw remap lines

Review comment:
       Nitpick: this breaks GoDoc. Symbol comments should be complete sentences starting with the symbol name and including punctuation, e.g. `// lastPrePostRemapLinesFor returns any pre or post raw remap lines.`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] traeak commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
traeak commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r800708569



##########
File path: docs/source/overview/profiles_and_parameters.rst
##########
@@ -621,6 +621,11 @@ The following plugins have support for adding args with following parameter Conf
 	| cachekey.pparam        | cachekey.pparam     | ``-o``                       | ``@pparam=-o``                       |
 	+------------------------+---------------------+------------------------------+--------------------------------------+
 
+In order to support difficult configurations at MID/LAST, a
+:term:`Delivery Service` profile parameter is available with parameters
+``LastRawRemapPre`` and ``LastRawRemapPost``, config file ``remap.config``
+and Value the raw remap lines.  The Value in this parameter will be pre
+or post pended to the end of ``remap.config``.

Review comment:
       I'm confused.  This heading is under "remap.config" and is another DS parameter that modifies the remap.config.  I don't understand where it should go.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #6529: Add DS parameter LastRawRemap(Pre|Post) to allow raw text in remap.config

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #6529:
URL: https://github.com/apache/trafficcontrol/pull/6529#discussion_r800828819



##########
File path: docs/source/overview/profiles_and_parameters.rst
##########
@@ -621,6 +621,11 @@ The following plugins have support for adding args with following parameter Conf
 	| cachekey.pparam        | cachekey.pparam     | ``-o``                       | ``@pparam=-o``                       |
 	+------------------------+---------------------+------------------------------+--------------------------------------+
 
+In order to support difficult configurations at MID/LAST, a
+:term:`Delivery Service` profile parameter is available with parameters
+``LastRawRemapPre`` and ``LastRawRemapPost``, config file ``remap.config``
+and Value the raw remap lines.  The Value in this parameter will be pre
+or post pended to the end of ``remap.config``.

Review comment:
       That's my mistake, it's not under `records.config`, I don't know why I thought it was




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org