Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend metadata in details panel for Weave Net nodes #1973

Merged
merged 3 commits into from
Nov 4, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.


// 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 @@ -93,8 +92,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