weave connect should be best-effort, and return errors for any fails
This commit is contained in:
1 parent
d18640fc8c
commit
b392a7d24d
2 files changed
+19
-10
No files matched your search
+12
-4
@@ -144,8 +144,8 @@ func main() {
|
||||
}
|
||||
|
||||
router.Start()
|
||||
if err := router.ConnectionMaker.InitiateConnections(peers); err != nil {
|
||||
log.Fatal(err)
|
||||
if errors := router.ConnectionMaker.InitiateConnections(peers); len(errors) > 0 {
|
||||
log.Fatal(errorMessages(errors))
|
||||
}
|
||||
|
||||
// The weave script always waits for a status call to succeed,
|
||||
@@ -158,6 +158,14 @@ func main() {
|
||||
SignalHandlerLoop(router)
|
||||
}
|
||||
|
||||
func errorMessages(errors []error) string {
|
||||
var result []string
|
||||
for _, err := range errors {
|
||||
result = append(result, err.Error())
|
||||
}
|
||||
return strings.Join(result, "\n")
|
||||
}
|
||||
|
||||
func options() map[string]string {
|
||||
options := make(map[string]string)
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
@@ -248,8 +256,8 @@ func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator
|
||||
if err := r.ParseForm(); err != nil {
|
||||
http.Error(w, fmt.Sprint("unable to parse form: ", err), http.StatusBadRequest)
|
||||
}
|
||||
if err := router.ConnectionMaker.InitiateConnections(r.Form["peer"]); err != nil {
|
||||
http.Error(w, fmt.Sprint("invalid peer address: ", err), http.StatusBadRequest)
|
||||
if errors := router.ConnectionMaker.InitiateConnections(r.Form["peer"]); len(errors) > 0 {
|
||||
http.Error(w, errorMessages(errors), http.StatusBadRequest)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user