You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ro...@apache.org on 2019/02/14 18:34:26 UTC

[trafficcontrol] branch master updated: Fix stale delivery services being served in /publish/CrStates

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

rob 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 94ef4a6  Fix stale delivery services being served in /publish/CrStates
94ef4a6 is described below

commit 94ef4a6a55a718136380bd03360719b6ddec790b
Author: PeterRyder <pe...@gmail.com>
AuthorDate: Mon Jan 7 12:00:41 2019 -0500

    Fix stale delivery services being served in /publish/CrStates
---
 traffic_monitor/manager/statecombiner.go | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/traffic_monitor/manager/statecombiner.go b/traffic_monitor/manager/statecombiner.go
index eab400d..2cade97 100644
--- a/traffic_monitor/manager/statecombiner.go
+++ b/traffic_monitor/manager/statecombiner.go
@@ -148,6 +148,31 @@ func combineDSState(
 	combinedStates.SetDeliveryService(deliveryServiceName, deliveryService)
 }
 
+// pruneCombinedDSState deletes delivery services in combined states which have been removed from localStates and peerStates
+func pruneCombinedDSState(combinedStates peer.CRStatesThreadsafe, localStates tc.CRStates, peerStates peer.CRStatesPeersThreadsafe) {
+	combinedCRStates := combinedStates.Get()
+
+	// remove any DS in combinedStates NOT in local states or peer states
+	for deliveryServiceName := range combinedCRStates.DeliveryService {
+		inPeer := false
+		inLocal := false
+		for _, iPeerStates := range peerStates.GetCrstates() {
+			if _, ok := iPeerStates.DeliveryService[deliveryServiceName]; ok {
+				inPeer = true
+				break
+			}
+		}
+
+		if _, ok := localStates.DeliveryService[deliveryServiceName]; ok {
+			inLocal = true
+		}
+
+		if !inPeer && !inLocal {
+			combinedStates.DeleteDeliveryService(deliveryServiceName)
+		}
+	}
+}
+
 // pruneCombinedCaches deletes caches in combined states which have been removed from localStates.
 func pruneCombinedCaches(combinedStates peer.CRStatesThreadsafe, localStates tc.CRStates) {
 	combinedCaches := combinedStates.GetCaches()
@@ -167,6 +192,7 @@ func combineCrStates(events health.ThreadsafeEvents, peerOptimistic bool, peerSt
 		combineDSState(deliveryServiceName, localDeliveryService, events, peerOptimistic, peerStates, localStates, combinedStates, overrideMap, toData)
 	}
 
+	pruneCombinedDSState(combinedStates, localStates, peerStates)
 	pruneCombinedCaches(combinedStates, localStates)
 }