You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/07/19 17:22:05 UTC
[trafficcontrol] branch master updated: Fix DS servers
ReplaceHandler
This is an automated email from the ASF dual-hosted git repository.
mitchell852 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 7ae54a0 Fix DS servers ReplaceHandler
7ae54a0 is described below
commit 7ae54a0a80b3eec725910b60294e24d4e832d39d
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Jul 19 10:51:43 2018 -0600
Fix DS servers ReplaceHandler
Use tx.Exec not tx.Queryx for a DELETE statement that returns no rows.
The unclosed Rows struct was making the subsequent tx.NamedQuery() call
fail.
---
lib/go-tc/deliveryservices.go | 2 +-
traffic_ops/testing/api/v13/todb.go | 2 ++
traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go | 4 +---
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/go-tc/deliveryservices.go b/lib/go-tc/deliveryservices.go
index d0429e7..1a5d1e4 100644
--- a/lib/go-tc/deliveryservices.go
+++ b/lib/go-tc/deliveryservices.go
@@ -586,7 +586,7 @@ type UserDeliveryServicesResponse struct {
}
type DSServerIDs struct {
- DeliveryServiceID *int `json:"dsId", db:"deliveryservice"`
+ DeliveryServiceID *int `json:"dsId" db:"deliveryservice"`
ServerIDs []int `json:"servers"`
Replace *bool `json:"replace"`
}
diff --git a/traffic_ops/testing/api/v13/todb.go b/traffic_ops/testing/api/v13/todb.go
index 6936194..3761ada 100644
--- a/traffic_ops/testing/api/v13/todb.go
+++ b/traffic_ops/testing/api/v13/todb.go
@@ -239,6 +239,7 @@ func Teardown(db *sql.DB) error {
DELETE FROM regex;
DELETE FROM deliveryservice_server;
DELETE FROM deliveryservice;
+ DELETE FROM origin;
DELETE FROM server;
DELETE FROM phys_location;
DELETE FROM region;
@@ -247,6 +248,7 @@ func Teardown(db *sql.DB) error {
DELETE FROM parameter;
DELETE FROM profile_parameter;
DELETE FROM cachegroup;
+ DELETE FROM coordinate;
DELETE FROM type;
DELETE FROM status;
DELETE FROM snapshot;
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
index 748ceae..5f6977e 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
@@ -368,14 +368,12 @@ func GetReplaceHandler(db *sqlx.DB) http.HandlerFunc {
if *payload.Replace {
// delete existing
- rows, err := tx.Queryx("DELETE FROM deliveryservice_server WHERE deliveryservice = $1", *dsId)
+ _, err := tx.Exec("DELETE FROM deliveryservice_server WHERE deliveryservice = $1", *dsId)
if err != nil {
log.Errorf("unable to remove the existing servers assigned to the delivery service: %s", err)
handleErrs(http.StatusInternalServerError, err)
return
}
-
- defer rows.Close()
}
i := 0