You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "gbkannan89 (via GitHub)" <gi...@apache.org> on 2023/07/18 10:08:35 UTC
[GitHub] [trafficcontrol] gbkannan89 opened a new pull request, #7660: To delivery service rfc time format v5
gbkannan89 opened a new pull request, #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660
Related:[#5911 ]( https://github.com/apache/trafficcontrol/issues/5911)
<hr/>
## Which Traffic Control components are affected by this PR?
- Documentation
- Traffic Ops
## What is the best way to verify this PR?
Response object with date must be in RFC3339-format date strings.
In deliveryservices/{{ID}}/servers - expected lastUpdated response in RFC3339-format date strings.
```
curl --request GET \
--url https://localhost:8443/api/5.0/deliveryservices/{{ID}}/servers
{
"response": [{
"cachegroup": "CDN_in_a_Box_Edge",
"cachegroupId": 7,
"cdnId": 2,
"cdnName": "CDN-in-a-Box",
"domainName": "infra.ciab.test",
"guid": null,
"hostName": "edge",
"httpsPort": 443,
"id": 10,
"iloIpAddress": "",
"iloIpGateway": "",
"iloIpNetmask": "",
"iloPassword": "",
"iloUsername": "",
"lastUpdated": "2018-11-14T21:50:03.009954Z",
"mgmtIpAddress": "",
"mgmtIpGateway": "",
"mgmtIpNetmask": "",
"offlineReason": "",
"physLocation": "Apachecon North America 2018",
"physLocationId": 1,
"profileNames": ["ATS_EDGE_TIER_CACHE"],
"rack": "",
"routerHostName": "",
"routerPortName": "",
"status": "REPORTED",
"statusId": 3,
"tcpPort": 80,
"type": "EDGE",
"typeId": 11,
"updPending": false,
"interfaces": [{
"ipAddresses": [{
"address": "172.16.239.100",
"gateway": "172.16.239.1",
"service_address": true
},
{
"address": "fc01:9400:1000:8::100",
"gateway": "fc01:9400:1000:8::1",
"service_address": true
}
],
"max_bandwidth": 0,
"monitor": true,
"mtu": 1500,
"name": "eth0"
}]
}]
}
```
In deliveryservices/{{ID}}/servers/eligible - expected lastUpdated in response RFC3339-format date strings.
```
curl --request GET \
--url https://localhost:8443/api/5.0/deliveryservices/{{ID}}/servers/eligible
{ "response": [
{
"cachegroup": "CDN_in_a_Box_Edge",
"cachegroupId": 7,
"cdnId": 2,
"cdnName": "CDN-in-a-Box",
"domainName": "infra.ciab.test",
"guid": null,
"hostName": "edge",
"httpsPort": 443,
"id": 10,
"iloIpAddress": "",
"iloIpGateway": "",
"iloIpNetmask": "",
"iloPassword": "",
"iloUsername": "",
"lastUpdated": "2018-10-30T21:50:03.009954Z",
"mgmtIpAddress": "",
"mgmtIpGateway": "",
"mgmtIpNetmask": "",
"offlineReason": "",
"physLocation": "Apachecon North America 2018",
"physLocationId": 1,
"profile": "ATS_EDGE_TIER_CACHE",
"profileDesc": "Edge Cache - Apache Traffic Server",
"profileId": 9,
"rack": "",
"routerHostName": "",
"routerPortName": "",
"status": "REPORTED",
"statusId": 3,
"tcpPort": 80,
"type": "EDGE",
"typeId": 11,
"updPending": false,
"interfaces": [{
"ipAddresses": [
{
"address": "172.16.239.100",
"gateway": "172.16.239.1",
"service_address": true
},
{
"address": "fc01:9400:1000:8::100",
"gateway": "fc01:9400:1000:8::1",
"service_address": true
}
],
"max_bandwidth": 0,
"monitor": true,
"mtu": 1500,
"name": "eth0"
}]
}
]}
```
## If this is a bugfix, which Traffic Control versions contained the bug?
- 7.0.x
## 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)
--
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 #7660: Fix `/deliveryservices/{{ID}}/servers` and `/deliveryservices/{{ID}}/servers/eligible` to use RFC3339 timestamps
Posted by "ocket8888 (via GitHub)" <gi...@apache.org>.
ocket8888 commented on code in PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#discussion_r1277043200
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -168,6 +168,44 @@ type DSServerBaseV4 struct {
DeliveryServiceCapabilities []string `json:"-" db:"deliveryservice_capabilities"`
}
+// DSServerBaseV5 contains the base information for a Delivery Service Server associated with APIv5.
+type DSServerBaseV5 struct {
Review Comment:
The reason we have a DSServerBase was to re-use a struct that shares many details between v4 and earlier versions. You are only using DSServerBaseV5 in exactly one place: the definition of DSServerV50. So it's completely unnecessary.
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -290,3 +346,48 @@ func (baseV4 DSServerBaseV4) ToDSServerBase(routerHostName, routerPort, pDesc *s
dsServerBase.RouterPortName = routerPort
return dsServerBase
}
+
+// ToDSServerV5 convert DSServerV4 lastUpdated time format to RFC3339 for DSServerV5
+// and also assign V4 values to V5
+func ToDSServerV5(serverList []DSServerV4) []DSServerV5 {
+ updatedServerList := make([]DSServerV5, len(serverList))
+
+ for i, server := range serverList {
+ r := time.Unix(server.LastUpdated.Unix(), 0)
+ updatedServerList[i].LastUpdated = &r
+ updatedServerList[i].Cachegroup = server.Cachegroup
+ updatedServerList[i].CachegroupID = server.CachegroupID
+ updatedServerList[i].CDNID = server.CDNID
+ updatedServerList[i].CDNName = server.CDNName
+ updatedServerList[i].DeliveryServices = server.DeliveryServices
+ updatedServerList[i].DomainName = server.DomainName
+ updatedServerList[i].FQDN = server.FQDN
+ updatedServerList[i].FqdnTime = server.FqdnTime
+ updatedServerList[i].GUID = server.GUID
+ updatedServerList[i].HostName = server.HostName
+ updatedServerList[i].HTTPSPort = server.HTTPSPort
+ updatedServerList[i].ID = server.ID
+ updatedServerList[i].ILOIPAddress = server.ILOIPAddress
+ updatedServerList[i].ILOIPGateway = server.ILOIPGateway
+ updatedServerList[i].ILOIPNetmask = server.ILOIPNetmask
+ updatedServerList[i].ILOPassword = server.ILOPassword
+ updatedServerList[i].ILOUsername = server.ILOUsername
+ updatedServerList[i].MgmtIPAddress = server.MgmtIPAddress
+ updatedServerList[i].MgmtIPGateway = server.MgmtIPGateway
+ updatedServerList[i].MgmtIPNetmask = server.MgmtIPNetmask
+ updatedServerList[i].OfflineReason = server.OfflineReason
+ updatedServerList[i].PhysLocation = server.PhysLocation
+ updatedServerList[i].PhysLocationID = server.PhysLocationID
+ updatedServerList[i].ProfileNames = server.ProfileNames
+ updatedServerList[i].Rack = server.Rack
+ updatedServerList[i].Status = server.Status
+ updatedServerList[i].StatusID = server.StatusID
+ updatedServerList[i].TCPPort = server.TCPPort
+ updatedServerList[i].Type = server.Type
+ updatedServerList[i].TypeID = server.TypeID
+ updatedServerList[i].UpdPending = server.UpdPending
+ updatedServerList[i].ServerCapabilities = server.ServerCapabilities
+ updatedServerList[i].DeliveryServiceCapabilities = server.DeliveryServiceCapabilities
+ }
+ return updatedServerList
+}
Review Comment:
This is missing (at least) network interface information.
IMO, it would much better to simply wrap a `ServerV50` to add the list of `DeliveryServices` (and DS Capabilities?) and then you can upgrade the server part by just calling `ServerV4.Upgrade` - which has test coverage that assures you that you haven't missed anything - and just making this a method on `DSServerV4` instead of trying to update a slice of those.
--
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] gbkannan89 commented on a diff in pull request #7660: To delivery service rfc time format v5
Posted by "gbkannan89 (via GitHub)" <gi...@apache.org>.
gbkannan89 commented on code in PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#discussion_r1270452208
##########
docs/source/api/v5/deliveryservices_id_servers.rst:
##########
@@ -70,7 +70,7 @@ Response Structure
:gateway: The IPv4 or IPv6 gateway address of the server - applicable for the interface ``name``
:service_address: A boolean determining if content will be routed to the IP address
-:lastUpdated: The time and date at which this server was last updated, in :ref:`non-rfc-datetime`
Review Comment:
yes i missed to update.
--
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 merged pull request #7660: Fix `/deliveryservices/{{ID}}/servers` and `/deliveryservices/{{ID}}/servers/eligible` to use RFC3339 timestamps
Posted by "ocket8888 (via GitHub)" <gi...@apache.org>.
ocket8888 merged PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660
--
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 #7660: To delivery service rfc time format v5
Posted by "ocket8888 (via GitHub)" <gi...@apache.org>.
ocket8888 commented on code in PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#discussion_r1275370305
##########
lib/go-tc/federation_resolver.go:
##########
@@ -51,7 +51,7 @@ type FederationResolver struct {
TypeID *uint `json:"typeId,omitempty" db:"type"`
}
-// FederationResolverV5 - is an alias for the Federal Resolver struct response used for the latest minor version associated with APIv5.
+// FederationResolverV5 - is an alias for the Federal Resolver struct response used for the latest major version associated with APIv5.
Review Comment:
This is not correct - `minor` is the right word here.
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -290,3 +349,14 @@ func (baseV4 DSServerBaseV4) ToDSServerBase(routerHostName, routerPort, pDesc *s
dsServerBase.RouterPortName = routerPort
return dsServerBase
}
+
+// ConvertV4LastupdateToV5 convert DSServerV4 lastUpdated time format to RFC3339 for DSServerV5
+func ConvertV4LastupdateToV5(serverList []DSServerV4) []DSServerV5 {
+ updatedServerList := make([]DSServerV5, len(serverList))
+
+ for i, server := range serverList {
+ r := time.Unix(server.LastUpdated.Unix(), 0)
+ updatedServerList[i].LastUpdated = &r
+ }
+ return updatedServerList
+}
Review Comment:
So, what this function does, is it creates a new list of `DSServerV5`s where each member of that array has the same `LastUpdated` time as the corresponding member in the `DSServerV4` array, but just using `time.Time` (pointer) instead of a `TimeNoMod` (pointer).
And that's it. It doesn't set any other field of the structs in the returned array, so you get back no information at all _except_ the `LastUpdated` time. I made a playground to illustrate the problem: https://go.dev/play/p/1X24ajmzLwE
##########
lib/go-tc/federation_resolver.go:
##########
@@ -72,7 +72,7 @@ type FederationResolversResponseV50 struct {
Response []FederationResolverV5 `json:"response"`
}
-// FederationResolverResponseV50 - represents struct response used for the latest minor version associated with APIv5.
+// FederationResolverResponseV5 - represents struct response used for the latest major version associated with APIv5.
Review Comment:
Same as above.
Correcting `FederationResolverResponseV50` to `FederationResolverV5` is accurate, though.
##########
lib/go-tc/federation_resolver.go:
##########
@@ -63,7 +63,7 @@ type FederationResolverV50 struct {
TypeID *uint `json:"typeId,omitempty" db:"type"`
}
-// FederationResolversResponseV5 - an alias for the Federation Resolver's struct response used for the latest minor version associated with APIv5.
+// FederationResolversResponseV5 - an alias for the Federation Resolver's struct response used for the latest major version associated with APIv5.
Review Comment:
Same as above.
##########
traffic_ops/traffic_ops_golang/deliveryservice/eligible.go:
##########
@@ -42,6 +42,8 @@ func GetServersEligible(w http.ResponseWriter, r *http.Request) {
}
defer inf.Close()
+ alerts := tc.Alerts{}
Review Comment:
This variable is declared 50 lines away from its only usage, which is a read, so this variable doesn't need to exist at all. The value it is given (which is never modified) could instead be used directly where that access is being done currently.
##########
lib/go-tc/federation_resolver.go:
##########
@@ -104,7 +104,7 @@ func (fr *FederationResolver) Validate(tx *sql.Tx) error {
}
// UpgradeToFederationResolverV5 upgrades an APIv4 Federal Resolver into an APIv5 Federal Resolver of
-// the latest minor version.
+// the latest major version APIv5.
Review Comment:
Same as above, also the <ins> APIv5</ins> you added should not have been added.
##########
traffic_ops/traffic_ops_golang/deliveryservice/eligible.go:
##########
@@ -96,6 +98,17 @@ func GetServersEligible(w http.ResponseWriter, r *http.Request) {
api.WriteResp(w, r, v3ServerList)
return
}
+
+ // Based on version we load Delivery Service Eligible Server - for version 5 and above we use DSServerV5
+ if inf.Version.GreaterThanOrEqualTo(&api.Version{Major: 5, Minor: 0}) {
+
+ // Convert lastupdate time format to RFC3339 of DSServerV4 to DSServerV5
+ newServerList := tc.ConvertV4LastupdateToV5(servers)
+
+ api.WriteAlertsObj(w, r, http.StatusOK, alerts, newServerList)
Review Comment:
`alerts` is always empty at this point, so why use `api.WriteAlertsObj`? You don't have any alerts to write.
--
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 #7660: To delivery service rfc time format v5
Posted by "ocket8888 (via GitHub)" <gi...@apache.org>.
ocket8888 commented on code in PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#discussion_r1275108892
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -168,6 +168,47 @@ type DSServerBaseV4 struct {
DeliveryServiceCapabilities []string `json:"-" db:"deliveryservice_capabilities"`
}
+// DSServerBaseV5 contains the base information for a Delivery Service Server associated with APIv5.
+type DSServerBaseV5 = DSServerBaseV50
+
+// DSServerBaseV50 contains the base information for a Delivery Service Server for the latest major version associated with APIv50.
+type DSServerBaseV50 struct {
Review Comment:
The reason we have a `DSServerBase` was to re-use a struct that shares many details between v4 and earlier versions. You are only using DSServerBaseV50 in exactly one place: the definition of DSServerV50. So it's completely unnecessary.
--
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] codecov[bot] commented on pull request #7660: To delivery service rfc time format v5
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#issuecomment-1640199156
## [Codecov](https://app.codecov.io/gh/apache/trafficcontrol/pull/7660?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#7660](https://app.codecov.io/gh/apache/trafficcontrol/pull/7660?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (5bbafb0) into [master](https://app.codecov.io/gh/apache/trafficcontrol/commit/3e388a3b97456c79235e4a6d487afced8113e663?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (3e388a3) will **increase** coverage by `5.02%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## master #7660 +/- ##
============================================
+ Coverage 29.99% 35.01% +5.02%
Complexity 98 98
============================================
Files 440 548 +108
Lines 37914 42807 +4893
Branches 90 905 +815
============================================
+ Hits 11373 14991 +3618
- Misses 25451 26666 +1215
- Partials 1090 1150 +60
```
| Flag | Coverage Δ | |
|---|---|---|
| golib_unit | `48.26% <ø> (+<0.01%)` | :arrow_up: |
| grove_unit | `4.60% <ø> (ø)` | |
| t3c_unit | `5.28% <ø> (ø)` | |
| traffic_monitor_unit | `21.30% <ø> (ø)` | |
| traffic_portal_v2 | `73.92% <ø> (?)` | |
| traffic_stats_unit | `10.14% <ø> (ø)` | |
| unit_tests | `31.77% <ø> (+6.28%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://app.codecov.io/gh/apache/trafficcontrol/pull/7660?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [lib/go-tc/deliveryservice\_servers.go](https://app.codecov.io/gh/apache/trafficcontrol/pull/7660?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-bGliL2dvLXRjL2RlbGl2ZXJ5c2VydmljZV9zZXJ2ZXJzLmdv) | `0.00% <ø> (ø)` | |
| [lib/go-tc/federation\_resolver.go](https://app.codecov.io/gh/apache/trafficcontrol/pull/7660?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-bGliL2dvLXRjL2ZlZGVyYXRpb25fcmVzb2x2ZXIuZ28=) | `45.45% <ø> (ø)` | |
... and [109 files with indirect coverage changes](https://app.codecov.io/gh/apache/trafficcontrol/pull/7660/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
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] rimashah25 commented on a diff in pull request #7660: To delivery service rfc time format v5
Posted by "rimashah25 (via GitHub)" <gi...@apache.org>.
rimashah25 commented on code in PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#discussion_r1269824774
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -168,6 +168,47 @@ type DSServerBaseV4 struct {
DeliveryServiceCapabilities []string `json:"-" db:"deliveryservice_capabilities"`
}
+// DSServerBaseV5 contains the base information for a Delivery Service Server associated with APIv5.
+type DSServerBaseV5 = DSServerBaseV50
+
+// DSServerBaseV50 contains the base information for a Delivery Service Server for the latest minor version associated with APIv50.
Review Comment:
latest `major` version not `minor`
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -205,6 +255,15 @@ type DSServerResponseV40 struct {
// API version 4.
type DSServerResponseV4 = DSServerResponseV40
+// DSServerResponseV50 is response from Traffic Ops to a request for servers assigned to a Delivery Service - in the latest minor version APIv50.
Review Comment:
latest `major` version not `minor`
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -180,6 +221,15 @@ type DSServer struct {
ServerInterfaces *[]ServerInterfaceInfo `json:"interfaces" db:"interfaces"`
}
+// DSServerV5 contains information of Delivery Service Server associated with APIv5.
+type DSServerV5 = DSServerV50
+
+// DSServerV50 contains information for a Delivery Service Server for the latest minor version associated with APIv50.
Review Comment:
latest `major` version not `minor`
##########
docs/source/api/v5/deliveryservices_id_servers.rst:
##########
@@ -70,7 +70,7 @@ Response Structure
:gateway: The IPv4 or IPv6 gateway address of the server - applicable for the interface ``name``
:service_address: A boolean determining if content will be routed to the IP address
-:lastUpdated: The time and date at which this server was last updated, in :ref:`non-rfc-datetime`
Review Comment:
Did the JSON response not need an updated timestamp representing RFC3339?
##########
docs/source/api/v5/deliveryservices_id_servers_eligible.rst:
##########
@@ -76,7 +76,7 @@ Response Structure
:gateway: The IPv4 or IPv6 gateway address of the server - applicable for the interface ``name``
:service_address: A boolean determining if content will be routed to the IP address
-:lastUpdated: The time and date at which this server was last updated, in :ref:`non-rfc-datetime`
Review Comment:
Did the JSON response not need an updated timestamp representing RFC3339?
##########
traffic_ops/traffic_ops_golang/deliveryservice/eligible.go:
##########
@@ -96,6 +99,22 @@ func GetServersEligible(w http.ResponseWriter, r *http.Request) {
api.WriteResp(w, r, v3ServerList)
return
}
+
+ // Based on version we load Delivery Service Eligible Server - for version 5 and above we use DSServerV5
+ if inf.Version.GreaterThanOrEqualTo(&api.Version{Major: 5, Minor: 0}) {
+
+ serverList := make([]tc.DSServerV5, len(servers))
+
+ for i, dss := range servers {
+ r := time.Unix(dss.LastUpdated.Unix(), 0)
Review Comment:
This variable name is confusing with the `http.Request` object.
##########
lib/go-tc/federation_resolver.go:
##########
@@ -72,7 +72,7 @@ type FederationResolversResponseV50 struct {
Response []FederationResolverV5 `json:"response"`
}
-// FederationResolverResponseV50 - represents struct response used for the latest minor version associated with APIv5.
+// FederationResolverResponseV5 - represents struct response used for the latest minor version associated with APIv5.
Review Comment:
latest `major` version not `minor`
##########
traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go:
##########
@@ -724,6 +724,21 @@ func GetReadAssigned(w http.ResponseWriter, r *http.Request) {
api.WriteAlertsObj(w, r, http.StatusOK, alerts, v3ServerList)
return
}
+
+ // Based on version we load Delivery Service Server - for version 5 and above we use DSServerV5
Review Comment:
Since you are using the same logic in two places, can it not be combined in a function call?
--
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 #7660: Fix `/deliveryservices/{{ID}}/servers` and `/deliveryservices/{{ID}}/servers/eligible` to use RFC3339 timestamps
Posted by "ocket8888 (via GitHub)" <gi...@apache.org>.
ocket8888 commented on code in PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#discussion_r1279438075
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -205,6 +205,26 @@ type DSServerResponseV40 struct {
// API version 4.
type DSServerResponseV4 = DSServerResponseV40
+// DSServerV5 is an alias for the latest minor version of the major version 5.
+type DSServerV5 = DSServerV50
+
+// DSServerV50 contains information for a Delivery Service Server.
+type DSServerV50 struct {
+ DSServerBase
+ LastUpdated *time.Time `json:"lastUpdated" db:"last_updated"`
+ ProfileNames []string `json:"profileNames" db:"profile_name"`
+ ServerInterfaces *[]ServerInterfaceInfoV40 `json:"interfaces" db:"interfaces"`
+}
Review Comment:
`DSServerBase` includes a `LastUpdated` field of a different type than the one described here, which could be confusing. Also I don't really want to start keeping track of everything added after some arbitrary date separately from everything else. Also also, `DSServerV50` now includes properties it doesn't have, for example: `ProfileDesc` (playground showing this happening: https://go.dev/play/p/WWwNPqJAyS3). You _could_ write an entire custom JSON marshaling and unmarshaling method pair, or you could just embed the non-DSS portion of the server as a ServerV50 - which will encode with RFC3339 timestamps - and make your type into a thin wrapper around that with the additional information provided by "Delivery Service Servers".
--
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