File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
pkg/controller/clusterstate/cache Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,10 @@ import (
48
48
"k8s.io/klog/v2"
49
49
50
50
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/api"
51
+ "k8s.io/apimachinery/pkg/util/wait"
51
52
)
52
53
53
- // New returns a Cache implementation.
54
+ //New returns a Cache implementation.
54
55
func New (config * rest.Config ) Cache {
55
56
return newClusterStateCache (config )
56
57
}
@@ -101,7 +102,7 @@ func (sc *ClusterStateCache) Run(stopCh <-chan struct{}) {
101
102
go sc .nodeInformer .Informer ().Run (stopCh )
102
103
103
104
// Update cache
104
- go sc .updateCache ( )
105
+ go wait . Until ( sc .updateCache , 1 * time . Second , stopCh )
105
106
106
107
}
107
108
@@ -243,15 +244,11 @@ func (sc *ClusterStateCache) updateState() error {
243
244
244
245
func (sc * ClusterStateCache ) updateCache () {
245
246
klog .V (9 ).Infof ("Starting to update Cluster State Cache" )
246
-
247
- for {
248
- err := sc .updateState ()
249
- if err != nil {
250
- klog .Errorf ("Failed update state: %v" , err )
251
- }
252
-
253
- time .Sleep (1 * time .Second )
247
+ err := sc .updateState ()
248
+ if err != nil {
249
+ klog .Errorf ("Failed update state: %v" , err )
254
250
}
251
+ return
255
252
}
256
253
257
254
func (sc * ClusterStateCache ) Snapshot () * api.ClusterInfo {
You can’t perform that action at this time.
0 commit comments