Files
ziti/controller/network/fault.go
2026-01-28 12:34:10 -05:00

55 lines
2.0 KiB
Go

/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package network
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/ziti/v2/controller/model"
)
type ForwardingFaultReport struct {
R *model.Router
CircuitIds []string
UnknownOwner bool
}
func (network *Network) fault(ffr *ForwardingFaultReport) {
pfxlog.Logger().Debugf("network fault processing for [%d] circuits", len(ffr.CircuitIds))
for _, circuitId := range ffr.CircuitIds {
log := pfxlog.Logger().WithField("circuitId", circuitId).WithField("routerId", ffr.R.Id)
s, found := network.Circuit.Get(circuitId)
if found {
if success := network.rerouteCircuitWithTries(s, 2); success {
log.Debug("rerouted circuit in response to forwarding fault from router")
} else {
log.Debugf("error rerouting circuit in response to forwarding fault from router, circuit removed")
}
} else if !ffr.UnknownOwner {
// If the owner is unknown, we can't unroute because the circuit may be owned by some other controller
// UnknownOwner faults come from a link forwarding operation and are generally caused by a missing forward
// table entry. In that case there's nothing to unroute anyway.
// unroute non-existent circuit
if err := sendUnroute(ffr.R, circuitId, true); err == nil {
log.Debug("sent unroute for circuit to router in response to forwarding fault")
} else {
log.WithError(err).Error("error sending unroute for circuit to router in response to forwarding fault")
}
}
}
}