Achilleas Tzenetopoulos 5 years ago
parent
commit
ce844b639a

+ 1 - 1
kubernetes-v1.15.4/pkg/scheduler/algorithm/priorities/custom_resource_allocation.go

@@ -120,7 +120,7 @@ func InvalidateCache() {
 
 func customResourceScorer(nodeName string) (float64, error) {
 
-	InvalidateCache()
+	//InvalidateCache()
 
 	cores, _ := Cores[nodeName]
 

+ 1 - 1
kubernetes-v1.15.4/pkg/scheduler/customcache/cache.go

@@ -6,7 +6,7 @@ import (
 )
 
 var LabCache MlabCache
-var duration int
+var duration int = 10
 
 type MlabCache struct {
 	Cache   map[string]map[string]float64

+ 11 - 0
kubernetes-v1.15.4/pkg/scheduler/scheduler.go

@@ -451,6 +451,17 @@ func (sched *Scheduler) scheduleOne() {
 	// 	customcache.LabCache.CleanCache()
 	// default:
 	// }
+	
+	// Check if the cache needs update
+	select {
+	// clean the cache if 10 seconds are passed
+	case <-customcache.LabCache.Timeout.C:
+		klog.Infof("Time to erase")
+		//customcache.LabCache.Timeout.Stop()
+		customcache.LabCache.CleanCache()
+	default:
+	}
+	
 
 	fwk := sched.config.Framework