zrhoffman commented on a change in pull request #5144:
URL: https://github.com/apache/trafficcontrol/pull/5144#discussion_r504821754
##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -146,13 +149,61 @@ func (topology *TOTopology) Validate() error {
return util.JoinErrs(tovalidate.ToErrors(rules))
}
+func (topology *TOTopology) checkForEmptyCacheGroups() error {
+ var (
+ cacheGroupNames = make([]string, len(topology.Nodes))
+ baseError = errors.New("unable to check for cachegroups
with no servers")
+ systemError = "checking for cachegroups with no servers: %s"
+ parameters = map[string]interface{}{}
+ query = selectEmptyCacheGroupsQuery()
+ )
+ for index, node := range topology.Nodes {
+ cacheGroupNames[index] = node.Cachegroup
+ }
+ parameters["cachegroup_names"] = pq.Array(cacheGroupNames)
+
+ rows, err := topology.ReqInfo.Tx.NamedQuery(query, parameters)
+ if err != nil {
+ log.Errorf(systemError, err.Error())
+ return baseError
+ }
+
+ var (
+ serverCount int
+ cacheGroup string
+ cacheGroups []string
+ )
+ defer log.Close(rows, "unable to close DB connection when checking for
cachegroups with no servers")
+ for rows.Next() {
+ if err := rows.Scan(&cacheGroup, &serverCount); err != nil {
+ log.Errorf(systemError, err.Error())
+ return baseError
+ }
+ if serverCount != 0 {
+ break
+ }
+ cacheGroups = append(cacheGroups, cacheGroup)
+ }
+
+ if cacheGroups != nil {
Review comment:
Rewrote condition in 9f7b44cf5
----------------------------------------------------------------
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]