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/04/22 19:22:37 UTC
[GitHub] [trafficcontrol] mattjackson220 opened a new pull request, #6774: CDNi Capacity Update With Scope
mattjackson220 opened a new pull request, #6774:
URL: https://github.com/apache/trafficcontrol/pull/6774
<!--
Thank you for contributing! Please be sure to read our contribution guidelines: https://github.com/apache/trafficcontrol/blob/master/CONTRIBUTING.md
If this closes or relates to an existing issue, please reference it using one of the following:
Closes: #ISSUE
Related: #ISSUE
If this PR fixes a security vulnerability, DO NOT submit! Instead, contact
the Apache Traffic Control Security Team at security@trafficcontrol.apache.org and follow the
guidelines at https://apache.org/security regarding vulnerability disclosure.
-->
This PR updates the CDNi Capacity API to be in line with the latest specification updates (see attached file).
The main changes are:
- the `total-limits` and `host-limits` fields have been replaced with just a `limits` field which now includes `id` and `scope` instead.
- the Telemetry object has been updated to include a `configuration` field which contains a `url` field. This field will be used to communicate the URL where the current usage data can be found that correlates to that Telemetry object (to ultimately be compared to the corresponding Capacity)
<!-- **^ Add meaningful description above** --><hr/>
## Which Traffic Control components are affected by this PR?
<!-- Please delete all components from this list that are NOT affected by this PR.
Feel free to add the name of a tool or script that is affected but not on the list.
-->
- Documentation
- Traffic Ops
## What is the best way to verify this PR?
<!-- Please include here ALL the steps necessary to test your PR.
If your PR has tests (and most should), provide the steps needed to run the tests.
If not, please provide step-by-step instructions to test the PR manually and explain why your PR does not need tests. -->
## If this is a bugfix, which Traffic Control versions contained the bug?
<!-- Delete this section if the PR is not a bugfix, or if the bug is only in the master branch.
Examples:
- 5.1.2
- 5.1.3 (RC1)
-->
## PR submission checklist
- [x] This PR has tests <!-- If not, please delete this text and explain why this PR does not need tests. -->
- [x] This PR has documentation <!-- If not, please delete this text and explain why this PR does not need documentation. -->
- [x] This PR has a CHANGELOG.md entry <!-- A fix for a bug from an ATC release, an improvement, or a new feature should have a changelog entry. -->
- [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://apache.org/security) for details)
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] srijeet0406 commented on a diff in pull request #6774: CDNi Capacity Update With Scope
Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on code in PR #6774:
URL: https://github.com/apache/trafficcontrol/pull/6774#discussion_r864163550
##########
traffic_ops/traffic_ops_golang/cdni/capacity.go:
##########
@@ -138,19 +101,27 @@ type CapabilityQueryResponse struct {
UCdn string `json:"ucdn" db:"ucdn"`
}
-type TotalLimitsQueryResponse struct {
- LimitType string `json:"limit_type" db:"limit_type"`
- MaximumHard int64 `json:"maximum_hard" db:"maximum_hard"`
- MaximumSoft int64 `json:"maximum_soft" db:"maximum_soft"`
- TelemetryId string `json:"telemetry_id" db:"telemetry_id"`
- TelemetryMetic string `json:"telemetry_metric" db:"telemetry_metric"`
- UCdn string `json:"ucdn" db:"ucdn"`
- Id string `json:"id" db:"id"`
- Type string `json:"type" db:"type"`
- Name string `json:"name" db:"name"`
- CapabilityId int `json:"-"`
+type LimitsQueryResponse struct {
+ Scope *LimitScope `json:"scope,omitempty"`
+ LimitId string `json:"limitId" db:"limit_id"`
+ LimitType string `json:"limitType" db:"limit_type"`
+ MaximumHard int64 `json:"maximum_hard" db:"maximum_hard"`
+ MaximumSoft int64 `json:"maximum_soft" db:"maximum_soft"`
+ TelemetryId string `json:"telemetry_id" db:"telemetry_id"`
+ TelemetryMetic string `json:"telemetry_metric" db:"telemetry_metric"`
+ UCdn string `json:"ucdn" db:"ucdn"`
+ Id string `json:"id" db:"id"`
+ Type string `json:"type" db:"type"`
+ Name string `json:"name" db:"name"`
+ CapabilityId int `json:"-"`
+}
+
+type LimitScope struct {
Review Comment:
Could you pls add some GoDocs for this?
##########
traffic_ops/traffic_ops_golang/cdni/capacity.go:
##########
@@ -138,19 +101,27 @@ type CapabilityQueryResponse struct {
UCdn string `json:"ucdn" db:"ucdn"`
}
-type TotalLimitsQueryResponse struct {
- LimitType string `json:"limit_type" db:"limit_type"`
- MaximumHard int64 `json:"maximum_hard" db:"maximum_hard"`
- MaximumSoft int64 `json:"maximum_soft" db:"maximum_soft"`
- TelemetryId string `json:"telemetry_id" db:"telemetry_id"`
- TelemetryMetic string `json:"telemetry_metric" db:"telemetry_metric"`
- UCdn string `json:"ucdn" db:"ucdn"`
- Id string `json:"id" db:"id"`
- Type string `json:"type" db:"type"`
- Name string `json:"name" db:"name"`
- CapabilityId int `json:"-"`
+type LimitsQueryResponse struct {
Review Comment:
Could you pls add some GoDocs for this?
##########
traffic_ops/traffic_ops_golang/cdni/shared.go:
##########
@@ -653,9 +629,11 @@ func getTelemetriesMap(tx *sql.Tx) (map[int][]Telemetry, error) {
telemetryMap := map[int][]Telemetry{}
for rows.Next() {
telemetry := Telemetry{}
- if err := rows.Scan(&telemetry.Id, &telemetry.Type, &telemetry.CapabilityId); err != nil {
+ configUrl := ""
+ if err := rows.Scan(&telemetry.Id, &telemetry.Type, &telemetry.CapabilityId, &configUrl); err != nil {
Review Comment:
Could we scan it directly into `&telemetry.Configuration.Url` ?
##########
traffic_ops/traffic_ops_golang/cdni/shared.go:
##########
@@ -43,27 +43,19 @@ const (
CapabilityQuery = `SELECT id, type, ucdn FROM cdni_capabilities WHERE type = $1 AND ucdn = $2`
AllFootprintQuery = `SELECT footprint_type, footprint_value::text[], capability_id FROM cdni_footprints`
- totalLimitsQuery = `
-SELECT limit_type, maximum_hard, maximum_soft, ctl.telemetry_id, ctl.telemetry_metric, t.id, t.type, tm.name, ctl.capability_id
-FROM cdni_total_limits AS ctl
+ limitsQuery = `
+SELECT limit_id, scope_type, scope_value, limit_type, maximum_hard, maximum_soft, ctl.telemetry_id, ctl.telemetry_metric, t.id, t.type, tm.name, ctl.capability_id
+FROM cdni_limits AS ctl
Review Comment:
Should the `AS` be `cl` instead of `ctl` now, since the table name has changed?
##########
traffic_ops/app/db/migrations/2022041810412200_cdni_capacity_limit_with_scopes.down.sql:
##########
@@ -0,0 +1,51 @@
+/*
Review Comment:
The timestamps of these migrations need to be changed to be after what we have in master currently.
##########
traffic_ops/traffic_ops_golang/cdni/capacity.go:
##########
@@ -138,19 +101,27 @@ type CapabilityQueryResponse struct {
UCdn string `json:"ucdn" db:"ucdn"`
}
-type TotalLimitsQueryResponse struct {
- LimitType string `json:"limit_type" db:"limit_type"`
- MaximumHard int64 `json:"maximum_hard" db:"maximum_hard"`
- MaximumSoft int64 `json:"maximum_soft" db:"maximum_soft"`
- TelemetryId string `json:"telemetry_id" db:"telemetry_id"`
- TelemetryMetic string `json:"telemetry_metric" db:"telemetry_metric"`
- UCdn string `json:"ucdn" db:"ucdn"`
- Id string `json:"id" db:"id"`
- Type string `json:"type" db:"type"`
- Name string `json:"name" db:"name"`
- CapabilityId int `json:"-"`
+type LimitsQueryResponse struct {
+ Scope *LimitScope `json:"scope,omitempty"`
+ LimitId string `json:"limitId" db:"limit_id"`
+ LimitType string `json:"limitType" db:"limit_type"`
+ MaximumHard int64 `json:"maximum_hard" db:"maximum_hard"`
+ MaximumSoft int64 `json:"maximum_soft" db:"maximum_soft"`
+ TelemetryId string `json:"telemetry_id" db:"telemetry_id"`
+ TelemetryMetic string `json:"telemetry_metric" db:"telemetry_metric"`
+ UCdn string `json:"ucdn" db:"ucdn"`
+ Id string `json:"id" db:"id"`
+ Type string `json:"type" db:"type"`
+ Name string `json:"name" db:"name"`
+ CapabilityId int `json:"-"`
+}
+
+type LimitScope struct {
+ ScopeType *string `json:"type" db:"scope_type"`
+ ScopeValue []string `json:"value" db:"scope_value"`
}
+
type HostLimitsResponse struct {
Review Comment:
Could you pls add some GoDocs for this?
##########
traffic_ops/traffic_ops_golang/cdni/shared.go:
##########
@@ -43,27 +43,19 @@ const (
CapabilityQuery = `SELECT id, type, ucdn FROM cdni_capabilities WHERE type = $1 AND ucdn = $2`
AllFootprintQuery = `SELECT footprint_type, footprint_value::text[], capability_id FROM cdni_footprints`
- totalLimitsQuery = `
-SELECT limit_type, maximum_hard, maximum_soft, ctl.telemetry_id, ctl.telemetry_metric, t.id, t.type, tm.name, ctl.capability_id
-FROM cdni_total_limits AS ctl
+ limitsQuery = `
+SELECT limit_id, scope_type, scope_value, limit_type, maximum_hard, maximum_soft, ctl.telemetry_id, ctl.telemetry_metric, t.id, t.type, tm.name, ctl.capability_id
+FROM cdni_limits AS ctl
LEFT JOIN cdni_telemetry as t ON telemetry_id = t.id
LEFT JOIN cdni_telemetry_metrics as tm ON telemetry_metric = tm.name`
- hostLimitsQuery = `
-SELECT limit_type, maximum_hard, maximum_soft, chl.telemetry_id, chl.telemetry_metric, t.id, t.type, tm.name, host, chl.capability_id
-FROM cdni_host_limits AS chl
-LEFT JOIN cdni_telemetry as t ON telemetry_id = t.id
-LEFT JOIN cdni_telemetry_metrics as tm ON telemetry_metric = tm.name
-ORDER BY host DESC`
-
InsertCapabilityUpdateQuery = `INSERT INTO cdni_capability_updates (ucdn, data, async_status_id, request_type, host) VALUES ($1, $2, $3, $4, $5)`
SelectCapabilityUpdateQuery = `SELECT ucdn, data, async_status_id, request_type, host FROM cdni_capability_updates WHERE id = $1`
SelectAllCapabilityUpdatesQuery = `SELECT id, ucdn, data, request_type, host FROM cdni_capability_updates`
DeleteCapabilityUpdateQuery = `DELETE FROM cdni_capability_updates WHERE id = $1`
- UpdateTotalLimitsByCapabilityAndLimitTypeQuery = `UPDATE cdni_total_limits SET maximum_hard = $1 WHERE capability_id = $2 AND limit_type = $3`
- UpdateHostLimitsByCapabilityAndLimitTypeQuery = `UPDATE cdni_host_limits SET maximum_hard = $1 WHERE capability_id = $2 AND limit_type = $3 AND host = $4`
- hostQuery = `SELECT count(*) FROM cdni_host_limits WHERE host = $1`
+ UpdateTotalLimitsByCapabilityAndLimitTypeQuery = `UPDATE cdni_limits SET maximum_hard = $1 WHERE capability_id = $2 AND limit_type = $3`
Review Comment:
Should this just be called `UpdateLimitsByCapabilityAndLimitTypeQuery` 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.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] srijeet0406 merged pull request #6774: CDNi Capacity Update With Scope
Posted by GitBox <gi...@apache.org>.
srijeet0406 merged PR #6774:
URL: https://github.com/apache/trafficcontrol/pull/6774
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #6774: CDNi Capacity Update With Scope
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on code in PR #6774:
URL: https://github.com/apache/trafficcontrol/pull/6774#discussion_r856514799
##########
traffic_ops/app/db/migrations/2022041810412200_cdni_capacity_limit_with_scopes.down.sql:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/* Downgrading this will lose some data because the specification has changed.
+ * Previously, only total and host limits were set. Now with the scope field, it is not as limited so downgrading
+ * cannot put the data back in the old tables since it wont necessarily fit into those buckets.
+*/
+CREATE TABLE IF NOT EXISTS cdni_total_limits (
Review Comment:
We need to create things in the `public` schema explicitly. Hank Beatty has had issues with our migrations and queries not doing that in the past, I think.
--
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