zrhoffman commented on a change in pull request #4907:
URL: https://github.com/apache/trafficcontrol/pull/4907#discussion_r467985008
##########
File path: traffic_ops/testing/api/v3/servers_test.go
##########
@@ -16,13 +16,19 @@ package v3
*/
import (
+
Review comment:
`gofmt` removes this line
##########
File path: traffic_ops/traffic_ops_golang/server/servers.go
##########
@@ -26,14 +26,15 @@ import (
"encoding/json"
"errors"
"fmt"
- "github.com/apache/trafficcontrol/lib/go-rfc"
-
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/util/ims"
"net"
"net/http"
"strconv"
"strings"
"time"
+ "github.com/apache/trafficcontrol/lib/go-rfc"
+
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/util/ims"
+
Review comment:
These newlines between ATC package imports can be removed
##########
File path: traffic_ops/testing/api/v3/servers_test.go
##########
@@ -16,13 +16,19 @@ package v3
*/
import (
+
"fmt"
- "github.com/apache/trafficcontrol/lib/go-rfc"
"net/http"
"net/url"
"strconv"
"testing"
"time"
+
+ "github.com/apache/trafficcontrol/lib/go-util"
+
+ "github.com/apache/trafficcontrol/lib/go-tc"
+
Review comment:
These newlines between ATC package imports can be removed
##########
File path: traffic_ops/traffic_ops_golang/server/servers.go
##########
@@ -485,6 +490,39 @@ func validateV3(s *tc.ServerNullable, tx *sql.Tx) (string,
error) {
}
errs = append(errs, validateCommon(&s.CommonServerProperties, tx)...)
+
+ query := `
+SELECT s.ID, ip.address FROM server s
+JOIN profile p on p.Id = s.Profile
+JOIN interface i on i.server = s.ID
+JOIN ip_address ip on ip.Server = s.ID and ip.interface = i.name
+WHERE i.monitor = true
+and p.id = $1
+`
+ var rows *sql.Rows
+ var err error
+ //ProfileID already validated
+ if s.ID != nil {
+ rows, err = tx.Query(query+" and s.id != $2", *s.ProfileID,
*s.ID)
+ } else {
+ rows, err = tx.Query(query, *s.ProfileID)
+ }
+ if err != nil {
+ errs = append(errs, errors.New("unable to determine service
address uniqueness"))
+ } else if rows != nil {
+ defer rows.Close()
+ for rows.Next() {
+ var id int
+ var ipaddress string
+ err = rows.Scan(&id, &ipaddress)
+ if err != nil {
+ errs = append(errs, errors.New("unable to
determine service address uniqueness"))
+ } else if (ipaddress == ipv4 || ipaddress == ipv6) &&
(s.ID == nil || *s.ID != id) {
+ errs = append(errs, errors.New("there exists a
server on the same profile that has the same service address"))
Review comment:
This error should include the IP addresses and IDs being compared.
----------------------------------------------------------------
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:
[email protected]