浏览代码

Fix listen port for test infra

Update Dockerfile, curl is used for the healthcheck
Add /dump for creating the routine stack trace

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
Flavio Crisciani 7 年之前
父节点
当前提交
4037132b33
共有 3 个文件被更改,包括 16 次插入1 次删除
  1. 2 1
      libnetwork/diagnose/diagnose.go
  2. 12 0
      libnetwork/networkdb/networkdbdiagnose.go
  3. 2 0
      libnetwork/test/networkDb/Dockerfile

+ 2 - 1
libnetwork/diagnose/diagnose.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"net"
 	"net/http"
+	"strconv"
 	"sync"
 
 	"github.com/sirupsen/logrus"
@@ -81,7 +82,7 @@ func (n *Server) EnableDebug(ip string, port int) {
 	// go func() {
 	// 	http.Serve(n.sk, n.mux)
 	// }()
-	http.ListenAndServe(":8000", n.mux)
+	http.ListenAndServe(":"+strconv.Itoa(port), n.mux)
 }
 
 // DisableDebug stop the dubug and closes the tcp socket

+ 12 - 0
libnetwork/networkdb/networkdbdiagnose.go

@@ -5,7 +5,9 @@ import (
 	"net/http"
 	"strings"
 
+	stackdump "github.com/docker/docker/pkg/signal"
 	"github.com/docker/libnetwork/diagnose"
+	"github.com/sirupsen/logrus"
 )
 
 const (
@@ -24,6 +26,7 @@ var NetDbPaths2Func = map[string]diagnose.HTTPHandlerFunc{
 	"/deleteentry":  dbDeleteEntry,
 	"/getentry":     dbGetEntry,
 	"/gettable":     dbGetTable,
+	"/dump":         dbStackTrace,
 }
 
 func dbJoin(ctx interface{}, w http.ResponseWriter, r *http.Request) {
@@ -240,3 +243,12 @@ func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
 		}
 	}
 }
+
+func dbStackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
+	path, err := stackdump.DumpStacks("/tmp/")
+	if err != nil {
+		logrus.WithError(err).Error("failed to write goroutines dump")
+	} else {
+		fmt.Fprintf(w, "goroutine stacks written to %s", path)
+	}
+}

+ 2 - 0
libnetwork/test/networkDb/Dockerfile

@@ -1,5 +1,7 @@
 FROM alpine
 
+RUN apk --no-cache add curl
+
 COPY testMain /app/
 
 WORKDIR app