mirror of
https://github.com/alibaba/higress.git
synced 2026-06-02 09:07:26 +08:00
refactor(v2): upgrade module to github.com/alibaba/higress/v2 (#2922)
Signed-off-by: Xijun Dai <daixijun1990@gmail.com>
This commit is contained in:
@@ -25,11 +25,11 @@ import (
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -156,7 +156,6 @@ func (w *watcher) fetchAllServices() error {
|
||||
q.Datacenter = w.ConsulDatacenter
|
||||
q.Token = w.authOption.ConsulToken
|
||||
services, _, err := w.consulCatalog.Services(q)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("consul fetch all services error:%v", err)
|
||||
return err
|
||||
@@ -273,7 +272,6 @@ func (w *watcher) subscribe(serviceName string) error {
|
||||
"type": "service",
|
||||
"service": serviceName,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -306,7 +304,7 @@ func (w *watcher) getSubscribeCallback(serviceName string) func(idx uint64, data
|
||||
})
|
||||
} else {
|
||||
log.Infof("consul serviceEntry %s is nil", host)
|
||||
//w.cache.DeleteServiceWrapper(host)
|
||||
// w.cache.DeleteServiceWrapper(host)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import (
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/registry"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/v2/registry"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
"github.com/go-errors/errors"
|
||||
)
|
||||
|
||||
@@ -210,7 +210,7 @@ func (w *watcher) generateDestinationRule(se *v1alpha3.ServiceEntry) *v1alpha3.D
|
||||
Host: se.Hosts[0],
|
||||
TrafficPolicy: &v1alpha3.TrafficPolicy{
|
||||
PortLevelSettings: []*v1alpha3.TrafficPolicy_PortTrafficPolicy{
|
||||
&v1alpha3.TrafficPolicy_PortTrafficPolicy{
|
||||
{
|
||||
Port: &v1alpha3.PortSelector{
|
||||
Number: se.Ports[0].Number,
|
||||
},
|
||||
|
||||
@@ -25,12 +25,12 @@ import (
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
. "github.com/alibaba/higress/registry/eureka/client"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
. "github.com/alibaba/higress/v2/registry/eureka/client"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -30,10 +30,10 @@ import (
|
||||
"istio.io/istio/pkg/config/schema/gvk"
|
||||
"istio.io/pkg/log"
|
||||
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
higressconfig "github.com/alibaba/higress/pkg/config"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
higressconfig "github.com/alibaba/higress/v2/pkg/config"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/v2/registry"
|
||||
)
|
||||
|
||||
type Cache interface {
|
||||
@@ -121,7 +121,7 @@ func (s *store) GetAllConfigs(kind config.GroupVersionKind) map[string]*config.C
|
||||
FailStrategy: extensions.FailStrategy_FAIL_OPEN,
|
||||
}
|
||||
|
||||
return map[string]*config.Config{"wasm": &config.Config{
|
||||
return map[string]*config.Config{"wasm": {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.WasmPlugin,
|
||||
Name: "istio-autogenerated-mcp-wasmplugin",
|
||||
|
||||
@@ -24,12 +24,12 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
common2 "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/pkg/ingress/kube/mcpserver"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
common2 "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/v2/pkg/ingress/kube/mcpserver"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
"github.com/golang/protobuf/ptypes/wrappers"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/model"
|
||||
|
||||
@@ -21,10 +21,10 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
common2 "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
common2 "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/model"
|
||||
"github.com/stretchr/testify/mock"
|
||||
wrappers "google.golang.org/protobuf/types/known/wrapperspb"
|
||||
@@ -81,7 +81,7 @@ func testCallback(msc *McpServerConfig) memory.Cache {
|
||||
EnableScopeMcpServers: wrappers.Bool(true),
|
||||
AllowMcpServers: []string{"mcp-server-1", "mcp-server-2"},
|
||||
Metadata: map[string]*apiv1.InnerMap{
|
||||
"routeName": &apiv1.InnerMap{
|
||||
"routeName": {
|
||||
InnerMap: map[string]string{"mcp-server-1": "mcp-route-1", "mcp-server-2": "mcp-route-2"},
|
||||
},
|
||||
},
|
||||
@@ -184,7 +184,7 @@ func Test_Watcher(t *testing.T) {
|
||||
}`,
|
||||
},
|
||||
wantConfig: map[string]*config.Config{
|
||||
gvk.ServiceEntry.String(): &config.Config{
|
||||
gvk.ServiceEntry.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.ServiceEntry,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedSeName, strings.TrimSuffix(dataId, ".json")),
|
||||
@@ -213,7 +213,7 @@ func Test_Watcher(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
gvk.VirtualService.String(): &config.Config{
|
||||
gvk.VirtualService.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.VirtualService,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedVsName, strings.TrimSuffix(dataId, ".json")),
|
||||
@@ -316,7 +316,7 @@ func Test_Watcher(t *testing.T) {
|
||||
}`,
|
||||
},
|
||||
wantConfig: map[string]*config.Config{
|
||||
gvk.ServiceEntry.String(): &config.Config{
|
||||
gvk.ServiceEntry.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.ServiceEntry,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedSeName, strings.TrimSuffix(dataId, ".json")),
|
||||
@@ -345,7 +345,7 @@ func Test_Watcher(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
gvk.VirtualService.String(): &config.Config{
|
||||
gvk.VirtualService.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.VirtualService,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedVsName, strings.TrimSuffix(dataId, ".json")),
|
||||
@@ -387,7 +387,7 @@ func Test_Watcher(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
gvk.DestinationRule.String(): &config.Config{
|
||||
gvk.DestinationRule.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.DestinationRule,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedDrName, strings.TrimSuffix(dataId, ".json")),
|
||||
@@ -472,7 +472,7 @@ func Test_Watcher(t *testing.T) {
|
||||
}`,
|
||||
},
|
||||
wantConfig: map[string]*config.Config{
|
||||
gvk.ServiceEntry.String(): &config.Config{
|
||||
gvk.ServiceEntry.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.ServiceEntry,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedSeName, strings.TrimSuffix(dataId, ".json")),
|
||||
@@ -501,7 +501,7 @@ func Test_Watcher(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
gvk.VirtualService.String(): &config.Config{
|
||||
gvk.VirtualService.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.VirtualService,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedVsName, strings.TrimSuffix(dataId, ".json")),
|
||||
@@ -542,7 +542,7 @@ func Test_Watcher(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
gvk.DestinationRule.String(): &config.Config{
|
||||
gvk.DestinationRule.String(): {
|
||||
Meta: config.Meta{
|
||||
GroupVersionKind: gvk.DestinationRule,
|
||||
Name: fmt.Sprintf("%s-%s", provider.IstioMcpAutoGeneratedDrName, strings.TrimSuffix(dataId, ".json")),
|
||||
|
||||
@@ -33,14 +33,14 @@ import (
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/registry"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
"github.com/alibaba/higress/registry/nacos/address"
|
||||
"github.com/alibaba/higress/registry/nacos/mcpserver"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/v2/registry"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
"github.com/alibaba/higress/v2/registry/nacos/address"
|
||||
"github.com/alibaba/higress/v2/registry/nacos/mcpserver"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -470,7 +470,6 @@ func (w *watcher) subscribe(groupName string, serviceName string) error {
|
||||
GroupName: groupName,
|
||||
SubscribeCallback: w.getSubscribeCallback(groupName, serviceName),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("subscribe service error:%v, groupName:%s, serviceName:%s", err, groupName, serviceName)
|
||||
return err
|
||||
@@ -487,7 +486,6 @@ func (w *watcher) unsubscribe(groupName string, serviceName string) error {
|
||||
GroupName: groupName,
|
||||
SubscribeCallback: w.getSubscribeCallback(groupName, serviceName),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("unsubscribe service error:%v, groupName:%s, serviceName:%s", err, groupName, serviceName)
|
||||
return err
|
||||
@@ -504,7 +502,7 @@ func (w *watcher) getSubscribeCallback(groupName string, serviceName string) fun
|
||||
return func(services []model.Instance, err error) {
|
||||
defer w.UpdateService()
|
||||
|
||||
//log.Info("callback", "serviceName", serviceName, "suffix", suffix, "details", services)
|
||||
// log.Info("callback", "serviceName", serviceName, "suffix", suffix, "details", services)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "hosts is empty") {
|
||||
|
||||
@@ -28,11 +28,11 @@ import (
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -269,7 +269,6 @@ func (w *watcher) subscribe(groupName string, serviceName string) error {
|
||||
GroupName: groupName,
|
||||
SubscribeCallback: w.getSubscribeCallback(groupName, serviceName),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("subscribe service error:%v, groupName:%s, serviceName:%s", err, groupName, serviceName)
|
||||
return err
|
||||
@@ -286,7 +285,6 @@ func (w *watcher) unsubscribe(groupName string, serviceName string) error {
|
||||
GroupName: groupName,
|
||||
SubscribeCallback: w.getSubscribeCallback(groupName, serviceName),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("unsubscribe service error:%v, groupName:%s, serviceName:%s", err, groupName, serviceName)
|
||||
return err
|
||||
@@ -303,7 +301,7 @@ func (w *watcher) getSubscribeCallback(groupName string, serviceName string) fun
|
||||
return func(services []model.SubscribeService, err error) {
|
||||
defer w.UpdateService()
|
||||
|
||||
//log.Info("callback", "serviceName", serviceName, "suffix", suffix, "details", services)
|
||||
// log.Info("callback", "serviceName", serviceName, "suffix", suffix, "details", services)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "hosts is empty") {
|
||||
|
||||
@@ -21,10 +21,10 @@ import (
|
||||
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/pkg/ingress/kube/util"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
"github.com/alibaba/higress/v2/pkg/ingress/kube/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -119,7 +119,7 @@ func FillProxyListenerPorts(proxies []*apiv1.ProxyConfig) bool {
|
||||
return false
|
||||
}
|
||||
filled := false
|
||||
var usedPorts = make(map[uint32]bool)
|
||||
usedPorts := make(map[uint32]bool)
|
||||
for _, proxy := range proxies {
|
||||
if proxy.ListenerPort > 0 {
|
||||
usedPorts[proxy.ListenerPort] = true
|
||||
|
||||
@@ -26,19 +26,19 @@ import (
|
||||
"istio.io/pkg/log"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
v1 "github.com/alibaba/higress/client/pkg/apis/networking/v1"
|
||||
higressmcpserver "github.com/alibaba/higress/pkg/ingress/kube/mcpserver"
|
||||
"github.com/alibaba/higress/pkg/kube"
|
||||
. "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/consul"
|
||||
"github.com/alibaba/higress/registry/direct"
|
||||
"github.com/alibaba/higress/registry/eureka"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
"github.com/alibaba/higress/registry/nacos"
|
||||
nacosv2 "github.com/alibaba/higress/registry/nacos/v2"
|
||||
"github.com/alibaba/higress/registry/proxy"
|
||||
"github.com/alibaba/higress/registry/zookeeper"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
v1 "github.com/alibaba/higress/v2/client/pkg/apis/networking/v1"
|
||||
higressmcpserver "github.com/alibaba/higress/v2/pkg/ingress/kube/mcpserver"
|
||||
"github.com/alibaba/higress/v2/pkg/kube"
|
||||
. "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/consul"
|
||||
"github.com/alibaba/higress/v2/registry/direct"
|
||||
"github.com/alibaba/higress/v2/registry/eureka"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
"github.com/alibaba/higress/v2/registry/nacos"
|
||||
nacosv2 "github.com/alibaba/higress/v2/registry/nacos/v2"
|
||||
"github.com/alibaba/higress/v2/registry/proxy"
|
||||
"github.com/alibaba/higress/v2/registry/zookeeper"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -168,7 +168,7 @@ func (r *Reconciler) reconcileRegistries(registries []*apiv1.RegistryConfig) err
|
||||
if errHappened {
|
||||
return errors.New("ReconcileRegistries failed, Init Watchers failed")
|
||||
}
|
||||
var ready = make(chan struct{})
|
||||
ready := make(chan struct{})
|
||||
readyTimer := time.NewTimer(DefaultReadyTimeout)
|
||||
go func() {
|
||||
wg.Wait()
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -74,6 +75,7 @@ func (w *BaseWatcher) GetRegistryType() string { return "" }
|
||||
func (w *BaseWatcher) AppendServiceUpdateHandler(f func()) {
|
||||
w.UpdateService = f
|
||||
}
|
||||
|
||||
func (w *BaseWatcher) ReadyHandler(f func(isReady bool)) {
|
||||
w.Ready = func(isReady bool) {
|
||||
w.ReadyStatus = isReady
|
||||
@@ -81,8 +83,10 @@ func (w *BaseWatcher) ReadyHandler(f func(isReady bool)) {
|
||||
}
|
||||
}
|
||||
|
||||
type ServiceUpdateHandler func()
|
||||
type ReadyHandler func(bool)
|
||||
type (
|
||||
ServiceUpdateHandler func()
|
||||
ReadyHandler func(bool)
|
||||
)
|
||||
|
||||
func ProbeWatcherStatus(host string, port string) WatcherStatus {
|
||||
address := net.JoinHostPort(host, port)
|
||||
@@ -118,4 +122,4 @@ func GetServiceVport(host string, vport *apiv1.RegistryConfig_VPort) *v1alpha3.S
|
||||
|
||||
func isValidPort(port uint32) bool {
|
||||
return port > 0 && port <= 65535
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ import (
|
||||
"istio.io/api/networking/v1alpha3"
|
||||
"istio.io/pkg/log"
|
||||
|
||||
apiv1 "github.com/alibaba/higress/api/networking/v1"
|
||||
"github.com/alibaba/higress/pkg/common"
|
||||
ingress "github.com/alibaba/higress/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/registry"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
apiv1 "github.com/alibaba/higress/v2/api/networking/v1"
|
||||
"github.com/alibaba/higress/v2/pkg/common"
|
||||
ingress "github.com/alibaba/higress/v2/pkg/ingress/kube/common"
|
||||
provider "github.com/alibaba/higress/v2/registry"
|
||||
"github.com/alibaba/higress/v2/registry/memory"
|
||||
)
|
||||
|
||||
type watchConfig struct {
|
||||
@@ -302,11 +302,10 @@ func (w *watcher) ListenService() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (w *watcher) DataChange(eventType Event) bool {
|
||||
//fmt.Println(eventType)
|
||||
// fmt.Println(eventType)
|
||||
host, interfaceConfig, err := w.GetInterfaceConfig(eventType)
|
||||
if err != nil {
|
||||
log.Errorf("GetInterfaceConfig failed, err:%v, event:%v", err, eventType)
|
||||
@@ -357,7 +356,7 @@ func (w *watcher) DataChange(eventType Event) bool {
|
||||
}
|
||||
se := w.generateServiceEntry(w.serviceEntry[host])
|
||||
w.seMux.Unlock()
|
||||
//todo update
|
||||
// todo update
|
||||
if len(se.Endpoints) == 0 {
|
||||
if !w.keepStaleWhenEmpty {
|
||||
w.cache.DeleteServiceWrapper(host)
|
||||
@@ -562,7 +561,7 @@ func (w *watcher) ChildToServiceEntry(children []string, interfaceName, zkPath s
|
||||
if ok {
|
||||
if !reflect.DeepEqual(value, config) {
|
||||
w.serviceEntry[host] = config
|
||||
//todo update or create serviceentry
|
||||
// todo update or create serviceentry
|
||||
w.cache.UpdateServiceWrapper(host, &ingress.ServiceWrapper{
|
||||
ServiceName: host,
|
||||
ServiceEntry: se,
|
||||
|
||||
Reference in New Issue
Block a user