Merge pull request #465 from awh/237_add_dns_to_weave_status
Include weave dns information in `weave status` Closes #237.
This commit is contained in:
commit
6b64516ede
8 files changed
+76
-7
No files matched your search
+3
-2
@@ -17,12 +17,13 @@ func httpErrorAndLog(level *log.Logger, w http.ResponseWriter, msg string,
|
||||
level.Printf("[http] "+logmsg, logargs...)
|
||||
}
|
||||
|
||||
func ListenHttp(domain string, db Zone, port int) {
|
||||
func ListenHttp(version string, server *DNSServer, domain string, db Zone, port int) {
|
||||
|
||||
muxRouter := mux.NewRouter()
|
||||
|
||||
muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, "ok")
|
||||
io.WriteString(w, fmt.Sprintln("weave DNS", version))
|
||||
io.WriteString(w, server.Status())
|
||||
})
|
||||
|
||||
muxRouter.Methods("PUT").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestHttp(t *testing.T) {
|
||||
var zone = new(ZoneDb)
|
||||
port := rand.Intn(10000) + 32768
|
||||
fmt.Println("Http test on port", port)
|
||||
go ListenHttp(testDomain, zone, port)
|
||||
go ListenHttp("", nil, testDomain, zone, port)
|
||||
|
||||
time.Sleep(100 * time.Millisecond) // Allow for http server to get going
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
. "github.com/zettio/weave/common"
|
||||
"net"
|
||||
"sync"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -142,6 +143,17 @@ func (s *DNSServer) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Return status string
|
||||
func (s *DNSServer) Status() string {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString(fmt.Sprintln("Local domain", s.Domain))
|
||||
buf.WriteString(fmt.Sprintln("Listen address", s.ListenAddr))
|
||||
buf.WriteString(fmt.Sprintln("mDNS interface", s.iface))
|
||||
buf.WriteString(fmt.Sprintln("Fallback DNS config", s.upstream))
|
||||
buf.WriteString(fmt.Sprintf("Zone database:\n%s", s.zone))
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// Perform a graceful shutdown
|
||||
func (s *DNSServer) Stop() error {
|
||||
if err := s.tcpSrv.Shutdown(); err != nil {
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
. "github.com/zettio/weave/common"
|
||||
"net"
|
||||
"sync"
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -61,6 +63,16 @@ func (zone *ZoneDb) indexOf(match func(Record) bool) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func (zone *ZoneDb) String() string {
|
||||
zone.mx.RLock()
|
||||
defer zone.mx.RUnlock()
|
||||
var buf bytes.Buffer
|
||||
for _, r := range zone.recs {
|
||||
buf.WriteString(fmt.Sprintf("%.12s %s %v\n", r.Ident, r.IP, r.Name))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (zone *ZoneDb) LookupName(name string) (net.IP, error) {
|
||||
zone.mx.RLock()
|
||||
defer zone.mx.RUnlock()
|
||||
|
||||
@@ -51,7 +51,7 @@ The command
|
||||
|
||||
weave status
|
||||
|
||||
reports on the current status of the weave router.
|
||||
reports on the current status of the weave router and DNS.
|
||||
|
||||
This produces output like:
|
||||
|
||||
@@ -80,6 +80,8 @@ broadcast:
|
||||
7a:16:dd:5b:83:de -> []
|
||||
Reconnects:
|
||||
192.168.32.1:6783 (next try at 2014-10-23 16:39:50.585932102 +0000 UTC)
|
||||
|
||||
weavedns container is not present; have you launched it?
|
||||
````
|
||||
|
||||
The terms used here are explained further at
|
||||
@@ -117,11 +119,16 @@ weave network is not fully connected. See the
|
||||
[architecture documentation](https://raw.githubusercontent.com/zettio/weave/master/docs/architecture.txt)
|
||||
for a full explanation.
|
||||
|
||||
Finally, 'Reconnects' lists peers that this router is aware of, but is
|
||||
The 'Reconnects' section lists peers that this router is aware of, but is
|
||||
not currently connected to. Each line contains some information about
|
||||
whether it is attempting to connect or is waiting for a while before
|
||||
connecting again.
|
||||
|
||||
Finally, status information from weave DNS is included. In this example,
|
||||
the DNS container has not been launched so no status information is
|
||||
available (see the [WeaveDNS README](https://github.com/zettio/weave/blob/master/weavedns/README.md)
|
||||
for more information).
|
||||
|
||||
### <a name="list-attached-containers"></a>List attached containers
|
||||
|
||||
weave ps
|
||||
|
||||
@@ -555,7 +555,9 @@ case "$COMMAND" in
|
||||
http_call $CONTAINER_NAME $HTTP_PORT POST /connect -d "peer=$1"
|
||||
;;
|
||||
status)
|
||||
http_call $CONTAINER_NAME $HTTP_PORT GET /status
|
||||
http_call $CONTAINER_NAME $HTTP_PORT GET /status || true
|
||||
echo
|
||||
http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT GET /status || true
|
||||
;;
|
||||
ps)
|
||||
[ $# -eq 0 ] || usage
|
||||
|
||||
@@ -177,6 +177,41 @@ $ dns_ip=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' weavedns)
|
||||
$ curl -X DELETE "http://$dns_ip:6785/name/$shell2/10.2.1.27"
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
The command
|
||||
|
||||
weave status
|
||||
|
||||
reports on the current status of the weave router and DNS:
|
||||
|
||||
````
|
||||
weave router git-8f675f15c0b5
|
||||
...
|
||||
|
||||
weave DNS git-8f675f15c0b5
|
||||
Local domain weave.local.
|
||||
Listen address :53
|
||||
mDNS interface &{26 65535 ethwe fa:b6:b1:85:ac:9b up|broadcast|multicast}
|
||||
Fallback DNS config &{[66.28.0.45 8.8.8.8] [] 53 1 5 2}
|
||||
Zone database:
|
||||
710978857a88 10.2.1.26 wiff.weave.local.
|
||||
e8d85b1dcdb1 10.2.1.27 waff.weave.local.
|
||||
26bd05f9a0cb 10.2.1.28 ping.weave.local.
|
||||
1ab0e8b17c39 10.2.1.29 pong.weave.local.
|
||||
````
|
||||
|
||||
The first section covers the router; see the troubleshooting guide in
|
||||
the main documentation for more detail.
|
||||
|
||||
The second section is pertinent to weaveDNS, and includes:
|
||||
|
||||
* The local domain suffix which is being served
|
||||
* The address on which the DNS server is listening
|
||||
* The interface being used for multicast DNS
|
||||
* The fallback DNS which will be used to resolve non local names
|
||||
* The names known to the local weaveDNS server. Each entry comprises the container ID, IP address and its fully qualified domain name
|
||||
|
||||
## Present limitations
|
||||
|
||||
* The server will not know about restarted containers, but if you
|
||||
|
||||
+1
-1
@@ -83,11 +83,11 @@ func main() {
|
||||
Debug.Printf("DNS fallback at %s:%s", fallbackHost, fallbackPort)
|
||||
}
|
||||
|
||||
go weavedns.ListenHttp(localDomain, zone, httpPort)
|
||||
srv, err := weavedns.NewDNSServer(srvConfig, zone, iface)
|
||||
if err != nil {
|
||||
Error.Fatal("Failed to initialize the WeaveDNS server", err)
|
||||
}
|
||||
go weavedns.ListenHttp(version, srv, localDomain, zone, httpPort)
|
||||
err = srv.Start()
|
||||
if err != nil {
|
||||
Error.Fatal("Failed to start the WeaveDNS server", err)
|
||||
|
||||
Reference in new issue
Block a user