Include overlay diagnostics in report JSON
This commit is contained in:
1 parent
ddfc8c2fa4
commit
eaf1f7cc13
5 files changed
+94
-1
No files matched your search
@@ -2,6 +2,7 @@ package router
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -321,6 +322,77 @@ func (fastDatapathOverlay) AddFeaturesTo(features map[string]string) {
|
|||||||
// OverlaySwitch.
|
// OverlaySwitch.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FlowStatus odp.FlowInfo
|
||||||
|
|
||||||
|
func (flowStatus *FlowStatus) MarshalJSON() ([]byte, error) {
|
||||||
|
type jsonFlowStatus struct {
|
||||||
|
FlowKeys []string
|
||||||
|
Actions []string
|
||||||
|
Packets uint64
|
||||||
|
Bytes uint64
|
||||||
|
Used uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
flowKeys := make([]string, 0, len(flowStatus.FlowKeys))
|
||||||
|
for _, flowKey := range flowStatus.FlowKeys {
|
||||||
|
if !flowKey.Ignored() {
|
||||||
|
flowKeys = append(flowKeys, fmt.Sprint(flowKey))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actions := make([]string, 0, len(flowStatus.Actions))
|
||||||
|
for _, action := range flowStatus.Actions {
|
||||||
|
actions = append(actions, fmt.Sprint(action))
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(&jsonFlowStatus{flowKeys, actions,
|
||||||
|
flowStatus.Packets, flowStatus.Bytes, flowStatus.Used})
|
||||||
|
}
|
||||||
|
|
||||||
|
type VportStatus odp.Vport
|
||||||
|
|
||||||
|
func (vport *VportStatus) MarshalJSON() ([]byte, error) {
|
||||||
|
type jsonVportStatus struct {
|
||||||
|
ID odp.VportID
|
||||||
|
Name string
|
||||||
|
TypeName string
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(&jsonVportStatus{vport.ID, vport.Spec.Name(),
|
||||||
|
vport.Spec.TypeName()})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fastdp fastDatapathOverlay) Diagnostics() interface{} {
|
||||||
|
lock := fastdp.startLock()
|
||||||
|
defer lock.unlock()
|
||||||
|
|
||||||
|
vports, err := fastdp.dp.EnumerateVports()
|
||||||
|
if err != nil {
|
||||||
|
log.Warn(err)
|
||||||
|
}
|
||||||
|
vportStatuses := make([]VportStatus, 0, len(vports))
|
||||||
|
for _, vport := range vports {
|
||||||
|
vportStatuses = append(vportStatuses, VportStatus(vport))
|
||||||
|
}
|
||||||
|
|
||||||
|
flows, err := fastdp.dp.EnumerateFlows()
|
||||||
|
if err != nil {
|
||||||
|
log.Warn(err)
|
||||||
|
}
|
||||||
|
flowStatuses := make([]FlowStatus, 0, len(flows))
|
||||||
|
for _, flow := range flows {
|
||||||
|
flowStatuses = append(flowStatuses, FlowStatus(flow))
|
||||||
|
}
|
||||||
|
|
||||||
|
return struct {
|
||||||
|
Vports []VportStatus
|
||||||
|
Flows []FlowStatus
|
||||||
|
}{
|
||||||
|
vportStatuses,
|
||||||
|
flowStatuses,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (fastdp fastDatapathOverlay) StartConsumingPackets(localPeer *Peer,
|
func (fastdp fastDatapathOverlay) StartConsumingPackets(localPeer *Peer,
|
||||||
peers *Peers, consumer OverlayConsumer) error {
|
peers *Peers, consumer OverlayConsumer) error {
|
||||||
fastdp.lock.Lock()
|
fastdp.lock.Lock()
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ type Overlay interface {
|
|||||||
|
|
||||||
// Enhance a features map with overlay-related features
|
// Enhance a features map with overlay-related features
|
||||||
AddFeaturesTo(map[string]string)
|
AddFeaturesTo(map[string]string)
|
||||||
|
|
||||||
|
// Obtain diagnostic information specific to the overlay
|
||||||
|
Diagnostics() interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ForwarderParams struct {
|
type ForwarderParams struct {
|
||||||
@@ -136,3 +139,7 @@ func (NullOverlay) ControlMessage(byte, []byte) {
|
|||||||
func (NullOverlay) DisplayName() string {
|
func (NullOverlay) DisplayName() string {
|
||||||
return "null"
|
return "null"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (NullOverlay) Diagnostics() interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -35,6 +35,14 @@ func (osw *OverlaySwitch) AddFeaturesTo(features map[string]string) {
|
|||||||
features["Overlays"] = strings.Join(osw.overlayNames, " ")
|
features["Overlays"] = strings.Join(osw.overlayNames, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (osw *OverlaySwitch) Diagnostics() interface{} {
|
||||||
|
diagnostics := make(map[string]interface{})
|
||||||
|
for name, overlay := range osw.overlays {
|
||||||
|
diagnostics[name] = overlay.Diagnostics()
|
||||||
|
}
|
||||||
|
return diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
func (osw *OverlaySwitch) InvalidateRoutes() {
|
func (osw *OverlaySwitch) InvalidateRoutes() {
|
||||||
for _, overlay := range osw.overlays {
|
for _, overlay := range osw.overlays {
|
||||||
overlay.InvalidateRoutes()
|
overlay.InvalidateRoutes()
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ func (*SleeveOverlay) AddFeaturesTo(map[string]string) {
|
|||||||
// No features to be provided, to facilitate compatibility
|
// No features to be provided, to facilitate compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*SleeveOverlay) Diagnostics() interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (sleeve *SleeveOverlay) lookupForwarder(peer PeerName) *sleeveForwarder {
|
func (sleeve *SleeveOverlay) lookupForwarder(peer PeerName) *sleeveForwarder {
|
||||||
sleeve.lock.Lock()
|
sleeve.lock.Lock()
|
||||||
defer sleeve.lock.Unlock()
|
defer sleeve.lock.Unlock()
|
||||||
|
|||||||
+3
-1
@@ -22,6 +22,7 @@ type Status struct {
|
|||||||
BroadcastRoutes []BroadcastRouteStatus
|
BroadcastRoutes []BroadcastRouteStatus
|
||||||
Connections []LocalConnectionStatus
|
Connections []LocalConnectionStatus
|
||||||
Targets []string
|
Targets []string
|
||||||
|
OverlayDiagnostics interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type MACStatus struct {
|
type MACStatus struct {
|
||||||
@@ -80,7 +81,8 @@ func NewStatus(router *Router) *Status {
|
|||||||
NewUnicastRouteStatusSlice(router.Routes),
|
NewUnicastRouteStatusSlice(router.Routes),
|
||||||
NewBroadcastRouteStatusSlice(router.Routes),
|
NewBroadcastRouteStatusSlice(router.Routes),
|
||||||
NewLocalConnectionStatusSlice(router.ConnectionMaker),
|
NewLocalConnectionStatusSlice(router.ConnectionMaker),
|
||||||
NewTargetSlice(router.ConnectionMaker)}
|
NewTargetSlice(router.ConnectionMaker),
|
||||||
|
router.Overlay.Diagnostics()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMACStatusSlice(cache *MacCache) []MACStatus {
|
func NewMACStatusSlice(cache *MacCache) []MACStatus {
|
||||||
|
|||||||
Reference in new issue
Block a user