mirror of
https://github.com/alibaba/higress.git
synced 2026-05-26 13:47:27 +08:00
fix reconcile of mcpbridge (#559)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user