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 20:33:18 UTC

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

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


##########
docs/source/api/v4/cdns.rst:
##########
@@ -67,6 +67,7 @@ Response Structure
 :id:            The integral, unique identifier for the CDN
 :lastUpdated:   Date and time when the CDN was last modified in :ref:`non-rfc-datetime`
 :name:          The name of the CDN
+:ttlOverride:	A :abbr:`TTL (Time To Live)` value, in seconds, that, if set, overrides all set set TTL values on :term:`Delivery Services` in this :term:`CDN`

Review Comment:
   I think you might have to add the term `CDN` to the glossary.



##########
docs/source/api/v4/cdns.rst:
##########
@@ -115,6 +117,7 @@ Request Structure
 :dnssecEnabled: If ``true``, this CDN will use DNSSEC, if ``false`` it will not
 :domainName:    The top-level domain (TLD) belonging to the new CDN
 :name:          Name of the new CDN
+:ttlOverride:	A :abbr:`TTL (Time To Live)` value, in seconds, that, if set, overrides all set set TTL values on :term:`Delivery Services` in this :term:`CDN`

Review Comment:
   Same comments here.



##########
docs/source/api/v5/cdns.rst:
##########
@@ -135,6 +138,7 @@ Response Structure
 :domainName:    The top-level domain (TLD) assigned to the newly created CDN
 :id:            An integral, unique identifier for the newly created CDN
 :name:          The newly created CDN's name
+:ttlOverride:	A :abbr:`TTL (Time To Live)` value, in seconds, that, if set, overrides all set set TTL values on :term:`Delivery Services` in this :term:`CDN`

Review Comment:
   Same



##########
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:
   You don't need to change it if you don't want to, but maybe using the `math.min` function reduces the lines of code here? I'm fine either way.



##########
traffic_ops/traffic_ops_golang/cdn/cdns.go:
##########
@@ -162,36 +176,75 @@ func (cdn *TOCDN) Delete() (error, error, int) {
 	return api.GenericDelete(cdn)
 }
 
-func selectQuery() string {
+func selectQuery(apiVersion *api.Version) string {
+	var ttlOverrideColumn string

Review Comment:
   Since this code block is being replicated in a couple of different places, would you mind making it into it's own function?



##########
docs/source/api/v5/cdns.rst:
##########
@@ -67,6 +67,7 @@ Response Structure
 :id:            The integral, unique identifier for the CDN
 :lastUpdated:   Date and time when the CDN was last modified in :ref:`non-rfc-datetime`
 :name:          The name of the CDN
+:ttlOverride:	A :abbr:`TTL (Time To Live)` value, in seconds, that, if set, overrides all set set TTL values on :term:`Delivery Services` in this :term:`CDN`

Review Comment:
   Same



##########
docs/source/api/v4/cdns.rst:
##########
@@ -135,6 +138,7 @@ Response Structure
 :domainName:    The top-level domain (TLD) assigned to the newly created CDN
 :id:            An integral, unique identifier for the newly created CDN
 :name:          The newly created CDN's name
+:ttlOverride:	A :abbr:`TTL (Time To Live)` value, in seconds, that, if set, overrides all set set TTL values on :term:`Delivery Services` in this :term:`CDN`

Review Comment:
   Same



##########
docs/source/api/v4/cdns.rst:
##########
@@ -67,6 +67,7 @@ Response Structure
 :id:            The integral, unique identifier for the CDN
 :lastUpdated:   Date and time when the CDN was last modified in :ref:`non-rfc-datetime`
 :name:          The name of the CDN
+:ttlOverride:	A :abbr:`TTL (Time To Live)` value, in seconds, that, if set, overrides all set set TTL values on :term:`Delivery Services` in this :term:`CDN`

Review Comment:
   Also, the word `set` is repeated.



##########
traffic_ops/app/db/migrations/2022101700451329_add_ttl_override_to_cdn.up.sql:
##########
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+ALTER TABLE public.cdn
+ADD COLUMN ttl_override BIGINT DEFAULT NULL;

Review Comment:
   Missing new line at the end of the file.



##########
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:
   Same comment about the `min` function here



##########
docs/source/api/v5/cdns.rst:
##########
@@ -115,6 +117,7 @@ Request Structure
 :dnssecEnabled: If ``true``, this CDN will use DNSSEC, if ``false`` it will not
 :domainName:    The top-level domain (TLD) belonging to the new CDN
 :name:          Name of the new CDN
+:ttlOverride:	A :abbr:`TTL (Time To Live)` value, in seconds, that, if set, overrides all set set TTL values on :term:`Delivery Services` in this :term:`CDN`

Review Comment:
   Same



##########
traffic_ops/app/db/migrations/2022101700451329_add_ttl_override_to_cdn.down.sql:
##########
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+ALTER TABLE public.cdn
+DROP COLUMN ttl_override;

Review Comment:
   Missing new line at the end of the file.



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