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/11/10 00:28:54 UTC

[GitHub] [trafficcontrol] ocket8888 opened a new pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

ocket8888 opened a new pull request #5265:
URL: https://github.com/apache/trafficcontrol/pull/5265


   ## What does this PR (Pull Request) do?
   - [x] This PR is not related to any Issue
   
   This PR removes Mid-Tier Cache Servers from CDN Snapshots, as they aren't necessary for Traffic Router. Documentation already specified that "contentServers" were edge-tier, so technically this was a bug.
   
   ## Which Traffic Control components are affected by this PR?
   - Traffic Ops
   
   ## What is the best way to verify this PR?
   Take a snapshot, ensure no mids appear in the output.
   
   ## If this is a bug fix, what versions of Traffic Control are affected?
   - master
   - 4.1.0
   - 4.1.1 (RC2)
   - 5.0.0 (RC1)
   
   ## The following criteria are ALL met by this PR
   - [x] This PR includes tests OR I have explained why tests are unnecessary
   - [x] This PR includes documentation OR I have explained why documentation is unnecessary
   - [x] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [x] This PR includes any and all required license headers
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY**


----------------------------------------------------------------
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 pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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


   I'll put this in draft status and open a separate PR for 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] zrhoffman commented on pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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


   > Alternatively, this could perhaps wait for the re-work of the relationship between Monitoring and CDN Snapshots, at which time the sync will no longer be an issue and TM work will need to be done anyway to make it always use the correct data set.
   
   Waiting sounds fine to me if we can suppress the warning for mids for 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] ocket8888 commented on pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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


   Maybe. That would be such a big overhaul to TM. I think. Who can tell with that thing?
   
   If TM is looping over anything, it should be from monitoring, not a Snapshot. Or monitoring shouldn't exist at all and we just use the Snapshot.


----------------------------------------------------------------
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] zrhoffman commented on pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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


   Because mids are nlo longer in `serverCachegroups`, `CreateStats not adding availability data for '%s': not found in Cachegroups` spams the TM logs for each mid every 3 seconds:
   https://github.com/apache/trafficcontrol/blob/347c0c93b8b37d9b9cad7bc4e6400e27a92f80b2/traffic_monitor/ds/stat.go#L47-L51
   
   Should `ds.addAvailableData()` only loop over servers found in CDN snapshots?


----------------------------------------------------------------
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 #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
##########
@@ -32,16 +32,29 @@ import (
 	"github.com/lib/pq"
 )
 
-const CDNSOAMinimum = 30 * time.Second
-const CDNSOAExpire = 604800 * time.Second
-const CDNSOARetry = 7200 * time.Second
-const CDNSOARefresh = 28800 * time.Second
-const CDNSOAAdmin = "traffic_ops"
+// Start-Of-Authority record fields; see RFC1035 section 3.3.13.
+// (https://tools.ietf.org/html/rfc1035#section-3.3.13).
+const (
+	CDNSOAAdmin   = "traffic_ops"
+	CDNSOAExpire  = 604800 * time.Second

Review comment:
       It can, but I assume it isn't because the actual Expire field of an SOA record is given in seconds so this gives you a better idea of what is literally inserted.




----------------------------------------------------------------
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] zrhoffman commented on a change in pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_monitor/todata/todata.go
##########
@@ -156,6 +157,14 @@ func (d TODataThreadsafe) Update(to towrap.TrafficOpsSessionThreadsafe, cdn stri
 		return fmt.Errorf("Error getting last CRConfig: %v", err)
 	}
 
+	monitoring, err := to.TrafficMonitorConfigMap(cdn)
+	if err != nil {
+		return fmt.Errorf("error getting monitoring configuration: %v", err)

Review comment:
       True, this is a less-important error to generate quickly.




----------------------------------------------------------------
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 #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_monitor/todata/todata.go
##########
@@ -156,6 +157,14 @@ func (d TODataThreadsafe) Update(to towrap.TrafficOpsSessionThreadsafe, cdn stri
 		return fmt.Errorf("Error getting last CRConfig: %v", err)
 	}
 
+	monitoring, err := to.TrafficMonitorConfigMap(cdn)
+	if err != nil {
+		return fmt.Errorf("error getting monitoring configuration: %v", err)

Review comment:
       That would also only be in the failure case.  In reality, I'd not expect it to fail on every poll, so it'd be much less frequent.




----------------------------------------------------------------
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] zrhoffman commented on a change in pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
##########
@@ -32,16 +32,29 @@ import (
 	"github.com/lib/pq"
 )
 
-const CDNSOAMinimum = 30 * time.Second
-const CDNSOAExpire = 604800 * time.Second
-const CDNSOARetry = 7200 * time.Second
-const CDNSOARefresh = 28800 * time.Second
-const CDNSOAAdmin = "traffic_ops"
+// Start-Of-Authority record fields; see RFC1035 section 3.3.13.
+// (https://tools.ietf.org/html/rfc1035#section-3.3.13).
+const (
+	CDNSOAAdmin   = "traffic_ops"
+	CDNSOAExpire  = 604800 * time.Second

Review comment:
       `CDNSOAExpire` can be written in terms of `time.Hour`.

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -34,10 +34,13 @@ import (
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
 )
 
-const RouterTypeName = "CCR"
-const MonitorTypeName = "RASCAL"
-const EdgeTypePrefix = "EDGE"
-const MidTypePrefix = "MID"
+// Names prefixes for each type of server to appear in CDN Snapshots.
+const (
+	RouterTypeName  = "CCR"
+	MonitorTypeName = "RASCAL"
+	EdgeTypePrefix  = "EDGE"
+	MidTypePrefix   = "MID"
+)

Review comment:
       All of these constants exist in `tc`, they can be removed from from this package.

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -304,20 +321,21 @@ func getServerDSes(cdn string, tx *sql.Tx, domain string) (map[tc.CacheName]map[
 		return nil, errors.New("Error getting server deliveryservices: " + err.Error())
 	}
 
-	q := `
-select ds.xml_id as ds, dt.name as ds_type, ds.routing_name, r.pattern as pattern,
-ds.topology IS NOT NULL as has_topology
-from regex as r
-inner join type as rt on r.type = rt.id
-inner join deliveryservice_regex as dsr on dsr.regex = r.id
-inner join deliveryservice as ds on ds.id = dsr.deliveryservice
-inner join type as dt on dt.id = ds.type
-where ds.cdn_id = (select id from cdn where name = $1)
-and ds.active = true` +
-		fmt.Sprintf(" and dt.name != '%s' ", tc.DSTypeAnyMap) + `
-and rt.name = 'HOST_REGEXP'
-order by dsr.set_number asc
-`
+	q := `SELECT ds.xml_id AS ds,
+		dt.name AS ds_type,
+		ds.routing_name,
+		r.pattern AS pattern,
+		ds.topology IS NOT NULL AS has_topology
+	FROM regex AS r
+	INNER JOIN type AS rt ON r.type = rt.id
+	INNER JOIN deliveryservice_regex AS dsr ON dsr.regex = r.id
+	INNER JOIN deliveryservice AS ds ON ds.id = dsr.deliveryservice
+	INNER JOIN type AS dt ON dt.id = ds.type
+	WHERE ds.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND ds.active = true
+		AND dt.name != '` + string(tc.DSTypeAnyMap) + `'
+		AND rt.name = 'HOST_REGEXP'

Review comment:
       `HOST_REGEXP` can be `tc.DSMatchTypeHostRegex`

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -389,16 +407,20 @@ type ServerParams struct {
 func getServerParams(cdn string, tx *sql.Tx) (map[string]ServerParams, error) {
 	params := map[string]ServerParams{}
 
-	q := `
-select s.host_name, p.name, p.value
-from server as s
-left join profile_parameter as pp on pp.profile = s.profile
-left join parameter as p on p.id = pp.parameter
-inner join status as st ON st.id = s.status
-where s.cdn_id = (select id from cdn where name = $1)
-and ((p.config_file = 'CRConfig.json' and (p.name = 'weight' or p.name = 'weightMultiplier')) or (p.name = 'api.port') or (p.name = 'secure.api.port'))
-and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
-`
+	q := `SELECT s.host_name,
+		p.name,
+		p.value
+	FROM server AS s
+	LEFT JOIN profile_parameter AS pp ON pp.profile = s.profile
+	LEFT JOIN parameter AS p ON p.id = pp.parameter
+	INNER JOIN status AS st ON st.id = s.status
+	WHERE s.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND (
+			(p.config_file = 'CRConfig.json' AND (p.name = 'weight' OR p.name = 'weightMultiplier')) OR
+			(p.name = 'api.port') OR
+			(p.name = 'secure.api.port')
+		)
+	AND (st.name = 'REPORTED' OR st.name = 'ONLINE' OR st.name = 'ADMIN_DOWN')`

Review comment:
       `REPORTED` can be `tc.CacheStatusReported`

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -260,20 +272,19 @@ func getAllServers(cdn string, tx *sql.Tx) (map[string]ServerUnion, error) {
 }
 
 func getServerDSNames(cdn string, tx *sql.Tx) (map[tc.CacheName][]tc.DeliveryServiceName, error) {
-	q := `
-select s.host_name, ds.xml_id
-from deliveryservice_server as dss
-inner join server as s on dss.server = s.id
-inner join deliveryservice as ds on ds.id = dss.deliveryservice
-inner join type as dt on dt.id = ds.type
-inner join profile as p on p.id = s.profile
-inner join status as st ON st.id = s.status
-where ds.cdn_id = (select id from cdn where name = $1)
-and ds.active = true` +
-		fmt.Sprintf(" and dt.name != '%s' ", tc.DSTypeAnyMap) + `
-and p.routing_disabled = false
-and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
-`
+	q := `SELECT s.host_name,
+		ds.xml_id
+	FROM deliveryservice_server AS dss
+	INNER JOIN server AS s ON dss.server = s.id
+	INNER JOIN deliveryservice AS ds ON ds.id = dss.deliveryservice
+	INNER JOIN type AS dt ON dt.id = ds.type
+	INNER JOIN profile AS p ON p.id = s.profile
+	INNER JOIN status AS st ON st.id = s.status
+	WHERE ds.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND ds.active = true
+	 	AND dt.name != '` + string(tc.DSTypeAnyMap) + `'
+		AND p.routing_disabled = false
+		AND (st.name = 'REPORTED' OR st.name = 'ONLINE' OR st.name = 'ADMIN_DOWN')`

Review comment:
       `ADMIN_DOWN` can be `tc.CacheStatusAdminDown`

##########
File path: traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
##########
@@ -32,16 +32,29 @@ import (
 	"github.com/lib/pq"
 )
 
-const CDNSOAMinimum = 30 * time.Second
-const CDNSOAExpire = 604800 * time.Second
-const CDNSOARetry = 7200 * time.Second
-const CDNSOARefresh = 28800 * time.Second
-const CDNSOAAdmin = "traffic_ops"
+// Start-Of-Authority record fields; see RFC1035 section 3.3.13.
+// (https://tools.ietf.org/html/rfc1035#section-3.3.13).
+const (
+	CDNSOAAdmin   = "traffic_ops"
+	CDNSOAExpire  = 604800 * time.Second
+	CDNSOAMinimum = 30 * time.Second
+	CDNSOARefresh = 28800 * time.Second
+	CDNSOARetry   = 7200 * time.Second

Review comment:
       `CDNSOARefresh` and `CDNSOARetry` can be written in terms of `time.Hour`.

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -260,20 +272,19 @@ func getAllServers(cdn string, tx *sql.Tx) (map[string]ServerUnion, error) {
 }
 
 func getServerDSNames(cdn string, tx *sql.Tx) (map[tc.CacheName][]tc.DeliveryServiceName, error) {
-	q := `
-select s.host_name, ds.xml_id
-from deliveryservice_server as dss
-inner join server as s on dss.server = s.id
-inner join deliveryservice as ds on ds.id = dss.deliveryservice
-inner join type as dt on dt.id = ds.type
-inner join profile as p on p.id = s.profile
-inner join status as st ON st.id = s.status
-where ds.cdn_id = (select id from cdn where name = $1)
-and ds.active = true` +
-		fmt.Sprintf(" and dt.name != '%s' ", tc.DSTypeAnyMap) + `
-and p.routing_disabled = false
-and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
-`
+	q := `SELECT s.host_name,
+		ds.xml_id
+	FROM deliveryservice_server AS dss
+	INNER JOIN server AS s ON dss.server = s.id
+	INNER JOIN deliveryservice AS ds ON ds.id = dss.deliveryservice
+	INNER JOIN type AS dt ON dt.id = ds.type
+	INNER JOIN profile AS p ON p.id = s.profile
+	INNER JOIN status AS st ON st.id = s.status
+	WHERE ds.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND ds.active = true
+	 	AND dt.name != '` + string(tc.DSTypeAnyMap) + `'
+		AND p.routing_disabled = false
+		AND (st.name = 'REPORTED' OR st.name = 'ONLINE' OR st.name = 'ADMIN_DOWN')`

Review comment:
       `REPORTED` can be `tc.CacheStatusReported`

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -389,16 +407,20 @@ type ServerParams struct {
 func getServerParams(cdn string, tx *sql.Tx) (map[string]ServerParams, error) {
 	params := map[string]ServerParams{}
 
-	q := `
-select s.host_name, p.name, p.value
-from server as s
-left join profile_parameter as pp on pp.profile = s.profile
-left join parameter as p on p.id = pp.parameter
-inner join status as st ON st.id = s.status
-where s.cdn_id = (select id from cdn where name = $1)
-and ((p.config_file = 'CRConfig.json' and (p.name = 'weight' or p.name = 'weightMultiplier')) or (p.name = 'api.port') or (p.name = 'secure.api.port'))
-and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
-`
+	q := `SELECT s.host_name,
+		p.name,
+		p.value
+	FROM server AS s
+	LEFT JOIN profile_parameter AS pp ON pp.profile = s.profile
+	LEFT JOIN parameter AS p ON p.id = pp.parameter
+	INNER JOIN status AS st ON st.id = s.status
+	WHERE s.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND (
+			(p.config_file = 'CRConfig.json' AND (p.name = 'weight' OR p.name = 'weightMultiplier')) OR
+			(p.name = 'api.port') OR
+			(p.name = 'secure.api.port')
+		)
+	AND (st.name = 'REPORTED' OR st.name = 'ONLINE' OR st.name = 'ADMIN_DOWN')`

Review comment:
       `ONLINE` can be `tc.CacheStatusOnline`

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -260,20 +272,19 @@ func getAllServers(cdn string, tx *sql.Tx) (map[string]ServerUnion, error) {
 }
 
 func getServerDSNames(cdn string, tx *sql.Tx) (map[tc.CacheName][]tc.DeliveryServiceName, error) {
-	q := `
-select s.host_name, ds.xml_id
-from deliveryservice_server as dss
-inner join server as s on dss.server = s.id
-inner join deliveryservice as ds on ds.id = dss.deliveryservice
-inner join type as dt on dt.id = ds.type
-inner join profile as p on p.id = s.profile
-inner join status as st ON st.id = s.status
-where ds.cdn_id = (select id from cdn where name = $1)
-and ds.active = true` +
-		fmt.Sprintf(" and dt.name != '%s' ", tc.DSTypeAnyMap) + `
-and p.routing_disabled = false
-and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
-`
+	q := `SELECT s.host_name,
+		ds.xml_id
+	FROM deliveryservice_server AS dss
+	INNER JOIN server AS s ON dss.server = s.id
+	INNER JOIN deliveryservice AS ds ON ds.id = dss.deliveryservice
+	INNER JOIN type AS dt ON dt.id = ds.type
+	INNER JOIN profile AS p ON p.id = s.profile
+	INNER JOIN status AS st ON st.id = s.status
+	WHERE ds.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND ds.active = true
+	 	AND dt.name != '` + string(tc.DSTypeAnyMap) + `'
+		AND p.routing_disabled = false
+		AND (st.name = 'REPORTED' OR st.name = 'ONLINE' OR st.name = 'ADMIN_DOWN')`

Review comment:
       `ONLINE` can be `tc.CacheStatusOnline`

##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -389,16 +407,20 @@ type ServerParams struct {
 func getServerParams(cdn string, tx *sql.Tx) (map[string]ServerParams, error) {
 	params := map[string]ServerParams{}
 
-	q := `
-select s.host_name, p.name, p.value
-from server as s
-left join profile_parameter as pp on pp.profile = s.profile
-left join parameter as p on p.id = pp.parameter
-inner join status as st ON st.id = s.status
-where s.cdn_id = (select id from cdn where name = $1)
-and ((p.config_file = 'CRConfig.json' and (p.name = 'weight' or p.name = 'weightMultiplier')) or (p.name = 'api.port') or (p.name = 'secure.api.port'))
-and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
-`
+	q := `SELECT s.host_name,
+		p.name,
+		p.value
+	FROM server AS s
+	LEFT JOIN profile_parameter AS pp ON pp.profile = s.profile
+	LEFT JOIN parameter AS p ON p.id = pp.parameter
+	INNER JOIN status AS st ON st.id = s.status
+	WHERE s.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND (
+			(p.config_file = 'CRConfig.json' AND (p.name = 'weight' OR p.name = 'weightMultiplier')) OR
+			(p.name = 'api.port') OR
+			(p.name = 'secure.api.port')
+		)
+	AND (st.name = 'REPORTED' OR st.name = 'ONLINE' OR st.name = 'ADMIN_DOWN')`

Review comment:
       `ADMIN_DOWN` can be `tc.CacheStatusAdminDown`

##########
File path: traffic_monitor/todata/todata.go
##########
@@ -156,6 +157,14 @@ func (d TODataThreadsafe) Update(to towrap.TrafficOpsSessionThreadsafe, cdn stri
 		return fmt.Errorf("Error getting last CRConfig: %v", err)
 	}
 
+	monitoring, err := to.TrafficMonitorConfigMap(cdn)
+	if err != nil {
+		return fmt.Errorf("error getting monitoring configuration: %v", err)

Review comment:
       `fmt.Errorf()` using `%v` is about 4.3 times slower than `errors.New()`. For TO it's not as important, but for TM it is.




----------------------------------------------------------------
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 #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -260,20 +272,19 @@ func getAllServers(cdn string, tx *sql.Tx) (map[string]ServerUnion, error) {
 }
 
 func getServerDSNames(cdn string, tx *sql.Tx) (map[tc.CacheName][]tc.DeliveryServiceName, error) {
-	q := `
-select s.host_name, ds.xml_id
-from deliveryservice_server as dss
-inner join server as s on dss.server = s.id
-inner join deliveryservice as ds on ds.id = dss.deliveryservice
-inner join type as dt on dt.id = ds.type
-inner join profile as p on p.id = s.profile
-inner join status as st ON st.id = s.status
-where ds.cdn_id = (select id from cdn where name = $1)
-and ds.active = true` +
-		fmt.Sprintf(" and dt.name != '%s' ", tc.DSTypeAnyMap) + `
-and p.routing_disabled = false
-and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
-`
+	q := `SELECT s.host_name,
+		ds.xml_id
+	FROM deliveryservice_server AS dss
+	INNER JOIN server AS s ON dss.server = s.id
+	INNER JOIN deliveryservice AS ds ON ds.id = dss.deliveryservice
+	INNER JOIN type AS dt ON dt.id = ds.type
+	INNER JOIN profile AS p ON p.id = s.profile
+	INNER JOIN status AS st ON st.id = s.status
+	WHERE ds.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND ds.active = true
+	 	AND dt.name != '` + string(tc.DSTypeAnyMap) + `'
+		AND p.routing_disabled = false
+		AND (st.name = 'REPORTED' OR st.name = 'ONLINE' OR st.name = 'ADMIN_DOWN')`

Review comment:
       I think I just capitalized and indented this, but okay




----------------------------------------------------------------
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 #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_ops/traffic_ops_golang/crconfig/servers.go
##########
@@ -304,20 +321,21 @@ func getServerDSes(cdn string, tx *sql.Tx, domain string) (map[tc.CacheName]map[
 		return nil, errors.New("Error getting server deliveryservices: " + err.Error())
 	}
 
-	q := `
-select ds.xml_id as ds, dt.name as ds_type, ds.routing_name, r.pattern as pattern,
-ds.topology IS NOT NULL as has_topology
-from regex as r
-inner join type as rt on r.type = rt.id
-inner join deliveryservice_regex as dsr on dsr.regex = r.id
-inner join deliveryservice as ds on ds.id = dsr.deliveryservice
-inner join type as dt on dt.id = ds.type
-where ds.cdn_id = (select id from cdn where name = $1)
-and ds.active = true` +
-		fmt.Sprintf(" and dt.name != '%s' ", tc.DSTypeAnyMap) + `
-and rt.name = 'HOST_REGEXP'
-order by dsr.set_number asc
-`
+	q := `SELECT ds.xml_id AS ds,
+		dt.name AS ds_type,
+		ds.routing_name,
+		r.pattern AS pattern,
+		ds.topology IS NOT NULL AS has_topology
+	FROM regex AS r
+	INNER JOIN type AS rt ON r.type = rt.id
+	INNER JOIN deliveryservice_regex AS dsr ON dsr.regex = r.id
+	INNER JOIN deliveryservice AS ds ON ds.id = dsr.deliveryservice
+	INNER JOIN type AS dt ON dt.id = ds.type
+	WHERE ds.cdn_id = (SELECT id FROM cdn WHERE name = $1)
+		AND ds.active = true
+		AND dt.name != '` + string(tc.DSTypeAnyMap) + `'
+		AND rt.name = 'HOST_REGEXP'

Review comment:
       I just wanted code-folding to work, but I guess I can change that while I'm at it.




----------------------------------------------------------------
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 #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_monitor/todata/todata.go
##########
@@ -156,6 +157,14 @@ func (d TODataThreadsafe) Update(to towrap.TrafficOpsSessionThreadsafe, cdn stri
 		return fmt.Errorf("Error getting last CRConfig: %v", err)
 	}
 
+	monitoring, err := to.TrafficMonitorConfigMap(cdn)
+	if err != nil {
+		return fmt.Errorf("error getting monitoring configuration: %v", err)

Review comment:
       I think it depends on how often this error is actually hit. Isn't this on the order of every minute or so (its TO polling interval)?




----------------------------------------------------------------
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] zrhoffman commented on a change in pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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



##########
File path: traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
##########
@@ -32,16 +32,29 @@ import (
 	"github.com/lib/pq"
 )
 
-const CDNSOAMinimum = 30 * time.Second
-const CDNSOAExpire = 604800 * time.Second
-const CDNSOARetry = 7200 * time.Second
-const CDNSOARefresh = 28800 * time.Second
-const CDNSOAAdmin = "traffic_ops"
+// Start-Of-Authority record fields; see RFC1035 section 3.3.13.
+// (https://tools.ietf.org/html/rfc1035#section-3.3.13).
+const (
+	CDNSOAAdmin   = "traffic_ops"
+	CDNSOAExpire  = 604800 * time.Second

Review comment:
       Good point, seconds makes sense here. It can still be factored, since it's not immediately apparent that `604800` is 1 week in seconds.




----------------------------------------------------------------
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 pull request #5265: Exclude Mid-Tier cache servers from CDN Snapshots

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


   So, I can do a quick "fix" to make TM check for cache server cachegroup membership in the Monitoring payload instead of the Snapshot. However, because those two sources are inconsistently in use throughout TM, and because they can be out-of-sync, this means that stats for servers that no longer exist may (try) to be added, added to the wrong cachegroup sometimes, and stats/health for cache servers that _do_ exist may not be checked or recorded. The out-of-sync windows for the two data sources is ideally minimal, but will depend on configuration and network conditions. Of course, some of those problems could still exist today, just with more consistency.
   
   Alternatively, this could perhaps wait for the re-work of the relationship between Monitoring and CDN Snapshots, at which time the sync will no longer be an issue and TM work will need to be done anyway to make it always use the correct data set.


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