Achilleas Tzenetopoulos hace 5 años
padre
commit
aab73744b9

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

@@ -106,22 +106,23 @@ func customScoreInfluxDB(metrics []string, uuid string, socket,
 	return calculateWeightedAverage(response, numberOfRows, len(metrics))
 }
 
-// func InvalidateCache() {
-// 	// 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:
-// 	}
-// }
+func InvalidateCache() {
+	// 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")
+		klog.Infof("Cache: %v", customcache.LabCache.Cache)
+		//customcache.LabCache.Timeout.Stop()
+		customcache.LabCache.CleanCache()
+
+	default:
+	}
+}
 
 func customResourceScorer(nodeName string) (float64, error) {
 
-	//InvalidateCache()
+	InvalidateCache()
 	//klog.Infof("The value of the Ticker: %v", customcache.LabCache.Timeout.C)
 	cores, _ := Cores[nodeName]
 

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

@@ -141,12 +141,11 @@ func (c *MlabCache) CleanCache() {
 
 func (c *MlabCache) UpdateCache(input map[string]float64, c6res float64, nodename string) error {
 	c.Mux.Lock()
-	c.Cache[nodename] = map[string]float64{
-		"ipc":       input["ipc"],
-		"mem_read":  input["mem_read"],
-		"mem_write": input["mem_write"],
-		"c6res":     c6res,
-	}
+
+	c.Cache[nodename]["ipc"] = input["ipc"]
+	c.Cache[nodename]["mem_read"] = input["mem_read"]
+	c.Cache[nodename]["mem_write"] = input["mem_write"]
+	c.Cache[nodename]["c6res"] = c6res
 
 	// Reset the ticker
 	c.Timeout = time.NewTicker(time.Duration(duration) * time.Second)

+ 9 - 9
kubernetes-v1.15.4/pkg/scheduler/scheduler.go

@@ -455,15 +455,15 @@ func (sched *Scheduler) scheduleOne() {
 
 	// Check if the cache needs update
 	//klog.Infof("The value of the Ticker: %v", customcache.LabCache.Timeout.C)
-	select {
-	// clean the cache if 10 seconds are passed
-	case <-customcache.LabCache.Timeout.C:
-		klog.Infof("Time to erase: %v", time.Now())
-		//customcache.LabCache.Timeout.Stop()
-		customcache.LabCache.CleanCache()
-		klog.Infof("Cache: %v", customcache.LabCache.Cache)
-	default:
-	}
+	// select {
+	// // clean the cache if 10 seconds are passed
+	// case <-customcache.LabCache.Timeout.C:
+	// 	klog.Infof("Time to erase: %v", time.Now())
+	// 	//customcache.LabCache.Timeout.Stop()
+	// 	customcache.LabCache.CleanCache()
+	// 	klog.Infof("Cache: %v", customcache.LabCache.Cache)
+	// default:
+	// }
 
 	fwk := sched.config.Framework