This is an automated email from the ASF dual-hosted git repository.
mattjackson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 30aac0e Null lat/long should be converted to 0 (#6442)
30aac0e is described below
commit 30aac0e6485271397b7c109c3e560676cefa734c
Author: Srijeet Chatterjee <[email protected]>
AuthorDate: Mon Jan 3 13:50:32 2022 -0700
Null lat/long should be converted to 0 (#6442)
---
CHANGELOG.md | 1 +
traffic_ops/testing/api/v4/cachegroups_test.go | 28 ++++++++++++++++++++++
traffic_ops/testing/api/v4/tc-fixtures.json | 5 ++++
.../traffic_ops_golang/cachegroup/cachegroups.go | 13 ++++++++++
4 files changed, 47 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f1759e1..83ba11e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,7 @@ The format is based on [Keep a
Changelog](http://keepachangelog.com/en/1.0.0/).
- [#6209](https://github.com/apache/trafficcontrol/pull/6209) Updated Traffic
Router to use Java 11 to compile and run
- [#5893](https://github.com/apache/trafficcontrol/issues/5893) - A self
signed certificate is created when an HTTPS delivery service is created or an
HTTP delivery service is updated to HTTPS.
- [#6255](https://github.com/apache/trafficcontrol/issues/6255) - Unreadable
Prod Mode CDN Notifications in Traffic Portal
+- [#6378](https://github.com/apache/trafficcontrol/issues/6378) - Cannot
update or delete Cache Groups with null latitude and longitude.
- Fixed broken `GET /cdns/routing` Traffic Ops API
- [#6259](https://github.com/apache/trafficcontrol/issues/6259) - Traffic
Portal No Longer Allows Spaces in Server Object "Router Port Name"
- [#6392](https://github.com/apache/trafficcontrol/issues/6392) - Traffic Ops
prevents assigning ORG servers to topology-based delivery services (as well as
a number of other valid operations being prohibited by "last server assigned to
DS" validations which don't apply to topology-based delivery services)
diff --git a/traffic_ops/testing/api/v4/cachegroups_test.go
b/traffic_ops/testing/api/v4/cachegroups_test.go
index b2eb675..e956d3b 100644
--- a/traffic_ops/testing/api/v4/cachegroups_test.go
+++ b/traffic_ops/testing/api/v4/cachegroups_test.go
@@ -32,6 +32,7 @@ import (
func TestCacheGroups(t *testing.T) {
WithObjs(t, []TCObj{Types, Parameters, CacheGroups, CDNs, Profiles,
Statuses, Divisions, Regions, PhysLocations, Servers, Topologies}, func() {
+ ReadUpdateTestCacheGroupWithNullLatLong(t)
GetTestCacheGroupsIMS(t)
GetTestCacheGroupsByNameIMS(t)
GetTestCacheGroupsByShortNameIMS(t)
@@ -62,6 +63,33 @@ func TestCacheGroups(t *testing.T) {
})
}
+func ReadUpdateTestCacheGroupWithNullLatLong(t *testing.T) {
+ opts := client.NewRequestOptions()
+ opts.QueryParameters.Add("name", "nullLatLongCG")
+ resp, _, err := TOSession.GetCacheGroups(opts)
+ if err != nil {
+ t.Fatalf("expected no error GETting cachegroups, but got %v",
err)
+ }
+ if len(resp.Response) != 1 {
+ t.Fatalf("expected just one cachegroup, but got %d",
len(resp.Response))
+ }
+ cg := resp.Response[0]
+ if cg.ID == nil {
+ t.Fatalf("got nil ID")
+ }
+ if cg.Latitude == nil || cg.Longitude == nil {
+ t.Fatalf("expected lat/long to be not nil")
+ }
+ if *cg.Latitude != 0 || *cg.Longitude != 0 {
+ t.Errorf("expected lat/long to be 0 and 0, but got %f and %f",
*cg.Latitude, *cg.Longitude)
+ }
+ cg.FallbackToClosest = util.BoolPtr(false)
+ _, _, err = TOSession.UpdateCacheGroup(*cg.ID, cg,
client.NewRequestOptions())
+ if err != nil {
+ t.Errorf("expected no error updating a cachegroup with null
lat/long, but got %v", err)
+ }
+}
+
func UpdateCachegroupWithLocks(t *testing.T) {
var cdnName string
servers := make([]tc.ServerV40, 0)
diff --git a/traffic_ops/testing/api/v4/tc-fixtures.json
b/traffic_ops/testing/api/v4/tc-fixtures.json
index bc3b173..4ae1fd0 100644
--- a/traffic_ops/testing/api/v4/tc-fixtures.json
+++ b/traffic_ops/testing/api/v4/tc-fixtures.json
@@ -249,6 +249,11 @@
"name": "cdn1-only",
"shortName": "cdn1-only",
"typeName": "EDGE_LOC"
+ },
+ {
+ "name": "nullLatLongCG",
+ "shortName": "null-ll",
+ "typeName": "EDGE_LOC"
}
],
"cdns": [
diff --git a/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
b/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
index b6c794e..262518a 100644
--- a/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
+++ b/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
@@ -279,6 +279,12 @@ func (cg TOCacheGroup) Validate() error {
//to be added to the struct
func (cg *TOCacheGroup) Create() (error, error, int) {
+ if cg.Latitude == nil {
+ cg.Latitude = util.FloatPtr(0.0)
+ }
+ if cg.Longitude == nil {
+ cg.Longitude = util.FloatPtr(0.0)
+ }
if cg.LocalizationMethods == nil {
cg.LocalizationMethods = &[]tc.LocalizationMethod{}
}
@@ -619,6 +625,13 @@ LEFT JOIN cachegroup AS cgs ON
cachegroup.secondary_parent_cachegroup_id = cgs.i
//The TOCacheGroup implementation of the Updater interface
func (cg *TOCacheGroup) Update(h http.Header) (error, error, int) {
+ if cg.Latitude == nil {
+ cg.Latitude = util.FloatPtr(0.0)
+ }
+ if cg.Longitude == nil {
+ cg.Longitude = util.FloatPtr(0.0)
+ }
+
if cg.LocalizationMethods == nil {
cg.LocalizationMethods = &[]tc.LocalizationMethod{}
}