Skip to content

Commit

Permalink
add logs for egress
Browse files Browse the repository at this point in the history
Signed-off-by: terasihma <[email protected]>
  • Loading branch information
terassyi committed Nov 27, 2023
1 parent bac8dee commit 1654599
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions v2/controllers/egress_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ func (r *EgressWatcher) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
return ctrl.Result{}, nil
}

func (r *EgressWatcher) reconcileEgressClient(ctx context.Context, eg *coilv2.Egress, pod *corev1.Pod, logger *logr.Logger) error {
hook, err := r.getHook(ctx, eg, logger)
func (r *EgressWatcher) reconcileEgressClient(ctx context.Context, eg *coilv2.Egress, pod *corev1.Pod, l *logr.Logger) error {
logger := l.WithValues("pod_name", pod.Name, "pod_namespace", pod.Namespace)
logger.Info("reconcile egress client")
hook, err := r.getHook(ctx, eg, &logger)
if err != nil {
return fmt.Errorf("failed to setup NAT hook: %w", err)
}
Expand Down Expand Up @@ -183,6 +185,7 @@ func (r *EgressWatcher) hook(gwn gwNets, log *logr.Logger) func(ipv4, ipv6 net.I
return fmt.Errorf("natClient hasn't been initialized: %w", err)
}

log.Info("add a fou device by EgressWatcher", "gateway", gwn.gateway.String())
link, err := ft.AddPeer(gwn.gateway, gwn.sportAuto)
if errors.Is(err, founat.ErrIPFamilyMismatch) {
// ignore unsupported IP family link
Expand Down
3 changes: 3 additions & 0 deletions v2/pkg/founat/fou.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func (t *fouTunnel) Init() error {
if err := modProbe("fou"); err != nil {
return fmt.Errorf("failed to load fou module: %w", err)
}
if t.logFunc != nil {
t.logFunc("add FoU devide for IPv4")
}
err := netlink.FouAdd(netlink.Fou{
Family: netlink.FAMILY_V4,
Protocol: 4, // IPv4 over IPv4 (so-called IPIP)
Expand Down
1 change: 1 addition & 0 deletions v2/pkg/nodenet/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ func (pn *podNetwork) Update(podIPv4, podIPv6 net.IP, hook SetupHook) error {
defer containerNS.Close()

err = containerNS.Do(func(ns.NetNS) error {
pn.log.Info("do the hook function", "netns", netNsPath, "pod_address", podIPv4)
if hook != nil {
return hook(podIPv4, podIPv6)
}
Expand Down
1 change: 1 addition & 0 deletions v2/runners/coild_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ func (s *coildServer) getHook(ctx context.Context, pod *corev1.Pod) (nodenet.Set
}

if len(gwlist) > 0 {
logger = logger.With(zap.String("pod_name", pod.Name), zap.String("pod_namespace", pod.Namespace))
return s.natSetup.Hook(gwlist, logger), nil
}
return nil, nil
Expand Down

0 comments on commit 1654599

Please sign in to comment.