Skip to content

Commit

Permalink
skipping unreachable caplet
Browse files Browse the repository at this point in the history
  • Loading branch information
shihyuho committed May 7, 2019
1 parent ba77f87 commit dae22b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/captain/app/server/captain_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/softleader/captain-kube/pkg/kubectl"
pb "github.com/softleader/captain-kube/pkg/proto"
"github.com/softleader/captain-kube/pkg/release"
"github.com/softleader/captain-kube/pkg/utils/tcp"
"net"
)

Expand All @@ -35,12 +36,17 @@ func (s *CaptainServer) lookupCaplet(log *logrus.Logger, colored bool) (endpoint
return
}
}
if len(hosts) == 0 {
return nil, ErrNonCapletDaemonFound
}
for _, host := range hosts {
// make a quick test to check the endpoint is available
if !tcp.IsReachable(host, s.Port, 1) {
log.Debugf("skipping unreachable caplet: %s:%v", host, s.Port)
continue
}
endpoints = append(endpoints, caplet.NewEndpoint(host, s.Port))
}
if len(endpoints) == 0 {
return nil, ErrNonCapletDaemonFound
}
if colored {
for i, color := range color.Pick(len(endpoints)) {
endpoints[i].Color = color
Expand Down

0 comments on commit dae22b5

Please sign in to comment.