Skip to content

Commit

Permalink
Merge pull request #1973 from weaveworks/1938-enrich-weave-details-panel
Browse files Browse the repository at this point in the history
Extend metadata in details panel for Weave Net nodes
  • Loading branch information
Alfonso Acosta authored Nov 4, 2016
2 parents 7e5166e + fc4eb85 commit 3ba83dd
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 152 deletions.
53 changes: 41 additions & 12 deletions common/weave/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,47 @@ type Client interface {
type Status struct {
Version string
Router Router
DNS DNS
IPAM IPAM
DNS *DNS
IPAM *IPAM
}

// Router describes the status of the Weave Router
type Router struct {
Name string
Peers []struct {
Name string
Encryption bool
ProtocolMinVersion int
ProtocolMaxVersion int
PeerDiscovery bool
Peers []Peer
Connections []struct {
Address string
Outbound bool
State string
Info string
}
Targets []string
TrustedSubnets []string
}

// Peer describes a peer in the weave network
type Peer struct {
Name string
NickName string
Connections []struct {
Name string
NickName string
Connections []struct {
Name string
NickName string
Address string
Outbound bool
Established bool
}
Address string
Outbound bool
Established bool
}
}

// DNS describes the status of Weave DNS
type DNS struct {
Entries []struct {
Domain string
Upstream []string
TTL uint32
Entries []struct {
Hostname string
ContainerID string
Tombstone int64
Expand All @@ -58,7 +76,18 @@ type DNS struct {

// IPAM describes the status of Weave IPAM
type IPAM struct {
Paxos *struct {
Elector bool
KnownNodes int
Quorum uint
}
Range string
DefaultSubnet string
Entries []struct {
Size uint32
IsKnownPeer bool
}
PendingAllocates []string
}

var weavePsMatch = regexp.MustCompile(`^([0-9a-f]{12}) ((?:[0-9a-f][0-9a-f]\:){5}(?:[0-9a-f][0-9a-f]))(.*)$`)
Expand Down
14 changes: 2 additions & 12 deletions common/weave/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,14 @@ func TestStatus(t *testing.T) {

want := weave.Status{
Router: weave.Router{
Peers: []struct {
Name string
NickName string
Connections []struct {
Name string
NickName string
Address string
Outbound bool
Established bool
}
}{
Peers: []weave.Peer{
{
Name: mockWeavePeerName,
NickName: mockWeavePeerNickName,
},
},
},
DNS: weave.DNS{
DNS: &weave.DNS{
Entries: []struct {
Hostname string
ContainerID string
Expand Down
4 changes: 2 additions & 2 deletions probe/docker/controls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestControls(t *testing.T) {
mdc := newMockClient()
setupStubs(mdc, func() {
hr := controls.NewDefaultHandlerRegistry()
registry, _ := docker.NewRegistry(10*time.Second, nil, false, "", hr)
registry, _ := docker.NewRegistry(10*time.Second, nil, false, "", hr, "")
defer registry.Stop()

for _, tc := range []struct{ command, result string }{
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestPipes(t *testing.T) {
mdc := newMockClient()
setupStubs(mdc, func() {
hr := controls.NewDefaultHandlerRegistry()
registry, _ := docker.NewRegistry(10*time.Second, nil, false, "", hr)
registry, _ := docker.NewRegistry(10*time.Second, nil, false, "", hr, "")
defer registry.Stop()

test.Poll(t, 100*time.Millisecond, true, func() interface{} {
Expand Down
5 changes: 2 additions & 3 deletions probe/docker/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const (
UnpauseEvent = "unpause"
NetworkConnectEvent = "network:connect"
NetworkDisconnectEvent = "network:disconnect"
endpoint = "unix:///var/run/docker.sock"
)

// Vars exported for testing.
Expand Down Expand Up @@ -95,8 +94,8 @@ func newDockerClient(endpoint string) (Client, error) {
}

// NewRegistry returns a usable Registry. Don't forget to Stop it.
func NewRegistry(interval time.Duration, pipes controls.PipeClient, collectStats bool, hostID string, handlerRegistry *controls.HandlerRegistry) (Registry, error) {
client, err := NewDockerClientStub(endpoint)
func NewRegistry(interval time.Duration, pipes controls.PipeClient, collectStats bool, hostID string, handlerRegistry *controls.HandlerRegistry, dockerEndpoint string) (Registry, error) {
client, err := NewDockerClientStub(dockerEndpoint)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion probe/docker/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func testRegistry() docker.Registry {
hr := controls.NewDefaultHandlerRegistry()
registry, _ := docker.NewRegistry(10*time.Second, nil, true, "", hr)
registry, _ := docker.NewRegistry(10*time.Second, nil, true, "", hr, "")
return registry
}

Expand Down
Loading

0 comments on commit 3ba83dd

Please sign in to comment.