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/02/10 16:08:00 UTC
[GitHub] [trafficcontrol] ocket8888 opened a new pull request #4388: Rewrote
deliveryservices/{{ID}/safe to Go
ocket8888 opened a new pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388
## What does this PR (Pull Request) do?
- [ ] This PR fixes #3786 and supersedes/replaces #2455
Rewrites `/deliveryservices/{{ID}}/safe` to Go with special handling for the new Delivery Service fields in API v1.3, 1.4 and 1.5. Also adds client methods, fixes some inaccurate documentation, adds integration tests, and updates the Python Client to support newer API versions for this endpoint.
## Which Traffic Control components are affected by this PR?
- Documentation
- Traffic Control Client (Python)
- Traffic Ops Client (Go)
- Traffic Ops
## What is the best way to verify this PR?
Run the associated client/api integration tests (`TestPutDeliveryServiceSafe`), build and read the documentation, make a `PUT` request to `/api/1.5/deliveryservices/{{ID}}/safe` - that doesn't need to succeed or even correspond to a real ID, just make sure the routing works.
## The following criteria are ALL met by this PR
- [x] This PR includes tests
- [x] This PR includes documentation
- [x] An update to CHANGELOG.md is not necessary
- [x] This PR includes any and all required license headers
- [x] This PR does not include a database migration
- [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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] mhoppa commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
mhoppa commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377165024
##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -607,3 +607,31 @@ type AssignedDsResponse struct {
DSIds []int `json:"dsIds"`
Replace bool `json:"replace"`
}
+
+// DeliveryServiceSafeUpdateRequest represents a request to update the "safe" fields of a
+// Delivery Service.
+type DeliveryServiceSafeUpdateRequest struct {
+ DisplayName *string `json:"displayName`
+ InfoURL *string `json:"infoUrl"`
+ LongDesc *string `json:"longDesc"`
+ LongDesc1 *string `json:"longDesc1`
+}
+
+// Validate implements the github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api.ParseValidator
+// interface.
+func (r *DeliveryServiceSafeUpdateRequest) Validate(*sql.Tx) error {
+ if r.DisplayName == nil {
Review comment:
do you need to check for empty string 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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377289998
##########
File path: lib/go-tc/deliveryservices.go
##########
@@ -607,3 +607,31 @@ type AssignedDsResponse struct {
DSIds []int `json:"dsIds"`
Replace bool `json:"replace"`
}
+
+// DeliveryServiceSafeUpdateRequest represents a request to update the "safe" fields of a
+// Delivery Service.
+type DeliveryServiceSafeUpdateRequest struct {
+ DisplayName *string `json:"displayName`
+ InfoURL *string `json:"infoUrl"`
+ LongDesc *string `json:"longDesc"`
+ LongDesc1 *string `json:"longDesc1`
+}
+
+// Validate implements the github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api.ParseValidator
+// interface.
+func (r *DeliveryServiceSafeUpdateRequest) Validate(*sql.Tx) error {
+ if r.DisplayName == nil {
Review comment:
No, Perl allowed empty strings and there's no database constraint to that effect.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377291189
##########
File path: traffic_ops/traffic_ops_golang/routing/routes.go
##########
@@ -564,6 +564,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
{1.4, http.MethodPut, `deliveryservices/{id}/?(\.json)?$`, deliveryservice.UpdateV14, auth.PrivLevelOperations, Authenticated, nil, 1766567526, noPerlBypass},
{1.3, http.MethodPut, `deliveryservices/{id}/?(\.json)?$`, deliveryservice.UpdateV13, auth.PrivLevelOperations, Authenticated, nil, 1559124565, noPerlBypass},
{1.1, http.MethodPut, `deliveryservices/{id}/?(\.json)?$`, deliveryservice.UpdateV12, auth.PrivLevelOperations, Authenticated, nil, 597160536, noPerlBypass},
+ {1.1, http.MethodPut, `deliveryservices/{id}/safe/?(\.json)?$`, deliveryservice.UpdateSafe, auth.PrivLevelOperations, Authenticated, nil, 547210931, perlBypass},
Review comment:
It returns the fields that are appropriate for the API version you requested; it gives back 1.5 fields if and only if `/api/1.5/deliveryservices/{{ID}}/safe` was requested.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] mhoppa commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
mhoppa commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377282495
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/safe.go
##########
@@ -0,0 +1,124 @@
+package deliveryservice
+
+/*
+ * 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.
+ */
+
+import (
+ "database/sql"
+ "fmt"
+ "net/http"
+
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/tenant"
+)
+
+const safeUpdateQuery = `
+UPDATE deliveryservice
+SET display_name=$1,
+ info_url=$2,
+ long_desc=$3,
+ long_desc_1=$4
+WHERE id = $5
+RETURNING id
Review comment:
nit but need to return id ???
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377290719
##########
File path: docs/source/api/deliveryservices_id_safe.rst
##########
@@ -32,39 +32,33 @@ Request Structure
.. table:: Request Path Parameters
+------+--------------------------------------------------------------------------------+
- | Name | Description |
+ | Name | Description |
+======+================================================================================+
| ID | The integral, unique identifier of the :term:`Delivery Service` being modified |
+------+--------------------------------------------------------------------------------+
-:displayName: The :ref:`ds-display-name`
-:infoUrl: An :ref:`ds-info-url`
-:longDesc: The :ref:`ds-longdesc` of this :term:`Delivery Service`
-:longDesc1: The :ref:`ds-longdesc2` of this :term:`Delivery Service`
-:longDesc2: The :ref:`ds-longdesc3` of this :term:`Delivery Service`
-
-.. note:: All of these fields are optional; this ``PUT`` behaves more like a ``PATCH``
+:displayName: A string that is the :ref:`ds-display-name`
+:infoUrl: An optional\ [#optional]_ string containing the :ref:`ds-info-url`
+:longDesc: An optional\ [#optional]_ string containing the :ref:`ds-longdesc` of this :term:`Delivery Service`
+:longDesc1: An optional\ [#optional]_ string containing the :ref:`ds-longdesc2` of this :term:`Delivery Service`
Review comment:
Perl didn't support it, it was incorrect documentation (if you look at #2455 it also didn't support it, but didn't change the documentation to reflect 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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377292422
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/safe.go
##########
@@ -0,0 +1,124 @@
+package deliveryservice
+
+/*
+ * 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.
+ */
+
+import (
+ "database/sql"
+ "fmt"
+ "net/http"
+
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/tenant"
+)
+
+const safeUpdateQuery = `
+UPDATE deliveryservice
+SET display_name=$1,
+ info_url=$2,
+ long_desc=$3,
+ long_desc_1=$4
+WHERE id = $5
+RETURNING id
Review comment:
I'm not 100% sure about this because I copy/pasted this from Rob's PR, but I _think_ if it doesn't return _something_ then the `RowsAffected` won't be accurate.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] mhoppa commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
mhoppa commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377338121
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/safe.go
##########
@@ -0,0 +1,124 @@
+package deliveryservice
+
+/*
+ * 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.
+ */
+
+import (
+ "database/sql"
+ "fmt"
+ "net/http"
+
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/tenant"
+)
+
+const safeUpdateQuery = `
+UPDATE deliveryservice
+SET display_name=$1,
+ info_url=$2,
+ long_desc=$3,
+ long_desc_1=$4
+WHERE id = $5
+RETURNING id
Review comment:
I _dont_ think that is true but its not hurting anything at all so 🤷♂
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] mhoppa commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
mhoppa commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377283546
##########
File path: traffic_ops/traffic_ops_golang/routing/routes.go
##########
@@ -564,6 +564,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
{1.4, http.MethodPut, `deliveryservices/{id}/?(\.json)?$`, deliveryservice.UpdateV14, auth.PrivLevelOperations, Authenticated, nil, 1766567526, noPerlBypass},
{1.3, http.MethodPut, `deliveryservices/{id}/?(\.json)?$`, deliveryservice.UpdateV13, auth.PrivLevelOperations, Authenticated, nil, 1559124565, noPerlBypass},
{1.1, http.MethodPut, `deliveryservices/{id}/?(\.json)?$`, deliveryservice.UpdateV12, auth.PrivLevelOperations, Authenticated, nil, 597160536, noPerlBypass},
+ {1.1, http.MethodPut, `deliveryservices/{id}/safe/?(\.json)?$`, deliveryservice.UpdateSafe, auth.PrivLevelOperations, Authenticated, nil, 547210931, perlBypass},
Review comment:
should this be 1.5 since it supports the new versions of the ds on the return? I cant decide if we want that or how you have it, What do you 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [trafficcontrol] mhoppa commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
mhoppa commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377281031
##########
File path: docs/source/api/deliveryservices_id_safe.rst
##########
@@ -32,39 +32,33 @@ Request Structure
.. table:: Request Path Parameters
+------+--------------------------------------------------------------------------------+
- | Name | Description |
+ | Name | Description |
+======+================================================================================+
| ID | The integral, unique identifier of the :term:`Delivery Service` being modified |
+------+--------------------------------------------------------------------------------+
-:displayName: The :ref:`ds-display-name`
-:infoUrl: An :ref:`ds-info-url`
-:longDesc: The :ref:`ds-longdesc` of this :term:`Delivery Service`
-:longDesc1: The :ref:`ds-longdesc2` of this :term:`Delivery Service`
-:longDesc2: The :ref:`ds-longdesc3` of this :term:`Delivery Service`
-
-.. note:: All of these fields are optional; this ``PUT`` behaves more like a ``PATCH``
+:displayName: A string that is the :ref:`ds-display-name`
+:infoUrl: An optional\ [#optional]_ string containing the :ref:`ds-info-url`
+:longDesc: An optional\ [#optional]_ string containing the :ref:`ds-longdesc` of this :term:`Delivery Service`
+:longDesc1: An optional\ [#optional]_ string containing the :ref:`ds-longdesc2` of this :term:`Delivery Service`
Review comment:
why the removal of longDesc2? Should that be supported 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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] mitchell852 merged pull request #4388: Rewrote
deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
mitchell852 merged pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [trafficcontrol] rob05c commented on a change in pull request
#4388: Rewrote deliveryservices/{{ID}/safe to Go
Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #4388: Rewrote deliveryservices/{{ID}/safe to Go
URL: https://github.com/apache/trafficcontrol/pull/4388#discussion_r377355835
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/safe.go
##########
@@ -0,0 +1,124 @@
+package deliveryservice
+
+/*
+ * 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.
+ */
+
+import (
+ "database/sql"
+ "fmt"
+ "net/http"
+
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/tenant"
+)
+
+const safeUpdateQuery = `
+UPDATE deliveryservice
+SET display_name=$1,
+ info_url=$2,
+ long_desc=$3,
+ long_desc_1=$4
+WHERE id = $5
+RETURNING id
Review comment:
I think `RowsEffected` is fine without it. I think it's an artifact of the "CRUDer" framework needing it. Probably copied from a CRUDer query, or maybe my old PR used the CRUDer stuff, I don't remember. But yeah, not really hurting anything.
----------------------------------------------------------------
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
With regards,
Apache Git Services