fix reconcile of mcpbridge (#559)

This commit is contained in:
澄潭
2023-09-25 10:42:19 +08:00
committed by GitHub
parent 792b9b0ee5
commit 945787f7dc
5 changed files with 49 additions and 10 deletions

View File

@@ -21,6 +21,7 @@ import (
"path"
"reflect"
"sync"
"time"
"istio.io/pkg/log"
@@ -38,6 +39,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
DefaultReadyTimeout = time.Second * 60
)
type Reconciler struct {
memory.Cache
registries map[string]*apiv1.RegistryConfig
@@ -123,7 +128,17 @@ func (r *Reconciler) Reconcile(mcpbridge *v1.McpBridge) error {
if errHappened {
return errors.New("ReconcileRegistries failed, Init Watchers failed")
}
wg.Wait()
var ready = make(chan struct{})
readyTimer := time.NewTimer(DefaultReadyTimeout)
go func() {
wg.Wait()
ready <- struct{}{}
}()
select {
case <-ready:
case <-readyTimer.C:
return errors.New("ReoncileRegistries failed, waiting for ready timeout")
}
r.Cache.PurgeStaleService()
log.Infof("Registries is reconciled")
return nil