From 1ee1c644c5b52ab9106dc4543dbd41d219b1f912 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Wed, 30 Mar 2022 13:44:58 -0400 Subject: [PATCH] Don't send egress on re-route, since it will always be ignored --- .gitignore | 3 ++- controller/network/network.go | 13 +++++++------ controller/network/path.go | 10 ++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index fc5172515..cc7145013 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea github_deploy_key .DS_Store -.vscode/ \ No newline at end of file +.vscode/ +go.work diff --git a/controller/network/network.go b/controller/network/network.go index 2f4c09a8a..d4ace35b3 100644 --- a/controller/network/network.go +++ b/controller/network/network.go @@ -611,7 +611,7 @@ func (network *Network) selectPath(srcR *Router, svc *Service, identity string, } func (network *Network) RemoveCircuit(circuitId string, now bool) error { - log := pfxlog.Logger() + log := pfxlog.Logger().WithField("circuitId", circuitId) if ss, found := network.circuitController.get(circuitId); found { for _, r := range ss.Path.Nodes { @@ -629,7 +629,7 @@ func (network *Network) RemoveCircuit(circuitId string, now bool) error { log.Warnf("failed to notify strategy %v of circuit end. invalid strategy (%v)", ss.Service.TerminatorStrategy, err) } - log.Debugf("removed circuit [s/%s]", ss.Id) + log.Debug("removed circuit") return nil } @@ -792,10 +792,11 @@ func (network *Network) rerouteLink(l *Link) error { } func (network *Network) rerouteCircuit(circuit *Circuit) error { + log := pfxlog.Logger().WithField("circuitId", circuit.Id) if circuit.Rerouting.CompareAndSwap(false, true) { defer circuit.Rerouting.Set(false) - logrus.Warnf("rerouting [s/%s]", circuit.Id) + log.Warn("rerouting circuit") if cq, err := network.UpdatePath(circuit.Path); err == nil { circuit.Path = cq @@ -804,11 +805,11 @@ func (network *Network) rerouteCircuit(circuit *Circuit) error { for i := 0; i < len(cq.Nodes); i++ { if _, err := sendRoute(cq.Nodes[i], rms[i], network.options.RouteTimeout); err != nil { - logrus.Errorf("error sending route to [r/%s] (%s)", cq.Nodes[i].Id, err) + log.WithError(err).Errorf("error sending route to [r/%s]", cq.Nodes[i].Id) } } - logrus.Infof("rerouted circuit [s/%s]", circuit.Id) + log.Info("rerouted circuit") network.CircuitEvent(CircuitUpdated, circuit) return nil @@ -816,7 +817,7 @@ func (network *Network) rerouteCircuit(circuit *Circuit) error { return err } } else { - logrus.Infof("not rerouting [s/%s], already in progress", circuit.Id) + log.Info("not rerouting circuit, already in progress") return nil } } diff --git a/controller/network/path.go b/controller/network/path.go index 2467ffe36..2d86826b3 100644 --- a/controller/network/path.go +++ b/controller/network/path.go @@ -138,10 +138,12 @@ func (self *Path) CreateRouteMessages(attempt uint32, circuitId string, terminat if i == len(self.Links)-1 { // egress routeMessage := &ctrl_pb.Route{CircuitId: circuitId, Attempt: attempt} - routeMessage.Egress = &ctrl_pb.Route_Egress{ - Binding: terminator.GetBinding(), - Address: self.EgressId, - Destination: terminator.GetAddress(), + if attempt != SmartRerouteAttempt { + routeMessage.Egress = &ctrl_pb.Route_Egress{ + Binding: terminator.GetBinding(), + Address: self.EgressId, + Destination: terminator.GetAddress(), + } } routeMessage.Forwards = append(routeMessage.Forwards, &ctrl_pb.Route_Forward{ SrcAddress: self.EgressId,