Skip to content

Commit 0a7aae2

Browse files
committed
Reduce egress gateway agent event
Signed-off-by: lou-lan <[email protected]>
1 parent 84cde27 commit 0a7aae2

File tree

4 files changed

+6
-25
lines changed

4 files changed

+6
-25
lines changed

pkg/agent/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Agent struct {
2828
}
2929

3030
func New(cfg *config.Config) (types.Service, error) {
31-
syncPeriod := time.Second * 15
31+
syncPeriod := time.Second * time.Duration(cfg.FileConfig.CacheSyncSyncPeriodSecond)
3232
log := logger.NewLogger(cfg.EnvConfig.Logger)
3333
t := time.Duration(0)
3434
mgrOpts := manager.Options{

pkg/agent/vxlan.go

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ func (r *vxlanReconciler) Reconcile(ctx context.Context, req reconcile.Request)
8181
return r.reconcileEgressTunnel(ctx, newReq, log)
8282
case "EgressGateway":
8383
return r.reconcileEgressGateway(ctx, newReq, log)
84-
case "EgressEndpointSlice":
85-
// return r.reconcileEgressEndpointSlice(ctx, newReq, log)
86-
return reconcile.Result{}, nil
87-
case "EgressClusterEndpointSlice":
88-
// return r.reconcileEgressClusterEndpointSlice(ctx, newReq, log)
89-
return reconcile.Result{}, nil
9084
default:
9185
return reconcile.Result{}, nil
9286
}
@@ -638,27 +632,12 @@ func newEgressTunnelController(mgr manager.Manager, cfg *config.Config, log logr
638632

639633
sourceEgressGateway := utils.SourceKind(mgr.GetCache(),
640634
&egressv1.EgressGateway{},
641-
handler.EnqueueRequestsFromMapFunc(utils.KindToMapFlat("EgressGateway")))
635+
handler.EnqueueRequestsFromMapFunc(utils.KindToMapFlat("EgressGateway")),
636+
)
642637
if err := c.Watch(sourceEgressGateway); err != nil {
643638
return fmt.Errorf("failed to watch EgressGateway: %w", err)
644639
}
645640

646-
sourceEgressEndpointSlice := utils.SourceKind(mgr.GetCache(),
647-
&egressv1.EgressEndpointSlice{},
648-
handler.EnqueueRequestsFromMapFunc(utils.KindToMapFlat("EgressEndpointSlice")),
649-
epSlicePredicate{})
650-
if err := c.Watch(sourceEgressEndpointSlice); err != nil {
651-
return fmt.Errorf("failed to watch EgressEndpointSlice: %w", err)
652-
}
653-
654-
sourceEgressClusterEndpointSlice := utils.SourceKind(mgr.GetCache(),
655-
&egressv1.EgressClusterEndpointSlice{},
656-
handler.EnqueueRequestsFromMapFunc(utils.KindToMapFlat("EgressClusterEndpointSlice")),
657-
epSlicePredicate{})
658-
if err := c.Watch(sourceEgressClusterEndpointSlice); err != nil {
659-
return fmt.Errorf("failed to watch EgressClusterEndpointSlice: %w", err)
660-
}
661-
662641
go r.keepVXLAN()
663642

664643
return nil

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type FileConfig struct {
8484
GatewayReplyRouteTable int `yaml:"gatewayReplyRouteTable"`
8585
GatewayReplyRouteMark int `yaml:"gatewayReplyRouteMark"`
8686
GatewayFailover GatewayFailover `yaml:"gatewayFailover"`
87+
CacheSyncSyncPeriodSecond int `json:"cacheSyncSyncPeriodSecond "`
8788
}
8889

8990
type GatewayFailover struct {
@@ -163,6 +164,7 @@ func LoadConfig(isAgent bool) (*Config, error) {
163164
TunnelUpdatePeriod: 5,
164165
EipEvictionTimeout: 15,
165166
},
167+
CacheSyncSyncPeriodSecond: 1800,
166168
},
167169
}
168170

pkg/controller/endpoint/endpoint_slice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package endpoint
66
import (
77
"context"
88
"fmt"
9-
"github.com/spidernet-io/egressgateway/pkg/utils"
109
"net"
1110
"reflect"
1211
"sort"
@@ -32,6 +31,7 @@ import (
3231
"github.com/spidernet-io/egressgateway/pkg/coalescing"
3332
"github.com/spidernet-io/egressgateway/pkg/config"
3433
"github.com/spidernet-io/egressgateway/pkg/k8s/apis/v1beta1"
34+
"github.com/spidernet-io/egressgateway/pkg/utils"
3535
)
3636

3737
type endpointReconciler struct {

0 commit comments

Comments
 (0)