Merge pull request #157 from YaoZengzeng/ocic-timeout

add timeout for ocic connect to server
This commit is contained in:
Mrunal Patel 2016-10-18 09:32:09 -07:00 committed by GitHub
commit 68a350d9ae

View file

@ -13,13 +13,8 @@ import (
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
)
const (
// TODO: Make configurable
timeout = 10 * time.Second
)
func getClientConnection(context *cli.Context) (*grpc.ClientConn, error) {
conn, err := grpc.Dial(context.GlobalString("connect"), grpc.WithInsecure(), grpc.WithTimeout(timeout),
conn, err := grpc.Dial(context.GlobalString("connect"), grpc.WithInsecure(), grpc.WithTimeout(context.GlobalDuration("timeout")),
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("unix", addr, timeout)
}))
@ -87,6 +82,11 @@ func main() {
Value: "/var/run/ocid.sock",
Usage: "Socket to connect to",
},
cli.DurationFlag{
Name: "timeout",
Value: 10 * time.Second,
Usage: "Timeout of connecting to server",
},
}
if err := app.Run(os.Args); err != nil {