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 92bd0ad  Fixed cachegroup deliveryservice ISE (#3566)
92bd0ad is described below

commit 92bd0add5aec9818eed601668c270958c8a2540f
Author: Matthew Allen Moltzau <[email protected]>
AuthorDate: Thu May 16 08:30:41 2019 -0600

    Fixed cachegroup deliveryservice ISE (#3566)
---
 traffic_ops/traffic_ops_golang/cachegroup/dspost.go | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/cachegroup/dspost.go 
b/traffic_ops/traffic_ops_golang/cachegroup/dspost.go
index ad112cb..6d3afc9 100644
--- a/traffic_ops/traffic_ops_golang/cachegroup/dspost.go
+++ b/traffic_ops/traffic_ops_golang/cachegroup/dspost.go
@@ -63,9 +63,12 @@ func DSPostHandler(w http.ResponseWriter, r *http.Request) {
 
 // postDSes returns the post response, any user error, any system error, and 
the HTTP status code to be returned in the event of an error.
 func postDSes(tx *sql.Tx, user *auth.CurrentUser, cgID int64, dsIDs []int64) 
(tc.CacheGroupPostDSResp, error, error, int) {
-       cdnName, err := getCachegroupCDN(tx, cgID)
-       if err != nil {
-               return tc.CacheGroupPostDSResp{}, nil, errors.New("getting 
cachegroup CDN: " + err.Error()), http.StatusInternalServerError
+       cdnName, usrErr, sysErr, errCode := getCachegroupCDN(tx, cgID)
+       if sysErr != nil {
+               sysErr = errors.New("getting cachegroup CDN: " + sysErr.Error())
+       }
+       if usrErr != nil || sysErr != nil {
+               return tc.CacheGroupPostDSResp{}, usrErr, sysErr, errCode
        }
 
        tenantIDs, err := getDSTenants(tx, dsIDs)
@@ -157,7 +160,7 @@ AND cdn.name <> $2::text
        return nil
 }
 
-func getCachegroupCDN(tx *sql.Tx, cgID int64) (string, error) {
+func getCachegroupCDN(tx *sql.Tx, cgID int64) (string, error, error, int) {
        q := `
 SELECT cdn.name
 FROM cdn
@@ -168,26 +171,26 @@ AND (type.name LIKE 'EDGE%' OR type.name LIKE 'ORG%')
 `
        rows, err := tx.Query(q, cgID)
        if err != nil {
-               return "", errors.New("selecting cachegroup CDNs: " + 
err.Error())
+               return "", nil, errors.New("selecting cachegroup CDNs: " + 
err.Error()), http.StatusInternalServerError
        }
        defer rows.Close()
        cdn := ""
        for rows.Next() {
                serverCDN := ""
                if err := rows.Scan(&serverCDN); err != nil {
-                       return "", errors.New("scanning cachegroup CDN: " + 
err.Error())
+                       return "", nil, errors.New("scanning cachegroup CDN: " 
+ err.Error()), http.StatusInternalServerError
                }
                if cdn == "" {
                        cdn = serverCDN
                }
                if cdn != serverCDN {
-                       return "", errors.New("cachegroup servers have 
different CDNs '" + cdn + "' and '" + serverCDN + "'")
+                       return "", nil, errors.New("cachegroup servers have 
different CDNs '" + cdn + "' and '" + serverCDN + "'"), 
http.StatusInternalServerError
                }
        }
        if cdn == "" {
-               return "", errors.New("no edge or origin servers found on 
cachegroup " + strconv.FormatInt(cgID, 10))
+               return "", errors.New("no edge or origin servers found on 
cachegroup " + strconv.FormatInt(cgID, 10)), nil, http.StatusBadRequest
        }
-       return cdn, nil
+       return cdn, nil, nil, http.StatusOK
 }
 
 // updateParams updated the header rewrite, cacheurl, and regex remap params 
for the given edge caches, on the given delivery services. NOTE it does not 
update Mid params.

Reply via email to