You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ne...@apache.org on 2017/03/02 03:39:40 UTC

[1/7] incubator-trafficcontrol git commit: reject to delete cdn if server or ds associated

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master ff950d4ec -> 992f0cd85


reject to delete cdn if server or ds associated


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c87e8437
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c87e8437
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c87e8437

Branch: refs/heads/master
Commit: c87e843725f99aa86dc7d6688fbd662a07877980
Parents: c824778
Author: Zhilin Huang <zh...@cisco.com>
Authored: Mon Feb 27 14:45:37 2017 +0800
Committer: David Neuman <da...@gmail.com>
Committed: Wed Mar 1 20:39:10 2017 -0700

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/Cdn.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c87e8437/traffic_ops/app/lib/UI/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Cdn.pm b/traffic_ops/app/lib/UI/Cdn.pm
index d9f9d80..c27c9a7 100644
--- a/traffic_ops/app/lib/UI/Cdn.pm
+++ b/traffic_ops/app/lib/UI/Cdn.pm
@@ -160,6 +160,16 @@ sub delete {
         $self->flash( alertmsg => "You must be an ADMIN to perform this operation!" );
     }
     else {
+        my $server_count = $self->db->resultset('Server')->search( { cdn_id => $id } )->count();
+        if ($server_count > 0) {
+            $self->flash( alertmsg => "Failed to delete cdn id = $id has servers." );
+            return $self->redirect_to('/close_fancybox.html');
+        }
+        my $ds_count = $self->db->resultset('Deliveryservice')->search( { cdn_id => $id } )->count();
+        if ($ds_count > 0) {
+            $self->flash( alertmsg => "Failed to delete cdn id = $id has delivery services." );
+            return $self->redirect_to('/close_fancybox.html');
+        }
         my $p_name = $self->db->resultset('Cdn')->search( { id => $id } )->get_column('name')->single();
         my $delete = $self->db->resultset('Cdn')->search( { id => $id } );
         $delete->delete();


[6/7] incubator-trafficcontrol git commit: This closes #320

Posted by ne...@apache.org.
This closes #320


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/ce2f2b8f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/ce2f2b8f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/ce2f2b8f

Branch: refs/heads/master
Commit: ce2f2b8f5487c476bf4f5db1e384338893b389ce
Parents: c87e843
Author: David Neuman <da...@gmail.com>
Authored: Wed Mar 1 20:39:21 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Wed Mar 1 20:39:21 2017 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------



[4/7] incubator-trafficcontrol git commit: Fix TM2 incorrect comment

Posted by ne...@apache.org.
Fix TM2 incorrect comment


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c8247785
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c8247785
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c8247785

Branch: refs/heads/master
Commit: c8247785cb4341de4038e065724b3875bbd79146
Parents: fc667c8
Author: Robert Butts <ro...@gmail.com>
Authored: Tue Feb 28 10:42:37 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Wed Mar 1 20:39:10 2017 -0700

----------------------------------------------------------------------
 traffic_monitor_golang/traffic_monitor/peer/crstates.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c8247785/traffic_monitor_golang/traffic_monitor/peer/crstates.go
----------------------------------------------------------------------
diff --git a/traffic_monitor_golang/traffic_monitor/peer/crstates.go b/traffic_monitor_golang/traffic_monitor/peer/crstates.go
index efa40a9..6919e37 100644
--- a/traffic_monitor_golang/traffic_monitor/peer/crstates.go
+++ b/traffic_monitor_golang/traffic_monitor/peer/crstates.go
@@ -229,7 +229,7 @@ func (t *CRStatesPeersThreadsafe) GetPeerAvailability(peer enum.TrafficMonitorNa
 	return availability
 }
 
-// GetPeerAvailability returns the state of the given peer
+// GetQueryTimes returns the last query time of all peers
 func (t *CRStatesPeersThreadsafe) GetQueryTimes() map[enum.TrafficMonitorName]time.Time {
 	t.m.RLock()
 	defer t.m.RUnlock()


[3/7] incubator-trafficcontrol git commit: Add TM2 Stats endpoint cache poll 95th percentile

Posted by ne...@apache.org.
Add TM2 Stats endpoint cache poll 95th percentile


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c877c07b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c877c07b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c877c07b

Branch: refs/heads/master
Commit: c877c07b179febf540d99cb8e3bd9db9c7aab23c
Parents: ad97540
Author: Robert Butts <ro...@gmail.com>
Authored: Mon Feb 27 15:30:27 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Wed Mar 1 20:39:10 2017 -0700

----------------------------------------------------------------------
 .../traffic_monitor/manager/datarequest.go      | 77 ++++++++++++++------
 .../traffic_monitor/version.go                  |  2 +-
 2 files changed, 54 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c877c07b/traffic_monitor_golang/traffic_monitor/manager/datarequest.go
----------------------------------------------------------------------
diff --git a/traffic_monitor_golang/traffic_monitor/manager/datarequest.go b/traffic_monitor_golang/traffic_monitor/manager/datarequest.go
index 1b5bd9e..b94b610 100644
--- a/traffic_monitor_golang/traffic_monitor/manager/datarequest.go
+++ b/traffic_monitor_golang/traffic_monitor/manager/datarequest.go
@@ -26,6 +26,7 @@ import (
 	"net/http"
 	"net/url"
 	"runtime"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -1092,30 +1093,31 @@ type JSONStats struct {
 
 // Stats contains statistics data about this running app. Designed to be returned via an API endpoint.
 type Stats struct {
-	MaxMemoryMB         uint64 `json:"Max Memory (MB),string"`
-	GitRevision         string `json:"git-revision"`
-	ErrorCount          uint64 `json:"Error Count,string"`
-	Uptime              uint64 `json:"uptime,string"`
-	FreeMemoryMB        uint64 `json:"Free Memory (MB),string"`
-	TotalMemoryMB       uint64 `json:"Total Memory (MB),string"`
-	Version             string `json:"version"`
-	DeployDir           string `json:"deploy-dir"`
-	FetchCount          uint64 `json:"Fetch Count,string"`
-	QueryIntervalDelta  int    `json:"Query Interval Delta,string"`
-	IterationCount      uint64 `json:"Iteration Count,string"`
-	Name                string `json:"name"`
-	BuildTimestamp      string `json:"buildTimestamp"`
-	QueryIntervalTarget int    `json:"Query Interval Target,string"`
-	QueryIntervalActual int    `json:"Query Interval Actual,string"`
-	SlowestCache        string `json:"Slowest Cache"`
-	LastQueryInterval   int    `json:"Last Query Interval,string"`
-	Microthreads        int    `json:"Goroutines"`
-	LastGC              string `json:"Last Garbage Collection"`
-	MemAllocBytes       uint64 `json:"Memory Bytes Allocated"`
-	MemTotalBytes       uint64 `json:"Total Bytes Allocated"`
-	MemSysBytes         uint64 `json:"System Bytes Allocated"`
-	OldestPolledPeer    string `json:"Oldest Polled Peer"`
-	OldestPolledPeerMs  int64  `json:"Oldest Polled Peer Time (ms)"`
+	MaxMemoryMB                 uint64 `json:"Max Memory (MB),string"`
+	GitRevision                 string `json:"git-revision"`
+	ErrorCount                  uint64 `json:"Error Count,string"`
+	Uptime                      uint64 `json:"uptime,string"`
+	FreeMemoryMB                uint64 `json:"Free Memory (MB),string"`
+	TotalMemoryMB               uint64 `json:"Total Memory (MB),string"`
+	Version                     string `json:"version"`
+	DeployDir                   string `json:"deploy-dir"`
+	FetchCount                  uint64 `json:"Fetch Count,string"`
+	QueryIntervalDelta          int    `json:"Query Interval Delta,string"`
+	IterationCount              uint64 `json:"Iteration Count,string"`
+	Name                        string `json:"name"`
+	BuildTimestamp              string `json:"buildTimestamp"`
+	QueryIntervalTarget         int    `json:"Query Interval Target,string"`
+	QueryIntervalActual         int    `json:"Query Interval Actual,string"`
+	SlowestCache                string `json:"Slowest Cache"`
+	LastQueryInterval           int    `json:"Last Query Interval,string"`
+	Microthreads                int    `json:"Goroutines"`
+	LastGC                      string `json:"Last Garbage Collection"`
+	MemAllocBytes               uint64 `json:"Memory Bytes Allocated"`
+	MemTotalBytes               uint64 `json:"Total Bytes Allocated"`
+	MemSysBytes                 uint64 `json:"System Bytes Allocated"`
+	OldestPolledPeer            string `json:"Oldest Polled Peer"`
+	OldestPolledPeerMs          int64  `json:"Oldest Polled Peer Time (ms)"`
+	QueryInterval95thPercentile int64  `json:"Query Interval 95th Percentile (ms)"`
 }
 
 func getLongestPoll(lastHealthTimes map[enum.CacheName]time.Duration) (enum.CacheName, time.Duration) {
@@ -1148,6 +1150,31 @@ func oldestPeerPollTime(peerTimes map[enum.TrafficMonitorName]time.Time) (enum.T
 
 const MillisecondsPerNanosecond = int64(1000000)
 
+type Durations []time.Duration
+
+func (s Durations) Len() int {
+	return len(s)
+}
+func (s Durations) Less(i, j int) bool {
+	return s[i] < s[j]
+}
+func (s Durations) Swap(i, j int) {
+	s[i], s[j] = s[j], s[i]
+}
+
+// getCacheTimePercentile returns the given percentile of cache result times. The `percentile` should be a decimal percent, for example, for the 95th percentile pass 0.95
+func getCacheTimePercentile(lastHealthTimes map[enum.CacheName]time.Duration, percentile float64) time.Duration {
+	times := make([]time.Duration, 0, len(lastHealthTimes))
+	for _, t := range lastHealthTimes {
+		times = append(times, t)
+	}
+	sort.Sort(Durations(times))
+
+	n := int(float64(len(lastHealthTimes)) * percentile)
+
+	return times[n]
+}
+
 func getStats(staticAppData StaticAppData, pollingInterval time.Duration, lastHealthTimes map[enum.CacheName]time.Duration, fetchCount uint64, healthIteration uint64, errorCount uint64, peerStates peer.CRStatesPeersThreadsafe) ([]byte, error) {
 	longestPollCache, longestPollTime := getLongestPoll(lastHealthTimes)
 	var memStats runtime.MemStats
@@ -1181,6 +1208,8 @@ func getStats(staticAppData StaticAppData, pollingInterval time.Duration, lastHe
 	s.OldestPolledPeer = string(oldestPolledPeer)
 	s.OldestPolledPeerMs = time.Now().Sub((oldestPolledPeerTime)).Nanoseconds() / MillisecondsPerNanosecond
 
+	s.QueryInterval95thPercentile = getCacheTimePercentile(lastHealthTimes, 0.95).Nanoseconds() / MillisecondsPerNanosecond
+
 	return json.Marshal(JSONStats{Stats: s})
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c877c07b/traffic_monitor_golang/traffic_monitor/version.go
----------------------------------------------------------------------
diff --git a/traffic_monitor_golang/traffic_monitor/version.go b/traffic_monitor_golang/traffic_monitor/version.go
index e9738e5..4d7eef9 100644
--- a/traffic_monitor_golang/traffic_monitor/version.go
+++ b/traffic_monitor_golang/traffic_monitor/version.go
@@ -20,4 +20,4 @@ package main
  */
 
 // Version is the current version of the app, in string form.
-var Version = "2.0.6"
+var Version = "2.0.7"


[5/7] incubator-trafficcontrol git commit: Fix TM2 global variable to be a safe local

Posted by ne...@apache.org.
Fix TM2 global variable to be a safe local

This wasn't technically a thread safety issue, because the integer was
only ever checked as a boolean. But it's a dangerous precedent, as in
most cases this design pattern would be unsafe. Changing it to a local
variable, and making the function 'pure', is generally safer, easier
to understand, and doesn't give anyone the idea that pattern is okay.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/fc667c8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/fc667c8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/fc667c8c

Branch: refs/heads/master
Commit: fc667c8c0ff4b1a34327cc28b5f0e3f6544dc786
Parents: 391dc6f
Author: Robert Butts <ro...@gmail.com>
Authored: Mon Feb 27 16:14:37 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Wed Mar 1 20:39:10 2017 -0700

----------------------------------------------------------------------
 .../traffic_monitor/manager/monitorconfig.go          | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/fc667c8c/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
----------------------------------------------------------------------
diff --git a/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go b/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
index f8e2f87..6d5748a 100644
--- a/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
+++ b/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
@@ -138,13 +138,11 @@ func trafficOpsHealthPollIntervalToDuration(t int) time.Duration {
 	return time.Duration(t) * time.Millisecond
 }
 
-var healthPollCount int
-
 // PollIntervalRatio is the ratio of the configuration interval to poll. The configured intervals are 'target' times, so we actually poll at some small fraction less, in attempt to make the actual poll marginally less than the target.
 const PollIntervalRatio = float64(0.97) // TODO make config?
 
 // getPollIntervals reads the Traffic Ops Client monitorConfig structure, and parses and returns the health, peer, and stat poll intervals
-func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap, cfg config.Config) (time.Duration, time.Duration, time.Duration, error) {
+func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap, cfg config.Config, logMissingHeartbeatParam bool) (time.Duration, time.Duration, time.Duration, error) {
 	peerPollIntervalI, peerPollIntervalExists := monitorConfig.Config["peers.polling.interval"]
 	if !peerPollIntervalExists {
 		return 0, 0, 0, fmt.Errorf("Traffic Ops Monitor config missing 'peers.polling.interval', not setting config changes.\n")
@@ -168,9 +166,8 @@ func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap, cf
 	healthPollIntervalI, healthPollIntervalExists := monitorConfig.Config["heartbeat.polling.interval"]
 	healthPollIntervalInt, healthPollIntervalIsInt := healthPollIntervalI.(float64)
 	if !healthPollIntervalExists {
-		if healthPollCount == 0 { //only log this once
+		if logMissingHeartbeatParam {
 			log.Warnln("Traffic Ops Monitor config missing 'heartbeat.polling.interval', using health for heartbeat.")
-			healthPollCount++
 		}
 		healthPollIntervalInt = statPollIntervalInt
 	} else if !healthPollIntervalIsInt {
@@ -206,6 +203,9 @@ func monitorConfigListen(
 		}
 		os.Exit(1) // The Monitor can't run without a MonitorConfigManager
 	}()
+
+	logMissingHeartbeatParam := true
+
 	for monitorConfig := range monitorConfigPollChan {
 		monitorConfigTS.Set(monitorConfig)
 		healthURLs := map[string]poller.PollConfig{}
@@ -213,7 +213,9 @@ func monitorConfigListen(
 		peerURLs := map[string]poller.PollConfig{}
 		caches := map[string]string{}
 
-		healthPollInterval, peerPollInterval, statPollInterval, err := getHealthPeerStatPollIntervals(monitorConfig, cfg)
+		healthPollInterval, peerPollInterval, statPollInterval, err := getHealthPeerStatPollIntervals(monitorConfig, cfg, logMissingHeartbeatParam)
+		logMissingHeartbeatParam = false // only log the heartbeat parameter missing once
+
 		if err != nil {
 			log.Errorf("monitor config error getting polling intervals, can't poll: %v", err)
 			continue


[2/7] incubator-trafficcontrol git commit: Change TM2 to poll slightly under targets

Posted by ne...@apache.org.
Change TM2 to poll slightly under targets


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/391dc6fa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/391dc6fa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/391dc6fa

Branch: refs/heads/master
Commit: 391dc6fa3b39f4556f7cb3878b558bea7786f93e
Parents: c877c07
Author: Robert Butts <ro...@gmail.com>
Authored: Mon Feb 27 15:53:58 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Wed Mar 1 20:39:10 2017 -0700

----------------------------------------------------------------------
 .../traffic_monitor/manager/monitorconfig.go                   | 6 ++++++
 traffic_monitor_golang/traffic_monitor/version.go              | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/391dc6fa/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
----------------------------------------------------------------------
diff --git a/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go b/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
index bb1c049..f8e2f87 100644
--- a/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
+++ b/traffic_monitor_golang/traffic_monitor/manager/monitorconfig.go
@@ -140,6 +140,9 @@ func trafficOpsHealthPollIntervalToDuration(t int) time.Duration {
 
 var healthPollCount int
 
+// PollIntervalRatio is the ratio of the configuration interval to poll. The configured intervals are 'target' times, so we actually poll at some small fraction less, in attempt to make the actual poll marginally less than the target.
+const PollIntervalRatio = float64(0.97) // TODO make config?
+
 // getPollIntervals reads the Traffic Ops Client monitorConfig structure, and parses and returns the health, peer, and stat poll intervals
 func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap, cfg config.Config) (time.Duration, time.Duration, time.Duration, error) {
 	peerPollIntervalI, peerPollIntervalExists := monitorConfig.Config["peers.polling.interval"]
@@ -176,6 +179,9 @@ func getHealthPeerStatPollIntervals(monitorConfig to.TrafficMonitorConfigMap, cf
 	}
 	healthPollInterval := trafficOpsHealthPollIntervalToDuration(int(healthPollIntervalInt))
 
+	healthPollInterval = time.Duration(float64(healthPollInterval) * PollIntervalRatio)
+	peerPollInterval = time.Duration(float64(peerPollInterval) * PollIntervalRatio)
+	statPollInterval = time.Duration(float64(statPollInterval) * PollIntervalRatio)
 	return healthPollInterval, peerPollInterval, statPollInterval, nil
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/391dc6fa/traffic_monitor_golang/traffic_monitor/version.go
----------------------------------------------------------------------
diff --git a/traffic_monitor_golang/traffic_monitor/version.go b/traffic_monitor_golang/traffic_monitor/version.go
index 4d7eef9..bbabbd6 100644
--- a/traffic_monitor_golang/traffic_monitor/version.go
+++ b/traffic_monitor_golang/traffic_monitor/version.go
@@ -20,4 +20,4 @@ package main
  */
 
 // Version is the current version of the app, in string form.
-var Version = "2.0.7"
+var Version = "2.0.8"


[7/7] incubator-trafficcontrol git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol

Posted by ne...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/992f0cd8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/992f0cd8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/992f0cd8

Branch: refs/heads/master
Commit: 992f0cd85a2860c365f69306ccd0f23328fa5d75
Parents: ce2f2b8 ff950d4
Author: David Neuman <da...@gmail.com>
Authored: Wed Mar 1 20:39:34 2017 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Wed Mar 1 20:39:34 2017 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------