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 2020/12/03 00:38:16 UTC

[GitHub] [trafficcontrol] srijeet0406 opened a new pull request #5345: Add a new field to the Delivery Service to accommodate for `max_request_header_size`

srijeet0406 opened a new pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345


   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [x] This PR is not related to any Issue <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   - Documentation
   - Traffic Control Client <!-- Please specify which; e.g. 'Python', 'Go', 'Java' -->
   - Traffic Ops
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   
   Run the `goose` migrations for both dev and test
   Make sure all the unit tests/ API tests pass
   Try creating a new DS in TP, and make sure the `Max Request Header Size` field shows up.
   Make sure you can also add and remove that field from the TP DS table view.
   Try updating that field and make sure that the updates take effect.
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   - master (1df853c8)
   - 4.0.0
   - 4.0.1 (RC1)
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   
   - master
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [x] This PR includes tests
   - [x] This PR includes documentation
   - [x] This PR includes an update to CHANGELOG.md
   - [x] This PR includes any and all required license headers
   - [x] This PR includes database migrations
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   ## Additional Information
   <!-- If you would like to include any additional information on the PR for
   potential reviewers please put it here.
   
   Some examples of this would be:
   
   - Before and after screenshots/gifs of the Traffic Portal if it is affected
   - Links to other dependent Pull Requests
   - References to relevant context (e.g. new/updates to dependent libraries,
   mailing list records, blueprints)
   
   Feel free to leave this section blank (or, preferably, delete it entirely).
   -->
   
   <!--
   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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747719368


   @srijeet0406 - since you changed traffic_portal_properties.json, you'll need to make a change like this to account for the new field: https://github.com/apache/trafficcontrol/pull/5379/commits/a1e504c6468f679d077c1192821ab498b0899be5


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747727160


   > If you mean from the API perspective, it will sanitize a null value to the default.
   
   Oh i see. so maybe the tooltip should say something like "leaving this value empty will result in the default: 131072". By the way what's the reasoning behind the 131072?


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747722423


   > ![image](https://user-images.githubusercontent.com/251272/102547605-ad22f500-4076-11eb-9de7-afd603cac134.png)
   > 
   > Think you could expand this to explain what leaving it blank/null will do? For example, if empty is there a) no max or b) the global max (if defined) kicks in?
   
   It actually cannot be empty, the min value of 1 will always be needed.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -428,8 +445,8 @@ func (ds *DeliveryServiceNullable) validateTypeFields(tx *sql.Tx) error {
 					if *ds.RangeRequestHandling == 3 {
 						return validation.Validate(ds.RangeSliceBlockSize, validation.Required,
 							// Per Slice Plugin implementation
-							validation.Min(262144),   // 256KiB
-							validation.Max(33554432), // 32MiB
+							validation.Min(MinRangeSliceBlockSize), // 256KiB

Review comment:
       We should do some basic validation for `MaxRequestHeaderBytes` as well -- like it should be greater than zero. 

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -699,62 +759,301 @@ WHERE
 }
 
 func updateV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS *tc.DeliveryServiceNullableV15) (*tc.DeliveryServiceNullableV15, int, error, error) {
-	dsV30 := tc.DeliveryServiceNullableV30{DeliveryServiceNullableV15: *reqDS}
+	dsV31 := tc.DeliveryServiceV31{
+		DeliveryServiceV30: tc.DeliveryServiceV30{
+			DeliveryServiceNullableV15: *reqDS,
+		},
+	}
 	// query the DB for existing 3.0 fields in order to "upgrade" this 1.5 request into a 3.0 request
 	query := `
 SELECT
   ds.topology,
   ds.first_header_rewrite,
   ds.inner_header_rewrite,
   ds.last_header_rewrite,
-  ds.service_category
+  ds.service_category,
+  ds.max_request_header_bytes
 FROM
   deliveryservice ds
 WHERE
   ds.id = $1`
 	if err := inf.Tx.Tx.QueryRow(query, *reqDS.ID).Scan(
-		&dsV30.Topology,
-		&dsV30.FirstHeaderRewrite,
-		&dsV30.InnerHeaderRewrite,
-		&dsV30.LastHeaderRewrite,
-		&dsV30.ServiceCategory,
+		&dsV31.Topology,
+		&dsV31.FirstHeaderRewrite,
+		&dsV31.InnerHeaderRewrite,
+		&dsV31.LastHeaderRewrite,
+		&dsV31.ServiceCategory,
+		&dsV31.MaxRequestHeaderBytes,
 	); err != nil {
 		if err == sql.ErrNoRows {
-			return nil, http.StatusNotFound, fmt.Errorf("delivery service ID %d not found", *dsV30.ID), nil
+			return nil, http.StatusNotFound, fmt.Errorf("delivery service ID %d not found", *dsV31.ID), nil
 		}
-		return nil, http.StatusInternalServerError, nil, fmt.Errorf("querying delivery service ID %d: %s", *dsV30.ID, err.Error())
+		return nil, http.StatusInternalServerError, nil, fmt.Errorf("querying delivery service ID %d: %s", *dsV31.ID, err.Error())
 	}
-	res, status, userErr, sysErr := updateV30(w, r, inf, &dsV30)
+	res, status, userErr, sysErr := updateV31(w, r, inf, &dsV31)
 	if res != nil {
 		return &res.DeliveryServiceNullableV15, status, userErr, sysErr
 	}
 	return nil, status, userErr, sysErr
 }
 
-func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.DeliveryServiceNullableV30) (*tc.DeliveryServiceNullableV30, int, error, error) {
+func updateV31(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.DeliveryServiceV31) (*tc.DeliveryServiceV31, int, error, error) {
 	tx := inf.Tx.Tx
 	user := inf.User
+	dsNullableV30 := tc.DeliveryServiceNullableV30(*ds)
+	if err := dsNullableV30.Validate(tx); err != nil {
+		return nil, http.StatusBadRequest, errors.New("invalid request: " + err.Error()), nil
+	}
+
+	if authorized, err := isTenantAuthorized(inf, &dsNullableV30); err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("checking tenant: " + err.Error())
+	} else if !authorized {
+		return nil, http.StatusForbidden, errors.New("not authorized on this tenant"), nil
+	}
+
+	if dsNullableV30.XMLID == nil {
+		return nil, http.StatusBadRequest, errors.New("missing xml_id"), nil
+	}
+	if dsNullableV30.ID == nil {
+		return nil, http.StatusBadRequest, errors.New("missing id"), nil
+	}
+
+	dsType, ok, err := getDSType(tx, *dsNullableV30.XMLID)
+	if !ok {
+		return nil, http.StatusNotFound, errors.New("delivery service '" + *dsNullableV30.XMLID + "' not found"), nil
+	}
+	if err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("getting delivery service type during update: " + err.Error())
+	}
 
-	if err := ds.Validate(tx); err != nil {
+	// oldHostName will be used to determine if SSL Keys need updating - this will be empty if the DS doesn't have SSL keys, because DS types without SSL keys may not have regexes, and thus will fail to get a host name.
+	oldHostName := ""
+	oldCDNName := ""
+	oldRoutingName := ""
+	if dsType.HasSSLKeys() {
+		oldHostName, oldCDNName, oldRoutingName, err = getOldDetails(*dsNullableV30.ID, tx)
+		if err != nil {
+			return nil, http.StatusInternalServerError, nil, errors.New("getting existing delivery service hostname: " + err.Error())
+		}
+	}
+
+	// TODO change DeepCachingType to implement sql.Valuer and sql.Scanner, so sqlx struct scan can be used.
+	deepCachingType := tc.DeepCachingType("").String()
+	if dsNullableV30.DeepCachingType != nil {
+		deepCachingType = dsNullableV30.DeepCachingType.String() // necessary, because DeepCachingType's default needs to insert the string, not "", and Query doesn't call .String().
+	}
+
+	userErr, sysErr, errCode := api.CheckIfUnModified(r.Header, inf.Tx, *dsNullableV30.ID, "deliveryservice")
+	if userErr != nil || sysErr != nil {
+		return nil, errCode, userErr, sysErr
+	}
+
+	if errCode, userErr, sysErr = dbhelpers.CheckTopology(inf.Tx, dsNullableV30); userErr != nil || sysErr != nil {
+		return nil, errCode, userErr, sysErr
+	}
+
+	if dsNullableV30.Topology != nil {
+		requiredCapabilities, err := dbhelpers.GetDSRequiredCapabilitiesFromID(*dsNullableV30.ID, tx)
+		if err != nil {
+			return nil, http.StatusInternalServerError, nil, errors.New("getting existing DS required capabilities: " + err.Error())
+		}
+		if len(requiredCapabilities) > 0 {
+			if userErr, sysErr, status := EnsureTopologyBasedRequiredCapabilities(tx, *dsNullableV30.ID, *dsNullableV30.Topology, requiredCapabilities); userErr != nil || sysErr != nil {
+				return nil, status, userErr, sysErr
+			}
+		}
+	}
+
+	resultRows, err := tx.Query(updateDSQuery(),
+		&dsNullableV30.Active,
+		&dsNullableV30.CacheURL,
+		&dsNullableV30.CCRDNSTTL,
+		&dsNullableV30.CDNID,
+		&dsNullableV30.CheckPath,
+		&deepCachingType,
+		&dsNullableV30.DisplayName,
+		&dsNullableV30.DNSBypassCNAME,
+		&dsNullableV30.DNSBypassIP,
+		&dsNullableV30.DNSBypassIP6,
+		&dsNullableV30.DNSBypassTTL,
+		&dsNullableV30.DSCP,
+		&dsNullableV30.EdgeHeaderRewrite,
+		&dsNullableV30.GeoLimitRedirectURL,
+		&dsNullableV30.GeoLimit,
+		&dsNullableV30.GeoLimitCountries,
+		&dsNullableV30.GeoProvider,
+		&dsNullableV30.GlobalMaxMBPS,
+		&dsNullableV30.GlobalMaxTPS,
+		&dsNullableV30.FQPacingRate,
+		&dsNullableV30.HTTPBypassFQDN,
+		&dsNullableV30.InfoURL,
+		&dsNullableV30.InitialDispersion,
+		&dsNullableV30.IPV6RoutingEnabled,
+		&dsNullableV30.LogsEnabled,
+		&dsNullableV30.LongDesc,
+		&dsNullableV30.LongDesc1,
+		&dsNullableV30.LongDesc2,
+		&dsNullableV30.MaxDNSAnswers,
+		&dsNullableV30.MidHeaderRewrite,
+		&dsNullableV30.MissLat,
+		&dsNullableV30.MissLong,
+		&dsNullableV30.MultiSiteOrigin,
+		&dsNullableV30.OriginShield,
+		&dsNullableV30.ProfileID,
+		&dsNullableV30.Protocol,
+		&dsNullableV30.QStringIgnore,
+		&dsNullableV30.RangeRequestHandling,
+		&dsNullableV30.RegexRemap,
+		&dsNullableV30.RegionalGeoBlocking,
+		&dsNullableV30.RemapText,
+		&dsNullableV30.RoutingName,
+		&dsNullableV30.SigningAlgorithm,
+		&dsNullableV30.SSLKeyVersion,
+		&dsNullableV30.TenantID,
+		&dsNullableV30.TRRequestHeaders,
+		&dsNullableV30.TRResponseHeaders,
+		&dsNullableV30.TypeID,
+		&dsNullableV30.XMLID,
+		&dsNullableV30.AnonymousBlockingEnabled,
+		&dsNullableV30.ConsistentHashRegex,
+		&dsNullableV30.MaxOriginConnections,
+		&dsNullableV30.EcsEnabled,
+		&dsNullableV30.RangeSliceBlockSize,
+		&dsNullableV30.Topology,
+		&dsNullableV30.FirstHeaderRewrite,
+		&dsNullableV30.InnerHeaderRewrite,
+		&dsNullableV30.LastHeaderRewrite,
+		&dsNullableV30.ServiceCategory,
+		&dsNullableV30.MaxRequestHeaderBytes,
+		&dsNullableV30.ID)
+
+	if err != nil {
+		usrErr, sysErr, code := api.ParseDBError(err)
+		return nil, code, usrErr, sysErr
+	}
+	defer resultRows.Close()
+	if !resultRows.Next() {
+		return nil, http.StatusNotFound, errors.New("no delivery service found with this id"), nil
+	}
+	lastUpdated := tc.TimeNoMod{}
+	if err := resultRows.Scan(&lastUpdated); err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("scan updating delivery service: " + err.Error())
+	}
+	if resultRows.Next() {
+		xmlID := ""
+		if dsNullableV30.XMLID != nil {
+			xmlID = *dsNullableV30.XMLID
+		}
+		return nil, http.StatusInternalServerError, nil, errors.New("updating delivery service " + xmlID + ": " + "this update affected too many rows: > 1")
+	}
+
+	if dsNullableV30.ID == nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("missing id after update")
+	}
+	if dsNullableV30.XMLID == nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("missing xml_id after update")
+	}
+	if dsNullableV30.TypeID == nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("missing type after update")
+	}
+	if dsNullableV30.RoutingName == nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("missing routing name after update")
+	}
+	newDSType, err := getTypeFromID(*dsNullableV30.TypeID, tx)
+	if err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("getting delivery service type after update: " + err.Error())
+	}
+	dsNullableV30.Type = &newDSType
+
+	cdnDomain, err := getCDNDomain(*dsNullableV30.ID, tx) // need to get the domain again, in case it changed.
+	if err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("getting CDN domain after update: " + err.Error())
+	}
+
+	matchLists, err := GetDeliveryServicesMatchLists([]string{*dsNullableV30.XMLID}, tx)
+	if err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("getting matchlists after update: " + err.Error())
+	}
+	if ml, ok := matchLists[*dsNullableV30.XMLID]; !ok {
+		return nil, http.StatusInternalServerError, nil, errors.New("no matchlists after update")
+	} else {
+		dsNullableV30.MatchList = &ml
+	}
+
+	// newHostName will be used to determine if SSL Keys need updating - this will be empty if the DS doesn't have SSL keys, because DS types without SSL keys may not have regexes, and thus will fail to get a host name.
+	newHostName := ""
+	newCDNName := ""
+	if dsType.HasSSLKeys() {
+		newCDNName, err = getCDNName(*dsNullableV30.CDNID, tx)
+		newHostName, err = getHostName(dsNullableV30.Protocol, *dsNullableV30.Type, *dsNullableV30.RoutingName, *dsNullableV30.MatchList, cdnDomain)
+		if err != nil {
+			return nil, http.StatusInternalServerError, nil, errors.New("getting cdnname/hostname after update: " + err.Error())
+		}
+	}
+
+	if newDSType.HasSSLKeys() && (oldHostName != newHostName || oldCDNName != newCDNName || oldRoutingName != *dsNullableV30.RoutingName) {
+		return nil, http.StatusForbidden, nil, errors.New("delivery service has ssl keys that cannot be automatically changed")
+	}
+
+	if err := EnsureParams(tx, *dsNullableV30.ID, *dsNullableV30.XMLID, dsNullableV30.EdgeHeaderRewrite, dsNullableV30.MidHeaderRewrite, dsNullableV30.RegexRemap, dsNullableV30.CacheURL, dsNullableV30.SigningAlgorithm, newDSType, dsNullableV30.MaxOriginConnections); err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("ensuring dsNullableV30 parameters:: " + err.Error())
+	}
+
+	if err := updatePrimaryOrigin(tx, user, dsNullableV30); err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("updating delivery service: " + err.Error())
+	}
+
+	dsNullableV30.LastUpdated = &lastUpdated
+
+	// the update may change or delete the query params -- delete existing and re-add if any provided
+	q := `DELETE FROM deliveryservice_consistent_hash_query_param WHERE deliveryservice_id = $1`
+	if res, err := tx.Exec(q, *dsNullableV30.ID); err != nil {
+		return nil, http.StatusInternalServerError, nil, fmt.Errorf("deleting consistent hash query params for dsNullableV30 %s: %s", *dsNullableV30.XMLID, err.Error())
+	} else if c, _ := res.RowsAffected(); c > 0 {
+		api.CreateChangeLogRawTx(api.ApiChange, "DS: "+*dsNullableV30.XMLID+", ID: "+strconv.Itoa(*dsNullableV30.ID)+", ACTION: Deleted "+strconv.FormatInt(c, 10)+" consistent hash query params", user, tx)
+	}
+
+	if c, err := createConsistentHashQueryParams(tx, *dsNullableV30.ID, dsNullableV30.ConsistentHashQueryParams); err != nil {
+		usrErr, sysErr, code := api.ParseDBError(err)
+		return nil, code, usrErr, sysErr
+	} else {
+		api.CreateChangeLogRawTx(api.ApiChange, "DS: "+*dsNullableV30.XMLID+", ID: "+strconv.Itoa(*dsNullableV30.ID)+", ACTION: Created "+strconv.Itoa(c)+" consistent hash query params", user, tx)
+	}
+
+	if err := api.CreateChangeLogRawErr(api.ApiChange, "Updated dsNullableV30: "+*dsNullableV30.XMLID+" id: "+strconv.Itoa(*dsNullableV30.ID), user, tx); err != nil {
+		return nil, http.StatusInternalServerError, nil, errors.New("writing change log entry: " + err.Error())
+	}
+	ds = (*tc.DeliveryServiceV31)(&dsNullableV30)
+	return ds, http.StatusOK, nil, nil
+}
+
+func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.DeliveryServiceV30) (*tc.DeliveryServiceV30, int, error, error) {

Review comment:
       Per my earlier comment above, this function should look just like `createV30`, except with the DB query that reads the existing value of the new field.

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -32,6 +32,9 @@ import (
 */
 
 const DefaultRoutingName = "cdn"
+const DefaultMaxHeaderSize = 131072

Review comment:
       we should rename this `DefaultMaxRequestHeaderBytes` to match the new name

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -239,91 +261,101 @@ func createV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS t
 }
 
 // create creates the given ds in the database, and returns the DS with its id and other fields created on insert set. On error, the HTTP status code, user error, and system error are returned. The status code SHOULD NOT be used, if both errors are nil.
-func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.DeliveryServiceNullableV30) (*tc.DeliveryServiceNullableV30, int, error, error) {
+func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.DeliveryServiceV30) (*tc.DeliveryServiceV30, int, error, error) {
+	dsV31 := tc.DeliveryServiceV31{DeliveryServiceV30: ds}
+	res, status, userErr, sysErr := createV31(w, r, inf, dsV31)
+	if res != nil {
+		return &res.DeliveryServiceV30, status, userErr, sysErr
+	}
+	return nil, status, userErr, sysErr
+}
+
+// create creates the given ds in the database, and returns the DS with its id and other fields created on insert set. On error, the HTTP status code, user error, and system error are returned. The status code SHOULD NOT be used, if both errors are nil.
+func createV31(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.DeliveryServiceV31) (*tc.DeliveryServiceV31, int, error, error) {

Review comment:
       We should rename `ds` to `dsV13`, then we can use `ds` instead of `dsNullableV30` on L278. Essentially, we don't want to be distracted by the versioning stuff throughout the method. Also it cuts down on the number of lines we have to change when adding new versions.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -699,62 +759,301 @@ WHERE
 }
 
 func updateV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS *tc.DeliveryServiceNullableV15) (*tc.DeliveryServiceNullableV15, int, error, error) {

Review comment:
       So this function should actually stay exactly the same as it was before. Basically, we want to rename `updateV30` to `updateV31`, change it to accept and return V31 structs, then copy `updateV15` to `updateV30`, change it to accept V30 structs, upgrade them to V31 by changing the query to only select the new V31 field from the DB, then pass it to `updateV31` for the actual handling.
   
   It's kind of hard to draw in a review, but the functions are designed to chain together like so:
   ```
   UpdateV12 -> updateV12
                 |     ^
                 V     |
   UpdateV13 -> updateV13
                 |     ^
                 V     |
      ...          ...
   UpdateV31 -> updateV31  <------(this latest handler does all the actual handling)
   ```
   So each API version is like a link in a chain. For adding a new version, you just add a new link to the end of the chain, and you don't have to worry about earlier links in the chain (other than the one you're linking to). Does that make sense?

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -699,62 +759,301 @@ WHERE
 }
 
 func updateV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS *tc.DeliveryServiceNullableV15) (*tc.DeliveryServiceNullableV15, int, error, error) {
-	dsV30 := tc.DeliveryServiceNullableV30{DeliveryServiceNullableV15: *reqDS}
+	dsV31 := tc.DeliveryServiceV31{
+		DeliveryServiceV30: tc.DeliveryServiceV30{
+			DeliveryServiceNullableV15: *reqDS,
+		},
+	}
 	// query the DB for existing 3.0 fields in order to "upgrade" this 1.5 request into a 3.0 request
 	query := `
 SELECT
   ds.topology,
   ds.first_header_rewrite,
   ds.inner_header_rewrite,
   ds.last_header_rewrite,
-  ds.service_category
+  ds.service_category,
+  ds.max_request_header_bytes
 FROM
   deliveryservice ds
 WHERE
   ds.id = $1`
 	if err := inf.Tx.Tx.QueryRow(query, *reqDS.ID).Scan(
-		&dsV30.Topology,
-		&dsV30.FirstHeaderRewrite,
-		&dsV30.InnerHeaderRewrite,
-		&dsV30.LastHeaderRewrite,
-		&dsV30.ServiceCategory,
+		&dsV31.Topology,
+		&dsV31.FirstHeaderRewrite,
+		&dsV31.InnerHeaderRewrite,
+		&dsV31.LastHeaderRewrite,
+		&dsV31.ServiceCategory,
+		&dsV31.MaxRequestHeaderBytes,
 	); err != nil {
 		if err == sql.ErrNoRows {
-			return nil, http.StatusNotFound, fmt.Errorf("delivery service ID %d not found", *dsV30.ID), nil
+			return nil, http.StatusNotFound, fmt.Errorf("delivery service ID %d not found", *dsV31.ID), nil
 		}
-		return nil, http.StatusInternalServerError, nil, fmt.Errorf("querying delivery service ID %d: %s", *dsV30.ID, err.Error())
+		return nil, http.StatusInternalServerError, nil, fmt.Errorf("querying delivery service ID %d: %s", *dsV31.ID, err.Error())
 	}
-	res, status, userErr, sysErr := updateV30(w, r, inf, &dsV30)
+	res, status, userErr, sysErr := updateV31(w, r, inf, &dsV31)
 	if res != nil {
 		return &res.DeliveryServiceNullableV15, status, userErr, sysErr
 	}
 	return nil, status, userErr, sysErr
 }
 
-func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.DeliveryServiceNullableV30) (*tc.DeliveryServiceNullableV30, int, error, error) {
+func updateV31(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.DeliveryServiceV31) (*tc.DeliveryServiceV31, int, error, error) {

Review comment:
       similar to my comment for `createV31`, we should rename this parameter to `dsV31`, then use `ds` instead of `dsNullableV30` on L803




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +188,11 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {
+	DeliveryServiceNullableV30
+	MaxRequestHeaderSize *int `json:"maxRequestHeaderSize" db:"max_request_header_size"`
+}
+
 // Deprecated: Use versioned structures only from now on.
 type DeliveryServiceNullable DeliveryServiceNullableV15

Review comment:
       So I had some thoughts @ocket8888 @rob05c. I think we may want to continue using type aliases like this, but only per major version.
   
   Otherwise, let's say we end up with another 5 minor versions in 3.x. That means we will have 5 different `GetDeliveryServiceV*`, `UpdateDeliveryServiceV*`, etc, all in the same client package. I don't think that's what we want the client to look like, right? As a user, I wouldn't want to have to pick between all those minor version methods. I thought we wanted it to auto-downgrade minor versions, which means all the client functions should be using a type alias per major version, e.g. `type DeliveryServiceV3 DeliveryServiceV31`, which we continually update to alias to new minor versions, e.g. `type DeliveryServiceV3 DeliveryServiceV32`. Does that make sense?
   
   Since we already have `DeliveryServiceNullableV30`, maybe that should be the current alias. Then we don't need to add new client methods for V31.

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -335,6 +349,46 @@ func ParseOrgServerFQDN(orgServerFQDN string) (*string, *string, *string, error)
 	return &protocol, &FQDN, port, nil
 }
 
+func (ds *DeliveryServiceV31) Sanitize() {

Review comment:
       I think we might not need this if we alias `type DeliveryServiceV30 DeliveryServiceV31` like I mention in the previous comment. But if we don't want to do that for some reason, I think the matching `DeliveryServiceV30` methods would no longer be in use and could be removed. We should only be calling `Sanitize`, `Validate`, etc. in the _latest_ handlers.

##########
File path: traffic_ops/app/db/migrations/2020113000000000_add_max_request_header_size_delivery_service.sql
##########
@@ -0,0 +1,22 @@
+/*
+
+    Licensed 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.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+ALTER TABLE deliveryservice ADD COLUMN max_request_header_size int DEFAULT 131072;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+ALTER TABLE deliveryservice DROP COLUMN max_request_header_size;

Review comment:
       missing newline at end of file

##########
File path: traffic_ops/traffic_ops_golang/routing/routes.go
##########
@@ -144,6 +144,13 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
 		/**
 		 * 3.x API
 		 */
+		////DeliveryServices
+		{api.Version{3, 1}, http.MethodGet, `deliveryservices/?$`, api.ReadHandler(&deliveryservice.TODeliveryService{}), auth.PrivLevelReadOnly, Authenticated, nil, 22383173943, noPerlBypass},

Review comment:
       We should only need 3.1 routes for POST and PUT. The GET handler should have the minor-version specific handling, and DELETE is version-agnostic.

##########
File path: traffic_ops/v3-client/deliveryservice.go
##########
@@ -34,13 +34,25 @@ const (
 	// See Also: https://traffic-control-cdn.readthedocs.io/en/latest/api/v3/deliveryservices.html
 	API_DELIVERY_SERVICES = apiBase + "/deliveryservices"
 
+	// API_DELIVERY_SERVICES_V31 is the API path on which Traffic Ops serves Delivery Service
+	// information. More specific information is typically found on sub-paths of this.
+	// See Also: https://traffic-control-cdn.readthedocs.io/en/latest/api/v3/deliveryservices.html
+	API_DELIVERY_SERVICES_V31 = apiBaseV31 + "/deliveryservices"

Review comment:
       If we follow my aliasing comment above, I think we would just update `apiBase` to 3.1, and we wouldn't need the new 3.1-specific client methods below.

##########
File path: traffic_portal/app/src/common/api/DeliveryServiceService.js
##########
@@ -20,7 +20,7 @@
 var DeliveryServiceService = function($http, locationUtils, messageModel, ENV) {
 
     this.getDeliveryServices = function(queryParams) {
-        return $http.get(ENV.api['root'] + 'deliveryservices', {params: queryParams}).then(
+        return $http.get(ENV.api['deliveryServices'] + 'deliveryservices', {params: queryParams}).then(

Review comment:
       I think we would just update `ENV.api['root']` to 3.1, right @mitchell852? I think we would prefer to have TP using the same version for all requests if possible.

##########
File path: traffic_ops/testing/api/v3/deliveryservices_test.go
##########
@@ -69,6 +71,21 @@ func TestDeliveryServices(t *testing.T) {
 	})
 }
 
+func GetTestDeliveryServicesV31(t *testing.T) {

Review comment:
       We shouldn't need new minor-version specific tests if we follow my first comment above. We could just check this new field in the existing `GetTestDeliveryServices` test (similar for update).

##########
File path: traffic_ops/testing/api/v3/traffic_control_test.go
##########
@@ -31,6 +31,7 @@ type TrafficControl struct {
 	DeliveryServiceRequests                           []tc.DeliveryServiceRequest             `json:"deliveryServiceRequests"`
 	DeliveryServiceRequestComments                    []tc.DeliveryServiceRequestComment      `json:"deliveryServiceRequestComments"`
 	DeliveryServices                                  []tc.DeliveryServiceNullableV30         `json:"deliveryservices"`
+	DeliveryServicesV31                               []tc.DeliveryServiceV31                 `json:"deliveryservicesV31"`

Review comment:
       We probably wouldn't need this and the new additions to tc-fixtures.json either (assuming we alias like I mention in the first comment).




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] TaylorCFrey commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
TaylorCFrey commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747854687


   > @srijeet0406 - sorry, this is not really related to your PR but can you make a tiny change for me? I found a small bug in table.serverCapabilityDeliveryServices.tpl.html. line 37 should be `<th>XML ID (Key)</th>` instead of `<th>Host</th>`. Think you can make that super tiny change?
   
   FWIW I think this particular sized bug is fine to squeeze into a PR like this, but I do think a quick GH issue would be nice to ensure there was some level of tracking. Not necessarily a separate PR, but if the issue was tracked and included via reference in this PR then we should be good to go. What do you think @mitchell852?


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -541,6 +541,17 @@ func (ds *DeliveryServiceNullableV30) validateTypeFields(tx *sql.Tx) error {
 				}
 				return nil
 			})),
+		"maxRequestHeaderBytes": validation.Validate(ds,
+			validation.By(func(dsi interface{}) error {
+				ds := dsi.(*DeliveryServiceNullableV30)
+				if ds.MaxRequestHeaderBytes == nil {
+					return fmt.Errorf("maxRequestHeaderBytes empty, must be a valid positive value")
+				}
+				if *ds.MaxRequestHeaderBytes <= 0 {
+					return fmt.Errorf("maxRequestHeaderBytes must be a valid positive value")

Review comment:
       ditto prior comment




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747728582


   so i can clear the value and save:
   
   ![image](https://user-images.githubusercontent.com/251272/102549087-cd53b380-4078-11eb-8146-92a543f9023f.png)
   
   but then the default comes back so the tooltip should probably say that. otherwise, it might confuse the user why it was cleared and then magically reappeared.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +188,11 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {
+	DeliveryServiceNullableV30
+	MaxRequestHeaderSize *int `json:"maxRequestHeaderSize" db:"max_request_header_size"`
+}
+
 // Deprecated: Use versioned structures only from now on.
 type DeliveryServiceNullable DeliveryServiceNullableV15

Review comment:
       That should work out fine, since the only kinds of changes that should break alias property access are the same kinds that would necessitate a major version bump.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -172,11 +174,12 @@ type DeliveryServiceV11 struct {
 
 type DeliveryServiceNullableV30 struct {
 	DeliveryServiceNullableV15
-	Topology           *string `json:"topology" db:"topology"`
-	FirstHeaderRewrite *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
-	InnerHeaderRewrite *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
-	LastHeaderRewrite  *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
-	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
+	Topology             *string `json:"topology" db:"topology"`
+	FirstHeaderRewrite   *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
+	InnerHeaderRewrite   *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
+	LastHeaderRewrite    *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
+	ServiceCategory      *string `json:"serviceCategory" db:"service_category"`
+	MaxRequestHeaderSize *int    `json:"maxRequestHeaderSize" db:"max_request_header_size"`

Review comment:
       Since 5.0 is leaving the station, we probably need a new `DeliveryServiceNullableV31` struct and all the other changes that come with that, since this will likely be 3.1. Right @ocket8888? This shouldn't be backported.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 merged pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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


   


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_portal/app/src/common/api/DeliveryServiceService.js
##########
@@ -20,7 +20,7 @@
 var DeliveryServiceService = function($http, locationUtils, messageModel, ENV) {
 
     this.getDeliveryServices = function(queryParams) {
-        return $http.get(ENV.api['root'] + 'deliveryservices', {params: queryParams}).then(
+        return $http.get(ENV.api['deliveryServices'] + 'deliveryservices', {params: queryParams}).then(

Review comment:
       That's a possibility, but it will mean needing to add routes to `routes.go` for 3.1 for all API routes.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -541,6 +541,17 @@ func (ds *DeliveryServiceNullableV30) validateTypeFields(tx *sql.Tx) error {
 				}
 				return nil
 			})),
+		"maxRequestHeaderBytes": validation.Validate(ds,
+			validation.By(func(dsi interface{}) error {
+				ds := dsi.(*DeliveryServiceNullableV30)
+				if ds.MaxRequestHeaderBytes == nil {
+					return fmt.Errorf("maxRequestHeaderBytes empty, must be a valid positive value")

Review comment:
       Since we include 0 as a valid value, should we say `nonnegative` instead of `positive`? Also this can be `errors.New` instead of `fmt.Errorf` since no formatting is done.

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -541,6 +541,17 @@ func (ds *DeliveryServiceNullableV30) validateTypeFields(tx *sql.Tx) error {
 				}
 				return nil
 			})),
+		"maxRequestHeaderBytes": validation.Validate(ds,
+			validation.By(func(dsi interface{}) error {
+				ds := dsi.(*DeliveryServiceNullableV30)
+				if ds.MaxRequestHeaderBytes == nil {
+					return fmt.Errorf("maxRequestHeaderBytes empty, must be a valid positive value")
+				}
+				if *ds.MaxRequestHeaderBytes <= 0 {
+					return fmt.Errorf("maxRequestHeaderBytes must be a valid positive value")

Review comment:
       dittor prior comment

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -796,11 +880,6 @@ func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.
 				return nil, status, userErr, sysErr
 			}
 		}
-
-		userErr, sysErr, status := dbhelpers.CheckOriginServerInCacheGroupTopology(tx, *ds.ID, *ds.Topology)

Review comment:
       Was this section deleted by accident? It seems like this should be causing a test failure, but it looks like the test for this validation is passing even though it shouldn't be...




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
##########
@@ -400,6 +400,22 @@ <h3>Current Value</h3>
                             </aside>
                         </div>
                     </div>
+                    <div class="form-group" ng-class="{'has-error': hasError(cacheConfig.maxRequestHeaderBytes), 'has-feedback': hasError(cacheConfig.maxRequestHeaderBytes)}">
+                        <label class="has-tooltip control-label col-md-2 col-sm-2 col-xs-12" for="maxRequestHeaderBytes">Max Request Header Bytes<div class="helptooltip">
+                                <div class="helptext">
+                                    The maximum size (in bytes) of the request headers for this particular delivery service.
+                                </div>
+                            </div>
+                        </label>
+                        <div class="col-md-10 col-sm-10 col-xs-12">
+                            <input id="maxRequestHeaderBytes" name="maxRequestHeaderBytes" type="number" class="form-control" ng-model="deliveryService.maxRequestHeaderBytes" step="1" min="1" value="131072">

Review comment:
       Made the change




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747727500


   oh geez. i see...it can't be empty. i should actually read.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] TaylorCFrey commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -335,6 +349,46 @@ func ParseOrgServerFQDN(orgServerFQDN string) (*string, *string, *string, error)
 	return &protocol, &FQDN, port, nil
 }
 
+func (ds *DeliveryServiceV31) Sanitize() {
+	if ds.GeoLimitCountries != nil {
+		*ds.GeoLimitCountries = strings.ToUpper(strings.Replace(*ds.GeoLimitCountries, " ", "", -1))
+	}
+	if ds.ProfileID != nil && *ds.ProfileID == -1 {
+		ds.ProfileID = nil
+	}
+	setNilIfEmpty(
+		&ds.EdgeHeaderRewrite,
+		&ds.MidHeaderRewrite,
+		&ds.FirstHeaderRewrite,
+		&ds.InnerHeaderRewrite,
+		&ds.LastHeaderRewrite,
+	)
+	if ds.RoutingName == nil || *ds.RoutingName == "" {
+		ds.RoutingName = util.StrPtr(DefaultRoutingName)
+	}
+	if ds.AnonymousBlockingEnabled == nil {
+		ds.AnonymousBlockingEnabled = util.BoolPtr(false)
+	}
+	signedAlgorithm := SigningAlgorithmURLSig
+	if ds.Signed && (ds.SigningAlgorithm == nil || *ds.SigningAlgorithm == "") {
+		ds.SigningAlgorithm = &signedAlgorithm
+	}
+	if !ds.Signed && ds.SigningAlgorithm != nil && *ds.SigningAlgorithm == signedAlgorithm {
+		ds.Signed = true
+	}
+	if ds.MaxOriginConnections == nil || *ds.MaxOriginConnections < 0 {
+		ds.MaxOriginConnections = util.IntPtr(0)
+	}
+	if ds.DeepCachingType == nil {
+		s := DeepCachingType("")
+		ds.DeepCachingType = &s
+	}
+	*ds.DeepCachingType = DeepCachingTypeFromString(string(*ds.DeepCachingType))
+	if ds.MaxRequestHeaderSize == nil {
+		ds.MaxRequestHeaderSize = util.IntPtr(131072)

Review comment:
       Is there something special about this value (131072)? Should we asign it as a variable to avoid magic number confusion in the future?

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +188,11 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {

Review comment:
       Do we need to signal if this, too, is `nullable` or not, like the nested struct?

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -32,6 +32,8 @@ import (
 */
 
 const DefaultRoutingName = "cdn"
+const MaxUint = ^uint(0)

Review comment:
       Are these max values used?

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -532,6 +586,121 @@ func (ds *DeliveryServiceNullableV30) validateTypeFields(tx *sql.Tx) error {
 	return nil
 }
 
+func (ds *DeliveryServiceV31) validateTypeFields(tx *sql.Tx) error {
+	// Validate the TypeName related fields below
+	err := error(nil)
+	DNSRegexType := "^DNS.*$"
+	HTTPRegexType := "^HTTP.*$"
+	SteeringRegexType := "^STEERING.*$"
+	latitudeErr := "Must be a floating point number within the range +-90"
+	longitudeErr := "Must be a floating point number within the range +-180"
+
+	typeName, err := ValidateTypeID(tx, ds.TypeID, "deliveryservice")
+	if err != nil {
+		return err
+	}
+
+	errs := validation.Errors{
+		"consistentHashQueryParams": validation.Validate(ds,
+			validation.By(func(dsi interface{}) error {
+				ds := dsi.(*DeliveryServiceV31)
+				if len(ds.ConsistentHashQueryParams) == 0 || DSType(typeName).IsHTTP() {
+					return nil
+				}
+				return fmt.Errorf("consistentHashQueryParams not allowed for '%s' deliveryservice type", typeName)
+			})),
+		"initialDispersion": validation.Validate(ds.InitialDispersion,
+			validation.By(requiredIfMatchesTypeName([]string{HTTPRegexType}, typeName)),
+			validation.By(tovalidate.IsGreaterThanZero)),
+		"ipv6RoutingEnabled": validation.Validate(ds.IPV6RoutingEnabled,
+			validation.By(requiredIfMatchesTypeName([]string{SteeringRegexType, DNSRegexType, HTTPRegexType}, typeName))),
+		"missLat": validation.Validate(ds.MissLat,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName)),
+			validation.Min(-90.0).Error(latitudeErr),
+			validation.Max(90.0).Error(latitudeErr)),
+		"missLong": validation.Validate(ds.MissLong,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName)),
+			validation.Min(-180.0).Error(longitudeErr),
+			validation.Max(180.0).Error(longitudeErr)),
+		"multiSiteOrigin": validation.Validate(ds.MultiSiteOrigin,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName))),
+		"orgServerFqdn": validation.Validate(ds.OrgServerFQDN,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName)),
+			validation.NewStringRule(validateOrgServerFQDN, "must start with http:// or https:// and be followed by a valid hostname with an optional port (no trailing slash)")),
+		"rangeSliceBlockSize": validation.Validate(ds,
+			validation.By(func(dsi interface{}) error {
+				ds := dsi.(*DeliveryServiceV31)
+				if ds.RangeRequestHandling != nil {
+					if *ds.RangeRequestHandling == 3 {
+						return validation.Validate(ds.RangeSliceBlockSize, validation.Required,
+							// Per Slice Plugin implementation
+							validation.Min(262144),   // 256KiB
+							validation.Max(33554432), // 32MiB

Review comment:
       Would these also be considered _"magic numbers"_ even though they are explained in comments?




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
rawlinp commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747569048


   Hmm... I suppose if 0 meant "no max", that would most likely be a lie, because by default ATS sets the max to `131072` (which is why we're also setting that as the default here).


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -172,11 +174,12 @@ type DeliveryServiceV11 struct {
 
 type DeliveryServiceNullableV30 struct {
 	DeliveryServiceNullableV15
-	Topology           *string `json:"topology" db:"topology"`
-	FirstHeaderRewrite *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
-	InnerHeaderRewrite *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
-	LastHeaderRewrite  *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
-	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
+	Topology             *string `json:"topology" db:"topology"`
+	FirstHeaderRewrite   *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
+	InnerHeaderRewrite   *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
+	LastHeaderRewrite    *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
+	ServiceCategory      *string `json:"serviceCategory" db:"service_category"`
+	MaxRequestHeaderSize *int    `json:"maxRequestHeaderSize" db:"max_request_header_size"`

Review comment:
       Yeah, I suppose there's no harm in that.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
rawlinp commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747744630


   > By the way what's the reasoning behind the 131072?
   That's the default that ATS uses for this.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747731710


   bug: I entered 2147483648 (1 higher than int range). i guess 2147483647 should be enforced as the max in UI/API


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747831242


   @srijeet0406 - isn't this related to #5244? want to add that to the description? also, want to share this with/demo this to @dsouza93 before merging to see if he has any feedback? or is suppose it could be after merging but any changes would require a new PR. just let me know. this all looks good. i'm ready to merge on your request.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +189,13 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {
+	DeliveryServiceV30
+	MaxRequestHeaderSize *int `json:"maxRequestHeaderSize" db:"max_request_header_size"`

Review comment:
       Would you object to changing this to `MaxRequestHeaderBytes`?
   I think it makes it easier, so people don't have to look up the documentation to know the units, and don't assume the wrong unit and make a mistake.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -172,11 +174,12 @@ type DeliveryServiceV11 struct {
 
 type DeliveryServiceNullableV30 struct {
 	DeliveryServiceNullableV15
-	Topology           *string `json:"topology" db:"topology"`
-	FirstHeaderRewrite *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
-	InnerHeaderRewrite *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
-	LastHeaderRewrite  *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
-	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
+	Topology             *string `json:"topology" db:"topology"`
+	FirstHeaderRewrite   *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
+	InnerHeaderRewrite   *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
+	LastHeaderRewrite    *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
+	ServiceCategory      *string `json:"serviceCategory" db:"service_category"`
+	MaxRequestHeaderSize *int    `json:"maxRequestHeaderSize" db:"max_request_header_size"`

Review comment:
       Well hopefully the next release can include the DS `active` flag change, so we may actually want to go to 4.0. That'll be a breaking change that needs a new major version bump.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_portal/app/src/common/api/DeliveryServiceService.js
##########
@@ -20,7 +20,7 @@
 var DeliveryServiceService = function($http, locationUtils, messageModel, ENV) {
 
     this.getDeliveryServices = function(queryParams) {
-        return $http.get(ENV.api['root'] + 'deliveryservices', {params: queryParams}).then(
+        return $http.get(ENV.api['deliveryServices'] + 'deliveryservices', {params: queryParams}).then(

Review comment:
       That's not the way routes work unless it was changed. If there is a single 3.1 route in existence, any handlers for 3.0 will implicitly handle 3.1 requests.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747569306


   > > @mitchell852 No, 0 is considered an invalid value. It wont let you create a DS with the max header bytes set to 0 in TP or in the backend TO.
   > 
   > honestly, i don't like 0 to mean "no max" but it's kinda weird that some properties on a ds, you can use 0 and others you cannot but i'll defer to you guys.
   
   Yeah, 0 header size would just mean that you cannot add a header rewrite rule in there, which is not what we want. You will always have to specify a value > 0.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -796,11 +880,6 @@ func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.
 				return nil, status, userErr, sysErr
 			}
 		}
-
-		userErr, sysErr, status := dbhelpers.CheckOriginServerInCacheGroupTopology(tx, *ds.ID, *ds.Topology)

Review comment:
       So I figured out why the test for this wasn't failing and am about to open a PR. This should be added back.
   
   EDIT: here's the PR: https://github.com/apache/trafficcontrol/pull/5381




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +188,11 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {
+	DeliveryServiceNullableV30
+	MaxRequestHeaderSize *int `json:"maxRequestHeaderSize" db:"max_request_header_size"`
+}
+
 // Deprecated: Use versioned structures only from now on.
 type DeliveryServiceNullable DeliveryServiceNullableV15

Review comment:
       That sounds good to me.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747721660


   ![image](https://user-images.githubusercontent.com/251272/102547605-ad22f500-4076-11eb-9de7-afd603cac134.png)
   
   Think you could expand this to explain what leaving it blank/null will do?


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -335,6 +349,46 @@ func ParseOrgServerFQDN(orgServerFQDN string) (*string, *string, *string, error)
 	return &protocol, &FQDN, port, nil
 }
 
+func (ds *DeliveryServiceV31) Sanitize() {
+	if ds.GeoLimitCountries != nil {
+		*ds.GeoLimitCountries = strings.ToUpper(strings.Replace(*ds.GeoLimitCountries, " ", "", -1))
+	}
+	if ds.ProfileID != nil && *ds.ProfileID == -1 {
+		ds.ProfileID = nil
+	}
+	setNilIfEmpty(
+		&ds.EdgeHeaderRewrite,
+		&ds.MidHeaderRewrite,
+		&ds.FirstHeaderRewrite,
+		&ds.InnerHeaderRewrite,
+		&ds.LastHeaderRewrite,
+	)
+	if ds.RoutingName == nil || *ds.RoutingName == "" {
+		ds.RoutingName = util.StrPtr(DefaultRoutingName)
+	}
+	if ds.AnonymousBlockingEnabled == nil {
+		ds.AnonymousBlockingEnabled = util.BoolPtr(false)
+	}
+	signedAlgorithm := SigningAlgorithmURLSig
+	if ds.Signed && (ds.SigningAlgorithm == nil || *ds.SigningAlgorithm == "") {
+		ds.SigningAlgorithm = &signedAlgorithm
+	}
+	if !ds.Signed && ds.SigningAlgorithm != nil && *ds.SigningAlgorithm == signedAlgorithm {
+		ds.Signed = true
+	}
+	if ds.MaxOriginConnections == nil || *ds.MaxOriginConnections < 0 {
+		ds.MaxOriginConnections = util.IntPtr(0)
+	}
+	if ds.DeepCachingType == nil {
+		s := DeepCachingType("")
+		ds.DeepCachingType = &s
+	}
+	*ds.DeepCachingType = DeepCachingTypeFromString(string(*ds.DeepCachingType))
+	if ds.MaxRequestHeaderSize == nil {
+		ds.MaxRequestHeaderSize = util.IntPtr(131072)

Review comment:
       This is the default value used for our header sizes, I have made it into a constant.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747721660


   ![image](https://user-images.githubusercontent.com/251272/102547605-ad22f500-4076-11eb-9de7-afd603cac134.png)
   
   Think you could expand this to explain what leaving it blank/null will do? For example, if empty is there a) no max or b) the global max (if defined) kicks in?


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747556954


   sorry if this was already discussed but was it considered using a value of 0 to mean "no max"? We have a precedent with that. See max dns answers and max origin connections. 
   
   I guess in this case "no max" (zero or null) would really mean "use the global max request header size parameter value instead unless there is none defined, then truly no max"


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +188,11 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {
+	DeliveryServiceNullableV30
+	MaxRequestHeaderSize *int `json:"maxRequestHeaderSize" db:"max_request_header_size"`
+}
+
 // Deprecated: Use versioned structures only from now on.
 type DeliveryServiceNullable DeliveryServiceNullableV15

Review comment:
       FWIW, I ended up making an alias in `lib/go-atscfg` for both the latest DS and Server. Just for stability, because it kept changing, and requiring updating hundreds of lines of code. Where using the alias lets me just update that single location, and the few places that broke.
   
   I don't currently have a strong opinion on this. But I think we should do whatever is easy for users to work with. From my recent experience, that seems to be an alias.
   
   > That should work out fine, since the only kinds of changes that should break alias property access are the same kinds that would necessitate a major version bump.
   
   Right, that's the big issue: how does an updating alias work with Go Modules and the library Version Promise?
   It's a little bit nebulous what constitutes "breaking." The updating minor alias will only break if people use the nested initialization, e.g. `sv := tc.Server{tc.ServerV3{tc.ServerV2{Foo: foo}, Bar: bar}}` vs `sv := tc.Server{}; sv.Foo = foo; sv.Bar = bar`.
   
   I think I'd be ok with declaring that unsupported in terms of the Go Modules and the library compatibility promise, and documenting so a symbol comment. "Struct alias initialization is only guaranteed forward-compatible for default-initialization."




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] TaylorCFrey commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -335,6 +349,46 @@ func ParseOrgServerFQDN(orgServerFQDN string) (*string, *string, *string, error)
 	return &protocol, &FQDN, port, nil
 }
 
+func (ds *DeliveryServiceV31) Sanitize() {
+	if ds.GeoLimitCountries != nil {
+		*ds.GeoLimitCountries = strings.ToUpper(strings.Replace(*ds.GeoLimitCountries, " ", "", -1))
+	}
+	if ds.ProfileID != nil && *ds.ProfileID == -1 {
+		ds.ProfileID = nil
+	}
+	setNilIfEmpty(
+		&ds.EdgeHeaderRewrite,
+		&ds.MidHeaderRewrite,
+		&ds.FirstHeaderRewrite,
+		&ds.InnerHeaderRewrite,
+		&ds.LastHeaderRewrite,
+	)
+	if ds.RoutingName == nil || *ds.RoutingName == "" {
+		ds.RoutingName = util.StrPtr(DefaultRoutingName)
+	}
+	if ds.AnonymousBlockingEnabled == nil {
+		ds.AnonymousBlockingEnabled = util.BoolPtr(false)
+	}
+	signedAlgorithm := SigningAlgorithmURLSig
+	if ds.Signed && (ds.SigningAlgorithm == nil || *ds.SigningAlgorithm == "") {
+		ds.SigningAlgorithm = &signedAlgorithm
+	}
+	if !ds.Signed && ds.SigningAlgorithm != nil && *ds.SigningAlgorithm == signedAlgorithm {
+		ds.Signed = true
+	}
+	if ds.MaxOriginConnections == nil || *ds.MaxOriginConnections < 0 {
+		ds.MaxOriginConnections = util.IntPtr(0)
+	}
+	if ds.DeepCachingType == nil {
+		s := DeepCachingType("")
+		ds.DeepCachingType = &s
+	}
+	*ds.DeepCachingType = DeepCachingTypeFromString(string(*ds.DeepCachingType))
+	if ds.MaxRequestHeaderSize == nil {
+		ds.MaxRequestHeaderSize = util.IntPtr(131072)

Review comment:
       Cool. I meant is there anything unique about 131072 vs, say, 32768? Is that bits or bytes? According to https://stackoverflow.com/questions/686217/maximum-on-http-header-values it looks like the max header size is 4K to 8K, but it depends on the underlying server or page files, etc. Not sure if this that is even relevant.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -629,117 +860,352 @@ WHERE
 		}
 		return nil, http.StatusInternalServerError, nil, fmt.Errorf("querying delivery service ID %d: %s", *dsV13.ID, err.Error())
 	}
-	if dsV13.DeepCachingType != nil {
-		*dsV13.DeepCachingType = tc.DeepCachingTypeFromString(string(*dsV13.DeepCachingType))
+	if dsV13.DeepCachingType != nil {
+		*dsV13.DeepCachingType = tc.DeepCachingTypeFromString(string(*dsV13.DeepCachingType))
+	}
+
+	res, status, userErr, sysErr := updateV13(w, r, inf, &dsV13)
+	if res != nil {
+		return &res.DeliveryServiceNullableV12, status, userErr, sysErr
+	}
+	return nil, status, userErr, sysErr
+}
+
+func updateV13(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS *tc.DeliveryServiceNullableV13) (*tc.DeliveryServiceNullableV13, int, error, error) {

Review comment:
       Yeah this is not a new change, it was just moved around.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -172,11 +174,12 @@ type DeliveryServiceV11 struct {
 
 type DeliveryServiceNullableV30 struct {
 	DeliveryServiceNullableV15
-	Topology           *string `json:"topology" db:"topology"`
-	FirstHeaderRewrite *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
-	InnerHeaderRewrite *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
-	LastHeaderRewrite  *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
-	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
+	Topology             *string `json:"topology" db:"topology"`
+	FirstHeaderRewrite   *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
+	InnerHeaderRewrite   *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
+	LastHeaderRewrite    *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
+	ServiceCategory      *string `json:"serviceCategory" db:"service_category"`
+	MaxRequestHeaderSize *int    `json:"maxRequestHeaderSize" db:"max_request_header_size"`

Review comment:
       The DS `active` flag change(that I worked on) is not modifying the structure. It just lets us query by the `active` flag.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747728582


   so i can clear the value and save:
   
   ![image](https://user-images.githubusercontent.com/251272/102549087-cd53b380-4078-11eb-8146-92a543f9023f.png)
   
   but then the default comes back so the tooltip should probably say that. 


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +188,11 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {
+	DeliveryServiceNullableV30
+	MaxRequestHeaderSize *int `json:"maxRequestHeaderSize" db:"max_request_header_size"`
+}
+
 // Deprecated: Use versioned structures only from now on.
 type DeliveryServiceNullable DeliveryServiceNullableV15

Review comment:
       FWIW, I ended up making an alias in `lib/go-atscfg` for both the latest DS and Server. Just for stability, because it kept changing, and requiring updating hundreds of lines of code. Where using the alias lets me just update that single location, and the few places that broke.
   
   I don't currently have a strong opinion on this. But I think we should do whatever is easy for users to work with. From my recent experience, that seems to be an alias.
   
   > That should work out fine, since the only kinds of changes that should break alias property access are the same kinds that would necessitate a major version bump.
   
   Right, that's the big issue: how does an updating alias work with Go Modules and the library Version Promise?
   It's a little bit nebulous what constitutes "breaking." The updating minor alias will only break if people use the nested initialization, e.g. `sv := tc.Server{tc.ServerV3{tc.ServerV2{Foo: foo}, Bar: bar}}` vs `sv := tc.Server{}; sv.Foo = foo; sv.Bar = bar`.
   
   I think I'd be ok with declaring that unsupported in terms of the Go Modules and the library compatibility promise, and documenting so a symbol comment. "Struct alias initialization is only guaranteed forward-compatible for default-initialization" (maybe with an example).




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
##########
@@ -400,6 +400,22 @@ <h3>Current Value</h3>
                             </aside>
                         </div>
                     </div>
+                    <div class="form-group" ng-class="{'has-error': hasError(cacheConfig.maxRequestHeaderBytes), 'has-feedback': hasError(cacheConfig.maxRequestHeaderBytes)}">
+                        <label class="has-tooltip control-label col-md-2 col-sm-2 col-xs-12" for="maxRequestHeaderBytes">Max Request Header Bytes<div class="helptooltip">
+                                <div class="helptext">
+                                    The maximum size (in bytes) of the request headers for this particular delivery service.
+                                </div>
+                            </div>
+                        </label>
+                        <div class="col-md-10 col-sm-10 col-xs-12">
+                            <input id="maxRequestHeaderBytes" name="maxRequestHeaderBytes" type="number" class="form-control" ng-model="deliveryService.maxRequestHeaderBytes" step="1" min="1" value="131072">

Review comment:
       the value attribute is not needed here. if this is a new ds, the value of this field will be derived from deliveryService.maxRequestHeaderBytes that was set in traffic_portal_properties.json. if this is an existing ds, it will show the ds's value. 




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -858,6 +859,7 @@ func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.
 		&ds.InnerHeaderRewrite,
 		&ds.LastHeaderRewrite,
 		&ds.ServiceCategory,
+		&ds.MaxRequestHeaderSize,

Review comment:
       The way the DS API works, we also need to query the existing value of `max_request_header_size` in `updateV15`, in order for 1.5 requests to be properly _upgraded_ to 3.0 requests. Otherwise, a pre-3.0 request would blow away the existing value.
   
   The [README](https://github.com/apache/trafficcontrol/blob/master/traffic_ops/traffic_ops_golang/README.md#updating-a-minor-version) explains this a bit better, but might be out of date now that `DeliveryServiceNullable` is deprecated :(




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -172,11 +174,12 @@ type DeliveryServiceV11 struct {
 
 type DeliveryServiceNullableV30 struct {
 	DeliveryServiceNullableV15
-	Topology           *string `json:"topology" db:"topology"`
-	FirstHeaderRewrite *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
-	InnerHeaderRewrite *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
-	LastHeaderRewrite  *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
-	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
+	Topology             *string `json:"topology" db:"topology"`
+	FirstHeaderRewrite   *string `json:"firstHeaderRewrite" db:"first_header_rewrite"`
+	InnerHeaderRewrite   *string `json:"innerHeaderRewrite" db:"inner_header_rewrite"`
+	LastHeaderRewrite    *string `json:"lastHeaderRewrite" db:"last_header_rewrite"`
+	ServiceCategory      *string `json:"serviceCategory" db:"service_category"`
+	MaxRequestHeaderSize *int    `json:"maxRequestHeaderSize" db:"max_request_header_size"`

Review comment:
       He's referring to https://github.com/apache/trafficcontrol/blob/master/blueprints/ds-active.md which hasn't been started yet. That blueprint would call for a major version bump.
   
   _This_ PR could add it as 3.1, then if we get to ☝️ before 5.1 is released, that API could still be added as 4.0. Then 3.1 == 4.0 like how 1.5 == 2.0 (if that makes sense). It _would_ be cleaner if we were able to have just one or the other, but I don't think it's a big deal if we end up having to add both.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -796,11 +880,6 @@ func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.
 				return nil, status, userErr, sysErr
 			}
 		}
-
-		userErr, sysErr, status := dbhelpers.CheckOriginServerInCacheGroupTopology(tx, *ds.ID, *ds.Topology)

Review comment:
       So I figured out why the test for this wasn't failing and am about to open a PR. This should be added back.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747738539


   > bug: I entered 2147483648 (1 higher than int range). i guess 2147483647 should be enforced as the max in UI/API
   
   Fixed in the latest commit


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
rawlinp commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747723687


   If you mean from the API perspective, it will sanitize a null value to the default.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -179,6 +188,11 @@ type DeliveryServiceNullableV30 struct {
 	ServiceCategory    *string `json:"serviceCategory" db:"service_category"`
 }
 
+type DeliveryServiceV31 struct {

Review comment:
       I believe the general rule is that new structs moving forward should be nullable, so it's not really necessary to call that out for new structs anymore.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747831242


   @srijeet0406 - isn't this related to #5244? want to add that to the description? also, want to share this with/demo this to @dsouza93 before merging to see if he has any feedback?


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747556954


   sorry if this was already discussed but was it considered using a value of 0 to mean "no max"? We have a precedent with that. See max dns answers and max origin connections. 


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-748177730


   > > @srijeet0406 - sorry, this is not really related to your PR but can you make a tiny change for me? I found a small bug in table.serverCapabilityDeliveryServices.tpl.html. line 37 should be `<th>XML ID (Key)</th>` instead of `<th>Host</th>`. Think you can make that super tiny change?
   > 
   > FWIW I think this particular sized bug is fine to squeeze into a PR like this, but I do think a quick GH issue would be nice to ensure there was some level of tracking. Not necessarily a separate PR, but if the issue was tracked and included via reference in this PR then we should be good to go. What do you think @mitchell852?
   
   normally i'd agree but this is so tiny/cosmetic seems like a waste of time to create a new issue/PR and really tracking this level of change is probably unnecessary and provides almost no value.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html
##########
@@ -400,6 +400,22 @@ <h3>Current Value</h3>
                             </aside>
                         </div>
                     </div>
+                    <div class="form-group" ng-class="{'has-error': hasError(cacheConfig.maxRequestHeaderBytes), 'has-feedback': hasError(cacheConfig.maxRequestHeaderBytes)}">
+                        <label class="has-tooltip control-label col-md-2 col-sm-2 col-xs-12" for="maxRequestHeaderBytes">Max Request Header Size<div class="helptooltip">

Review comment:
       this should probably say `Bytes` instead of `Size` here and on the other forms/tables as well now

##########
File path: traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html
##########
@@ -400,6 +400,22 @@ <h3>Current Value</h3>
                             </aside>
                         </div>
                     </div>
+                    <div class="form-group" ng-class="{'has-error': hasError(cacheConfig.maxRequestHeaderBytes), 'has-feedback': hasError(cacheConfig.maxRequestHeaderBytes)}">
+                        <label class="has-tooltip control-label col-md-2 col-sm-2 col-xs-12" for="maxRequestHeaderBytes">Max Request Header Size<div class="helptooltip">
+                                <div class="helptext">
+                                    The maximum size of the request headers for this particular delivery service.

Review comment:
       this should probably say "The maximum size (in bytes) of the ..." (as well as the tooltip on the other form)




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747559308


   @mitchell852 No, 0 is considered an invalid value. It wont let you create a DS with the max header bytes set to 0 in TP or in the backend TO.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
rawlinp edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747744630


   > By the way what's the reasoning behind the 131072?
   
   That's the default that ATS uses for this.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747850075


   > @srijeet0406 - isn't this related to #5244? want to add that to the description? also, want to share this with/demo this to @dsouza93 before merging to see if he has any feedback? or I suppose it could be demo'd after merging but any changes would require a new PR. just let me know. this all looks good. i'm ready to merge on your request.
   
   I've mentioned it in the "additional info" section of the PR


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 removed a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 removed a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747727500


   oh geez. i see...it can't be empty. i should actually read.


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_ops/traffic_ops_golang/routing/routes.go
##########
@@ -145,11 +145,9 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
 		 * 3.x API
 		 */
 		////DeliveryServices
-		{api.Version{3, 1}, http.MethodGet, `deliveryservices/?$`, api.ReadHandler(&deliveryservice.TODeliveryService{}), auth.PrivLevelReadOnly, Authenticated, nil, 22383173943, noPerlBypass},
 		{api.Version{3, 1}, http.MethodPost, `deliveryservices/?$`, deliveryservice.CreateV31, auth.PrivLevelOperations, Authenticated, nil, 2064315323, noPerlBypass},
 		{api.Version{3, 1}, http.MethodPut, `deliveryservices/{id}/?$`, deliveryservice.UpdateV31, auth.PrivLevelOperations, Authenticated, nil, 27665675673, noPerlBypass},
 		{api.Version{3, 1}, http.MethodPut, `deliveryservices/{id}/safe/?$`, deliveryservice.UpdateSafe, auth.PrivLevelOperations, Authenticated, nil, 2472107313, perlBypass},

Review comment:
       I think this route is unnecessary as well -- the existing 3.0 route will handle the 3.1 requests.

##########
File path: CHANGELOG.md
##########
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 
 ## [unreleased]
 ### Added
+- Traffic Ops: added a feature so that the user can specify `maxRequestHeadersize` on a per delivery service basis

Review comment:
       `maxRequestHeaderBytes`

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -187,10 +190,12 @@ type DeliveryServiceNullableV30 struct {
 }
 
 type DeliveryServiceV31 struct {
-	DeliveryServiceNullableV30
+	DeliveryServiceV30
 	MaxRequestHeaderSize *int `json:"maxRequestHeaderSize" db:"max_request_header_size"`
 }
 
+type DeliveryServiceNullableV30 DeliveryServiceV31

Review comment:
       We should add a comment here that this type should always alias the _latest_ 3.x minor version struct.

##########
File path: traffic_ops/app/db/migrations/2020113000000000_add_max_request_header_size_delivery_service.sql
##########
@@ -0,0 +1,22 @@
+/*
+
+    Licensed 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.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+ALTER TABLE deliveryservice ADD COLUMN max_request_header_bytes int DEFAULT 131072;

Review comment:
       I think since we `Sanitize()` this to the default value upon creation/deletion, we can make this column `NOT NULL`.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -194,14 +194,39 @@ func CreateV30(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	res, status, userErr, sysErr := createV30(w, r, inf, ds)
+	res, status, userErr, sysErr := createV31(w, r, inf, ds)
 	if userErr != nil || sysErr != nil {
 		api.HandleErr(w, r, inf.Tx.Tx, status, userErr, sysErr)
 		return
 	}
 	api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Deliveryservice creation was successful.", []tc.DeliveryServiceNullableV30{*res})
 }
 
+func CreateV30(w http.ResponseWriter, r *http.Request) {
+	inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
+	if userErr != nil || sysErr != nil {
+		api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+		return
+	}
+	defer inf.Close()
+
+	ds := tc.DeliveryServiceV30{}
+	if err := json.NewDecoder(r.Body).Decode(&ds); err != nil {
+		api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, errors.New("decoding: "+err.Error()), nil)
+		return
+	}
+
+	dsV30Nullable := tc.DeliveryServiceNullableV30{

Review comment:
       `createV30` should take a `tc.DeliveryServiceV30` as input, so we shouldn't need to convert it here.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -180,7 +180,7 @@ func CreateV15(w http.ResponseWriter, r *http.Request) {
 	api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Deliveryservice creation was successful.", []tc.DeliveryServiceNullableV15{*res})
 }
 
-func CreateV30(w http.ResponseWriter, r *http.Request) {
+func CreateV31(w http.ResponseWriter, r *http.Request) {

Review comment:
       So on L191 below we should actually unmarshal the request into a `DeliveryServiceV31` struct, which is then passed into `createV31`, and then L202 writes `[]tc.DeliveryServiceV31`.
   
   Basically, we want these minor-version specific "route entry" functions to _not_ use the alias. That way, we don't have to update the existing "route entry" functions when we add new minor versions.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -230,16 +255,19 @@ func createV14(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS t
 }
 
 func createV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS tc.DeliveryServiceNullableV15) (*tc.DeliveryServiceNullableV15, int, error, error) {
-	dsV30 := tc.DeliveryServiceNullableV30{DeliveryServiceNullableV15: reqDS}
-	res, status, userErr, sysErr := createV30(w, r, inf, dsV30)
+	dsV30 := tc.DeliveryServiceV30{DeliveryServiceNullableV15: reqDS}
+	dsV30Nullable := tc.DeliveryServiceNullableV30{

Review comment:
       `createV30` should take a `DeliveryServiceV30` as input, so this conversion should be unnecessary.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -264,7 +292,7 @@ func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.D
 		return nil, errCode, userErr, sysErr
 	}
 
-	resultRows, err := tx.Query(insertQuery(),
+	resultRows, err := tx.Query(insertV31Query(),

Review comment:
       the existing `insertQuery` function should be updated to include the new field, so a specific `insertV31Query` should be unnecessary

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -588,14 +791,42 @@ func UpdateV30(w http.ResponseWriter, r *http.Request) {
 
 	id := inf.IntParams["id"]
 
+	ds := tc.DeliveryServiceV30{}
+	if err := json.NewDecoder(r.Body).Decode(&ds); err != nil {
+		api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, errors.New("malformed JSON: "+err.Error()), nil)
+		return
+	}
+	ds.ID = &id
+
+	dsV30Nullable := tc.DeliveryServiceNullableV30{
+		DeliveryServiceV30: ds,
+	}
+	res, status, userErr, sysErr := updateV30(w, r, inf, &dsV30Nullable)
+	if userErr != nil || sysErr != nil {
+		api.HandleErr(w, r, inf.Tx.Tx, status, userErr, sysErr)
+		return
+	}
+	api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Deliveryservice update was successful.", []tc.DeliveryServiceV30{*res})
+}
+
+func UpdateV31(w http.ResponseWriter, r *http.Request) {
+	inf, userErr, sysErr, errCode := api.NewInfo(r, nil, []string{"id"})
+	if userErr != nil || sysErr != nil {
+		api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+		return
+	}
+	defer inf.Close()
+
+	id := inf.IntParams["id"]
+
 	ds := tc.DeliveryServiceNullableV30{}

Review comment:
       here we want to unmarshal into a `DeliveryServiceV31` struct which is then passed to `updateV31`, and on L834 we want to write `[]tc.DeliveryServiceV31`

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -588,14 +791,42 @@ func UpdateV30(w http.ResponseWriter, r *http.Request) {
 
 	id := inf.IntParams["id"]
 
+	ds := tc.DeliveryServiceV30{}
+	if err := json.NewDecoder(r.Body).Decode(&ds); err != nil {
+		api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, errors.New("malformed JSON: "+err.Error()), nil)
+		return
+	}
+	ds.ID = &id
+
+	dsV30Nullable := tc.DeliveryServiceNullableV30{

Review comment:
       Similar to `createV30`, `updateV30` should take a `tc.DeliveryServiceV30` as input, so we shouldn't need to convert it here.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -1666,7 +2132,7 @@ func getTenantID(tx *sql.Tx, ds *tc.DeliveryServiceNullableV30) (*int, error) {
 	return existingID, err
 }
 
-func isTenantAuthorized(inf *api.APIInfo, ds *tc.DeliveryServiceNullableV30) (bool, error) {
+func isTenantAuthorized(inf *api.APIInfo, ds *tc.DeliveryServiceV30) (bool, error) {

Review comment:
       This should take `DeliveryServiceNullableV30` as input

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -1139,7 +1604,7 @@ func getTypeFromID(id int, tx *sql.Tx) (tc.DSType, error) {
 	return tc.DSTypeFromString(name), nil
 }
 
-func updatePrimaryOrigin(tx *sql.Tx, user *auth.CurrentUser, ds tc.DeliveryServiceNullableV30) error {
+func updatePrimaryOrigin(tx *sql.Tx, user *auth.CurrentUser, ds tc.DeliveryServiceV30) error {

Review comment:
       This should take `DeliveryServiceNullableV30` as input

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -1179,7 +1644,7 @@ func updatePrimaryOrigin(tx *sql.Tx, user *auth.CurrentUser, ds tc.DeliveryServi
 	return nil
 }
 
-func createPrimaryOrigin(tx *sql.Tx, user *auth.CurrentUser, ds tc.DeliveryServiceNullableV30) error {
+func createPrimaryOrigin(tx *sql.Tx, user *auth.CurrentUser, ds tc.DeliveryServiceV30) error {

Review comment:
       This should take `DeliveryServiceNullableV30` as input

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -88,7 +88,7 @@ func (ds *TODeliveryService) GetType() string {
 
 // IsTenantAuthorized checks that the user is authorized for both the delivery service's existing tenant, and the new tenant they're changing it to (if different).
 func (ds *TODeliveryService) IsTenantAuthorized(user *auth.CurrentUser) (bool, error) {
-	return isTenantAuthorized(ds.ReqInfo, &ds.DeliveryServiceNullableV30)
+	return isTenantAuthorized(ds.ReqInfo, &ds.DeliveryServiceV30)

Review comment:
       I think this can remain `DeliveryServiceNullableV30`

##########
File path: traffic_ops/testing/api/v3/deliveryservices_test.go
##########
@@ -176,38 +176,42 @@ func SSLDeliveryServiceCDNUpdateTest(t *testing.T) {
 	}
 
 	customDS := tc.DeliveryServiceNullableV30{
-		DeliveryServiceNullableV15: tc.DeliveryServiceNullableV15{
-			DeliveryServiceNullableV14: tc.DeliveryServiceNullableV14{
-				DeliveryServiceNullableV13: tc.DeliveryServiceNullableV13{
-					DeliveryServiceNullableV12: tc.DeliveryServiceNullableV12{
-						DeliveryServiceNullableV11: tc.DeliveryServiceNullableV11{
-							Active:               util.BoolPtr(true),
-							CDNID:                util.IntPtr(oldCdn.ID),
-							DSCP:                 util.IntPtr(0),
-							DisplayName:          util.StrPtr("displayName"),
-							RoutingName:          util.StrPtr("routingName"),
-							GeoLimit:             util.IntPtr(0),
-							GeoProvider:          util.IntPtr(0),
-							IPV6RoutingEnabled:   util.BoolPtr(false),
-							InitialDispersion:    util.IntPtr(1),
-							LogsEnabled:          util.BoolPtr(true),
-							MissLat:              util.FloatPtr(0),
-							MissLong:             util.FloatPtr(0),
-							MultiSiteOrigin:      util.BoolPtr(false),
-							OrgServerFQDN:        util.StrPtr("https://test.com"),
-							Protocol:             util.IntPtr(2),
-							QStringIgnore:        util.IntPtr(0),
-							RangeRequestHandling: util.IntPtr(0),
-							RegionalGeoBlocking:  util.BoolPtr(false),
-							TenantID:             util.IntPtr(1),
-							TypeID:               util.IntPtr(types[0].ID),
-							XMLID:                util.StrPtr("dsID"),
+		DeliveryServiceV30: tc.DeliveryServiceV30{

Review comment:
       It's better to declare DS structs like this, so that the declaration doesn't need updated with every minor version:
   ```
   customDS := tc.DeliveryServiceNullableV30{}
   customDS.Active = util.BoolPtr(true)
   ...
   (etc)
   ```

##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -45,6 +48,13 @@ type DeliveryServicesResponse struct {
 	Alerts
 }
 
+// DeliveryServicesResponseV31 is the type of a response from the
+// /api/3.1/deliveryservices Traffic Ops endpoint.
+type DeliveryServicesResponseV31 struct {

Review comment:
       this struct should be unnecessary -- we should be able to use `DeliveryServicesResponseV30` since it uses the `DeliveryServiceNullableV30` alias.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -230,16 +255,19 @@ func createV14(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS t
 }
 
 func createV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS tc.DeliveryServiceNullableV15) (*tc.DeliveryServiceNullableV15, int, error, error) {
-	dsV30 := tc.DeliveryServiceNullableV30{DeliveryServiceNullableV15: reqDS}
-	res, status, userErr, sysErr := createV30(w, r, inf, dsV30)
+	dsV30 := tc.DeliveryServiceV30{DeliveryServiceNullableV15: reqDS}
+	dsV30Nullable := tc.DeliveryServiceNullableV30{
+		DeliveryServiceV30: dsV30,
+	}
+	res, status, userErr, sysErr := createV30(w, r, inf, dsV30Nullable)
 	if res != nil {
 		return &res.DeliveryServiceNullableV15, status, userErr, sysErr
 	}
 	return nil, status, userErr, sysErr
 }
 
 // create creates the given ds in the database, and returns the DS with its id and other fields created on insert set. On error, the HTTP status code, user error, and system error are returned. The status code SHOULD NOT be used, if both errors are nil.
-func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.DeliveryServiceNullableV30) (*tc.DeliveryServiceNullableV30, int, error, error) {
+func createV31(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.DeliveryServiceNullableV30) (*tc.DeliveryServiceNullableV30, int, error, error) {

Review comment:
       This function should take a `DeliveryServiceV31` as input (and output), but then we should immediately typecast it to `DeliveryServiceNullableV30` within the function and typecast it _back_ to `DeliveryServiceV31` when returning it.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -1654,7 +2120,7 @@ func GetDSSelectQuery() string {
 }
 
 // getTenantID returns the tenant Id of the given delivery service. Note it may return a nil id and nil error, if the tenant ID in the database is nil.
-func getTenantID(tx *sql.Tx, ds *tc.DeliveryServiceNullableV30) (*int, error) {
+func getTenantID(tx *sql.Tx, ds *tc.DeliveryServiceV30) (*int, error) {

Review comment:
       This should take `DeliveryServiceNullableV30` as input

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -248,7 +276,7 @@ func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.D
 		return nil, http.StatusBadRequest, errors.New("invalid request: " + err.Error()), nil
 	}
 
-	if authorized, err := isTenantAuthorized(inf, &ds); err != nil {
+	if authorized, err := isTenantAuthorized(inf, &ds.DeliveryServiceV30); err != nil {

Review comment:
       following my previous comments this shouldn't be necessary

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -398,7 +427,7 @@ func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.D
 		}
 	}
 
-	if err := createPrimaryOrigin(tx, user, ds); err != nil {
+	if err := createPrimaryOrigin(tx, user, ds.DeliveryServiceV30); err != nil {

Review comment:
       This function should take `DeliveryServiceNullableV30` as input, so this change should be unnecessary.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -1954,3 +2490,72 @@ VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$
 RETURNING id, last_updated
 `
 }
+
+func insertV31Query() string {

Review comment:
       the `insertQuery()` function should be updated instead, making this function unnecessary

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -410,6 +439,178 @@ func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.D
 	return &ds, http.StatusOK, nil, nil
 }
 
+// create creates the given ds in the database, and returns the DS with its id and other fields created on insert set. On error, the HTTP status code, user error, and system error are returned. The status code SHOULD NOT be used, if both errors are nil.
+func createV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.DeliveryServiceNullableV30) (*tc.DeliveryServiceV30, int, error, error) {

Review comment:
       So, if you look at `createV15`, this function should look at lot like it. Basically we want it to take a `DeliveryServiceV30` struct as input and return one as output. Then it should just convert the `DeliveryServiceV30` into a `DeliveryServiceV31`, then pass that to `createV31` which does all the actual creation.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -1819,6 +2286,75 @@ LEFT JOIN tenant ON ds.tenant_id = tenant.id
 `
 }
 
+func updateDSV31Query() string {

Review comment:
       the `updateQuery()` function should be updated instead, making this function unnecessary

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -629,117 +860,352 @@ WHERE
 		}
 		return nil, http.StatusInternalServerError, nil, fmt.Errorf("querying delivery service ID %d: %s", *dsV13.ID, err.Error())
 	}
-	if dsV13.DeepCachingType != nil {
-		*dsV13.DeepCachingType = tc.DeepCachingTypeFromString(string(*dsV13.DeepCachingType))
+	if dsV13.DeepCachingType != nil {
+		*dsV13.DeepCachingType = tc.DeepCachingTypeFromString(string(*dsV13.DeepCachingType))
+	}
+
+	res, status, userErr, sysErr := updateV13(w, r, inf, &dsV13)
+	if res != nil {
+		return &res.DeliveryServiceNullableV12, status, userErr, sysErr
+	}
+	return nil, status, userErr, sysErr
+}
+
+func updateV13(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS *tc.DeliveryServiceNullableV13) (*tc.DeliveryServiceNullableV13, int, error, error) {

Review comment:
       This is kind of confusing to review since it seems like this was all added as new code, but I think things were just moved around.
   
   For the update* functions, you should just rename `updateV30` to `updateV31`, and change it to take in `DeliveryServiceV31` as input and output. Then _within_ the function you should immediately cast it to `DeliveryServiceNullableV30`. At the end of the function, you cast it back to `DeliveryServiceV31` before returning it.
   
   Then you can basically copy `updateV15` to `updateV30`, change it to take `DeliveryServiceV30` as input and output, then change it to read the new `max_request_header_bytes` from the DB before passing it to `updateV31`, where the real handling is done.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747835932


   @srijeet0406 - sorry, this is not really related to your PR but can you make a tiny change for me? I found a small bug in table.serverCapabilityDeliveryServices.tpl.html. line 37 should be `<th>XML ID (Key)</th>` instead of `<th>Host</th>`. Think you can make that super tiny change?


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747561636


   > @mitchell852 No, 0 is considered an invalid value. It wont let you create a DS with the max header bytes set to 0 in TP or in the backend TO.
   
   honestly, i don't like 0 to mean "no max" but it's kinda weird that some properties on a ds, you can use 0 and others you cannot but i'll defer to you guys. 


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747728582


   so i can clear the value
   
   ![image](https://user-images.githubusercontent.com/251272/102549087-cd53b380-4078-11eb-8146-92a543f9023f.png)
   
   but then the default comes back so the tooltip should probably say that. 


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747719368






----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_ops/app/db/migrations/2020113000000000_add_max_request_header_size_delivery_service.sql
##########
@@ -0,0 +1,22 @@
+/*

Review comment:
       Another migration has been merged, so this date will need to be updated to be later than the recently merged one.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747556954


   sorry if this was already discussed but was it considered using a value of 0 to mean "no max"? We have a precedent with that. See max dns answers and max origin connections. 
   
   I guess in this case "no max" (zero or null) would really mean "use the global max request header size parameter value instead unless there is none, then truly no max"


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -796,11 +880,6 @@ func updateV30(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds *tc.
 				return nil, status, userErr, sysErr
 			}
 		}
-
-		userErr, sysErr, status := dbhelpers.CheckOriginServerInCacheGroupTopology(tx, *ds.ID, *ds.Topology)

Review comment:
       Whoops sorry, I must have fat fingered a copy paste. fixed now.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747721660


   ![image](https://user-images.githubusercontent.com/251272/102547605-ad22f500-4076-11eb-9de7-afd603cac134.png)
   
   Think you could expand this to explain what leaving it blank/null will do? For example, if empty is there a) no max or b) the global max kicks in?


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

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



##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -532,6 +586,121 @@ func (ds *DeliveryServiceNullableV30) validateTypeFields(tx *sql.Tx) error {
 	return nil
 }
 
+func (ds *DeliveryServiceV31) validateTypeFields(tx *sql.Tx) error {
+	// Validate the TypeName related fields below
+	err := error(nil)
+	DNSRegexType := "^DNS.*$"
+	HTTPRegexType := "^HTTP.*$"
+	SteeringRegexType := "^STEERING.*$"
+	latitudeErr := "Must be a floating point number within the range +-90"
+	longitudeErr := "Must be a floating point number within the range +-180"
+
+	typeName, err := ValidateTypeID(tx, ds.TypeID, "deliveryservice")
+	if err != nil {
+		return err
+	}
+
+	errs := validation.Errors{
+		"consistentHashQueryParams": validation.Validate(ds,
+			validation.By(func(dsi interface{}) error {
+				ds := dsi.(*DeliveryServiceV31)
+				if len(ds.ConsistentHashQueryParams) == 0 || DSType(typeName).IsHTTP() {
+					return nil
+				}
+				return fmt.Errorf("consistentHashQueryParams not allowed for '%s' deliveryservice type", typeName)
+			})),
+		"initialDispersion": validation.Validate(ds.InitialDispersion,
+			validation.By(requiredIfMatchesTypeName([]string{HTTPRegexType}, typeName)),
+			validation.By(tovalidate.IsGreaterThanZero)),
+		"ipv6RoutingEnabled": validation.Validate(ds.IPV6RoutingEnabled,
+			validation.By(requiredIfMatchesTypeName([]string{SteeringRegexType, DNSRegexType, HTTPRegexType}, typeName))),
+		"missLat": validation.Validate(ds.MissLat,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName)),
+			validation.Min(-90.0).Error(latitudeErr),
+			validation.Max(90.0).Error(latitudeErr)),
+		"missLong": validation.Validate(ds.MissLong,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName)),
+			validation.Min(-180.0).Error(longitudeErr),
+			validation.Max(180.0).Error(longitudeErr)),
+		"multiSiteOrigin": validation.Validate(ds.MultiSiteOrigin,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName))),
+		"orgServerFqdn": validation.Validate(ds.OrgServerFQDN,
+			validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName)),
+			validation.NewStringRule(validateOrgServerFQDN, "must start with http:// or https:// and be followed by a valid hostname with an optional port (no trailing slash)")),
+		"rangeSliceBlockSize": validation.Validate(ds,
+			validation.By(func(dsi interface{}) error {
+				ds := dsi.(*DeliveryServiceV31)
+				if ds.RangeRequestHandling != nil {
+					if *ds.RangeRequestHandling == 3 {
+						return validation.Validate(ds.RangeSliceBlockSize, validation.Required,
+							// Per Slice Plugin implementation
+							validation.Min(262144),   // 256KiB
+							validation.Max(33554432), // 32MiB

Review comment:
       Made constants for these values as well.




----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] srijeet0406 commented on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747848634


   @mitchell852 No problem at all, I've fixed it in the latest commit. Also, I did have a talk with Dylan and showed him a quick demo earlier. He seemed happy with the changes. So if you feel it looks good, I'd say we are good here :) 


----------------------------------------------------------------
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.

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



[GitHub] [trafficcontrol] mitchell852 edited a comment on pull request #5345: Add a new field to the Delivery Service to accommodate for "max_request_header_size"

Posted by GitBox <gi...@apache.org>.
mitchell852 edited a comment on pull request #5345:
URL: https://github.com/apache/trafficcontrol/pull/5345#issuecomment-747831242


   @srijeet0406 - isn't this related to #5244? want to add that to the description? also, want to share this with/demo this to @dsouza93 before merging to see if he has any feedback? or I suppose it could be demo'd after merging but any changes would require a new PR. just let me know. this all looks good. i'm ready to merge on your request.


----------------------------------------------------------------
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.

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