-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TO Fixes Region V5 apis to respond with RFC3339 date/time Format #7698
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7698 +/- ##
============================================
- Coverage 29.78% 29.70% -0.08%
Complexity 98 98
============================================
Files 802 802
Lines 85789 86011 +222
Branches 952 952
============================================
+ Hits 25550 25552 +2
- Misses 58099 58320 +221
+ Partials 2140 2139 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API v5 tests fail:
regions_test.go:324: Received unexpected error: error requesting Traffic Ops: path 'https://localhost:6443/api/5.0/regions' gave HTTP error 400 Bad Request - error-level alerts: error decoding POST request body into RegionV5 struct parsing time "\"0001-01-01 00:00:00+00\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse " 00:00:00+00\"" as "T" Messages: Could not create Region 'region1': error requesting Traffic Ops: path 'https://localhost:6443/api/5.0/regions' gave HTTP error 400 Bad Request - error-level alerts: error decoding POST request body into RegionV5 struct parsing time "\"0001-01-01 00:00:00+00\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse " 00:00:00+00\"" as "T" - alerts: [{Text:error decoding POST request body into RegionV5 struct parsing time "\"0001-01-01 00:00:00+00\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse " 00:00:00+00\"" as "T" Level:error}]
-
the client still uses the the old Region struct:
func (to *Session) CreateRegion(region tc.Region, opts RequestOptions) (tc.Alerts, toclientlib.ReqInf, error) { -
the fixtures still use the old Region struct:
Regions []tc.Region `json:"regions"`
Both need to use the API v5 version instead.
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api" | ||
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers" | ||
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/util/ims" | ||
validation "github.com/go-ozzo/ozzo-validation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a line break between Traffic Control imports and third-party imports.
@@ -298,7 +294,7 @@ func validateRegionsDescSort() utils.CkReqFunc { | |||
|
|||
func validateRegionsPagination(paginationParam string) utils.CkReqFunc { | |||
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ tc.Alerts, _ error) { | |||
paginationResp := resp.([]tc.Region) | |||
paginationResp := resp.([]tc.RegionV5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line panics for me. You're typecasting to []tc.RegionV5
, which is not the type of the Response
field:
trafficcontrol/lib/go-tc/regions.go
Lines 44 to 45 in 0d79728
type RegionsResponseV50 struct { | |
Response []Region `json:"response"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few changes needed.
docs/source/api/v5/regions.rst
Outdated
@@ -41,8 +41,7 @@ Request Structure | |||
+-----------+----------+---------------------------------------------------------------------------------------------------------------+ | |||
| name | no | Filter :term:`Regions` by name | | |||
+-----------+----------+---------------------------------------------------------------------------------------------------------------+ | |||
| orderby | no | Choose the ordering of the results - must be the name of one of the fields of the objects in the ``response`` | | |||
| | | array | | |||
| orderby | no | Choose the ordering of the results - either one of them "division", "id", "name" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ending pipe
docs/source/api/v5/regions.rst
Outdated
@@ -111,7 +110,6 @@ Creates a new region | |||
Request Structure | |||
----------------- | |||
:division: The integral, unique identifier of the division which shall contain the new region\ [1]_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Target "1" was removed, so his does not refer to anything anymore. Needs removed
docs/source/api/v5/regions_id.rst
Outdated
@@ -39,7 +39,6 @@ Request Structure | |||
+------+---------------------------------------------------------+ | |||
|
|||
:division: The new integral, unique identifier of the division which shall contain the region\ [1]_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Target "1" was removed, so his does not refer to anything anymore. Needs removed
SELECT max(r.last_updated) as t FROM region r | ||
JOIN division d ON r.division = d.id ` + where + | ||
` UNION ALL | ||
select max(last_updated) as t from last_deleted l where l.table_name='region') as res` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to keep this commented out statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it is not commented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 1 small comment.
lib/go-tc/regions.go
Outdated
import "time" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports should be after the Apache license, not before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! But I'll wait for @kdamichie to approve before I merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
I'll wait for the checks to pass, then merge |
…che#7698) * region v5 api * change log and doc * region comments addresed * response error fix * comments addressed * comment addressed * removed stray pipe --------- Co-authored-by: Zach Hoffman <zrhoffman@apache.org>
Related: #5911
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
Curl all Region v5 REST calls (GET, CREATE, UPDATE, DELETE) and ensure you are getting RFC3339 date-time ( eg: lastUpdated : "2023-05-25T15:59:33.7096-06:00" )
If this is a bugfix, which Traffic Control versions contained the bug?
PR submission checklist