You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/10/17 21:17:02 UTC

[GitHub] [trafficcontrol] zrhoffman commented on a diff in pull request #7143: Override all Delivery Service TTLs in a CDN's Snapshot with a given value

zrhoffman commented on code in PR #7143:
URL: https://github.com/apache/trafficcontrol/pull/7143#discussion_r997517886


##########
traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go:
##########
@@ -43,14 +43,33 @@ const DefaultTLDTTLNS = 3600 * time.Second
 const GeoProviderMaxmindStr = "maxmindGeolocationService"
 const GeoProviderNeustarStr = "neustarGeolocationService"
 
-func makeDSes(cdn string, domain string, tx *sql.Tx) (map[string]tc.CRConfigDeliveryService, error) {
+func makeDSes(cdn string, domain string, ttlOverride int, tx *sql.Tx) (map[string]tc.CRConfigDeliveryService, error) {
 	dses := map[string]tc.CRConfigDeliveryService{}
 
 	admin := CDNSOAAdmin
-	expireSecondsStr := strconv.Itoa(int(CDNSOAExpire / time.Second))
-	minimumSecondsStr := strconv.Itoa(int(CDNSOAMinimum / time.Second))
-	refreshSecondsStr := strconv.Itoa(int(CDNSOARefresh / time.Second))
-	retrySecondsStr := strconv.Itoa(int(CDNSOARetry / time.Second))
+	expireSeconds := int(CDNSOAExpire / time.Second)
+	minimumSeconds := int(CDNSOAMinimum / time.Second)
+	refreshSeconds := int(CDNSOARefresh / time.Second)
+	retrySeconds := int(CDNSOARetry / time.Second)
+	if ttlOverride > 0 {
+		if ttlOverride < expireSeconds {

Review Comment:
   Using `math.Min()` in f1340e3d56



##########
traffic_ops/traffic_ops_golang/crconfig/deliveryservice_test.go:
##########
@@ -35,19 +35,53 @@ import (
 	"gopkg.in/DATA-DOG/go-sqlmock.v1"
 )
 
-func randDS() tc.CRConfigDeliveryService {
+func randDS(ttlOverride int) tc.CRConfigDeliveryService {
 	// truePtr := true
 	falseStrPtr := "false"
 	// numStr := "42"
 	ttlAdmin := "traffic_ops"
-	ttlExpire := "604800"
-	ttlMinimum := "30"
-	ttlRefresh := "28800"
-	ttlRetry := "7200"
-	ttl := util.IntPtr(test.RandInt())
-	ttlStr := strconv.Itoa(*ttl)
-	ttlNS := "3600"
-	ttlSOA := "86400"
+	ttlExpire := 604800
+	ttlMinimum := 30
+	ttlRefresh := 28800
+	ttlRetry := 7200
+	if ttlOverride > 0 {
+		if ttlOverride < ttlExpire {

Review Comment:
   Using `math.Min()` in f1340e3d56



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

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

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