This is an automated email from the ASF dual-hosted git repository.

zrhoffman 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 b31db78  Fixed GET api/3.1/cdns/routing endpoint to avoid incorrect 
success response (return all zeros)  (#5709)
b31db78 is described below

commit b31db78965ee66dd5abea1508f732bdc42cafe0c
Author: Rima Shah <[email protected]>
AuthorDate: Mon Apr 5 16:26:39 2021 -0600

    Fixed GET api/3.1/cdns/routing endpoint to avoid incorrect success response 
(return all zeros)  (#5709)
    
    * Added debug statements
    
    * Removed debug fmt statements and updated the return error as it was 
returning incorrect err value.
    
    * Updated TR's stat tracker to include long int
    Update CHANGELOG.md
    Removed unnecessary new lines
    
    * Updated TR's stat tracker to include long int-1
---
 CHANGELOG.md                                               |  1 +
 traffic_ops/traffic_ops_golang/crstats/routing.go          |  3 +--
 .../traffic_router/core/router/StatTracker.java            | 14 +++++++-------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index a7baeec..6fef452 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - ORT config generation: Added a rule to ip_allow such that PURGE requests are 
allowed over localhost
 
 ### Fixed
+- Fixed the return error for GET api `cdns/routing` to avoid incorrect success 
response.
 - [#2471](https://github.com/apache/trafficcontrol/issues/2471) - A PR check 
to ensure added db migration file is the latest.
 - [#5609](https://github.com/apache/trafficcontrol/issues/5609) - Fixed GET 
/servercheck filter for an extra query param.
 - [#5288](https://github.com/apache/trafficcontrol/issues/5288) - Fixed the 
ability to create and update a server with MTU value >= 1280.
diff --git a/traffic_ops/traffic_ops_golang/crstats/routing.go 
b/traffic_ops/traffic_ops_golang/crstats/routing.go
index 6a18ebc..bd720c0 100644
--- a/traffic_ops/traffic_ops_golang/crstats/routing.go
+++ b/traffic_ops/traffic_ops_golang/crstats/routing.go
@@ -102,10 +102,9 @@ func getRoutersRouting(tx *sql.Tx, routers 
map[tc.CDNName][]string, statType *st
        close(resp)
 
        dat := RouterData{}
-
        for r := range resp {
                if r.Error != nil {
-                       return tc.Routing{}, err
+                       return tc.Routing{}, r.Error
                }
                dat = addCRSStats(dat, r.Stats, statType, hostRegex)
        }
diff --git 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
index 6546b87..0aac2c9 100644
--- 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
+++ 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
@@ -318,32 +318,32 @@ public class StatTracker {
        public Map<String, Tallies> getHttpMap() {
                return httpMap;
        }
-       public int getTotalDnsCount() {
+       public long getTotalDnsCount() {
                return totalDnsCount;
        }
        public long getAverageDnsTime() {
                if(totalDnsCount==0) { return 0; }
                return totalDnsTime/totalDnsCount;
        }
-       public int getTotalHttpCount() {
+       public long getTotalHttpCount() {
                return totalHttpCount;
        }
        public long getAverageHttpTime() {
                if(totalHttpCount==0) { return 0; }
                return totalHttpTime/totalHttpCount;
        }
-       public int getTotalDsMissCount() {
+       public long getTotalDsMissCount() {
                return totalDsMissCount;
        }
-       public void setTotalDsMissCount(final int totalDsMissCount) {
+       public void setTotalDsMissCount(final long totalDsMissCount) {
                this.totalDsMissCount = totalDsMissCount;
        }
 
-       private int totalDnsCount;
+       private long totalDnsCount;
        private long totalDnsTime;
-       private int totalHttpCount;
+       private long totalHttpCount;
        private long totalHttpTime;
-       private int totalDsMissCount = 0;
+       private long totalDsMissCount = 0;
        public Map<String,Long> getUpdateTracker() {
                return TrafficRouterManager.getTimeTracker();
        }

Reply via email to