Achilleas Tzenetopoulos 5 yıl önce
ebeveyn
işleme
706d120062

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

@@ -11,7 +11,7 @@ var duration int = 10
 type MlabCache struct {
 	Cache   map[string]map[string]float64
 	Mux     sync.Mutex
-	Timeout *time.Ticker
+	Timeout time.Ticker
 }
 
 func init() {
@@ -66,8 +66,8 @@ func init() {
 				"c6res":     -1,
 			},
 		},
-		Timeout: time.NewTicker(time.Duration(10) * time.Second),
 	}
+	LabCache.Timeout = *time.NewTicker(time.Duration(10) * time.Second)
 }
 
 // var Τimeout *time.Ticker
@@ -124,6 +124,7 @@ func (c *MlabCache) CleanCache() {
 			"c6res":     -1,
 		},
 	}
+	c.Timeout.Stop()
 	//Timeout := time.NewTicker(time.Duration(10 * time.Second))
 	c.Mux.Unlock()
 }
@@ -138,7 +139,8 @@ func (c *MlabCache) UpdateCache(input map[string]float64, c6res float64, nodenam
 	}
 
 	// Reset the ticker
-	c.Timeout = time.NewTicker(time.Duration(duration) * time.Second)
+	c.Timeout = *time.NewTicker(time.Duration(duration) * time.Second)
+	//klog.Infof("Reset the Ticker")
 	c.Mux.Unlock()
 
 	//klog.Infof("After cache update")

+ 3 - 2
kubernetes-v1.15.4/pkg/scheduler/scheduler.go

@@ -38,6 +38,7 @@ import (
 	latestschedulerapi "k8s.io/kubernetes/pkg/scheduler/api/latest"
 	kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
 	"k8s.io/kubernetes/pkg/scheduler/core"
+	"k8s.io/kubernetes/pkg/scheduler/customcache"
 	"k8s.io/kubernetes/pkg/scheduler/factory"
 	framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
 	internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
@@ -451,8 +452,9 @@ func (sched *Scheduler) scheduleOne() {
 	// 	customcache.LabCache.CleanCache()
 	// default:
 	// }
-	
+
 	// 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:
@@ -461,7 +463,6 @@ func (sched *Scheduler) scheduleOne() {
 		customcache.LabCache.CleanCache()
 	default:
 	}
-	
 
 	fwk := sched.config.Framework