Update grpc timeout and logger
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
d2fc059229
commit
55afe3359a
@ -87,7 +87,6 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
|
|||||||
gopts := []grpc.DialOption{
|
gopts := []grpc.DialOption{
|
||||||
grpc.WithBlock(),
|
grpc.WithBlock(),
|
||||||
grpc.WithInsecure(),
|
grpc.WithInsecure(),
|
||||||
grpc.WithTimeout(60 * time.Second),
|
|
||||||
grpc.FailOnNonTempDialError(true),
|
grpc.FailOnNonTempDialError(true),
|
||||||
grpc.WithBackoffMaxDelay(3 * time.Second),
|
grpc.WithBackoffMaxDelay(3 * time.Second),
|
||||||
grpc.WithDialer(dialer.Dialer),
|
grpc.WithDialer(dialer.Dialer),
|
||||||
@ -107,7 +106,9 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
connector := func() (*grpc.ClientConn, error) {
|
connector := func() (*grpc.ClientConn, error) {
|
||||||
conn, err := grpc.Dial(dialer.DialAddress(address), gopts...)
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
conn, err := grpc.DialContext(ctx, dialer.DialAddress(address), gopts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to dial %q", address)
|
return nil, errors.Wrapf(err, "failed to dial %q", address)
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
golog "log"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc/grpclog"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
@ -50,9 +46,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Discard grpc logs so that they don't mess with our stdio
|
|
||||||
grpclog.SetLogger(golog.New(ioutil.Discard, "", golog.LstdFlags))
|
|
||||||
|
|
||||||
flag.StringVar(&address, "address", defaultAddress, "The address to the containerd socket for use in the tests")
|
flag.StringVar(&address, "address", defaultAddress, "The address to the containerd socket for use in the tests")
|
||||||
flag.BoolVar(&noDaemon, "no-daemon", false, "Do not start a dedicated daemon for the tests")
|
flag.BoolVar(&noDaemon, "no-daemon", false, "Do not start a dedicated daemon for the tests")
|
||||||
flag.BoolVar(&noCriu, "no-criu", false, "Do not run the checkpoint tests")
|
flag.BoolVar(&noCriu, "no-criu", false, "Do not run the checkpoint tests")
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
gocontext "context"
|
gocontext "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
golog "log"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -50,7 +49,7 @@ high performance container runtime
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Discard grpc logs so that they don't mess with our stdio
|
// Discard grpc logs so that they don't mess with our stdio
|
||||||
grpclog.SetLogger(golog.New(ioutil.Discard, "", golog.LstdFlags))
|
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
|
||||||
|
|
||||||
cli.VersionPrinter = func(c *cli.Context) {
|
cli.VersionPrinter = func(c *cli.Context) {
|
||||||
fmt.Println(c.App.Name, version.Package, c.App.Version, version.Revision)
|
fmt.Println(c.App.Name, version.Package, c.App.Version, version.Revision)
|
||||||
|
@ -95,12 +95,13 @@ func connect(address string, d func(string, time.Duration) (net.Conn, error)) (*
|
|||||||
gopts := []grpc.DialOption{
|
gopts := []grpc.DialOption{
|
||||||
grpc.WithBlock(),
|
grpc.WithBlock(),
|
||||||
grpc.WithInsecure(),
|
grpc.WithInsecure(),
|
||||||
grpc.WithTimeout(60 * time.Second),
|
|
||||||
grpc.WithDialer(d),
|
grpc.WithDialer(d),
|
||||||
grpc.FailOnNonTempDialError(true),
|
grpc.FailOnNonTempDialError(true),
|
||||||
grpc.WithBackoffMaxDelay(3 * time.Second),
|
grpc.WithBackoffMaxDelay(3 * time.Second),
|
||||||
}
|
}
|
||||||
conn, err := grpc.Dial(dialer.DialAddress(address), gopts...)
|
ctx, cancel := gocontext.WithTimeout(gocontext.Background(), 60*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
conn, err := grpc.DialContext(ctx, dialer.DialAddress(address), gopts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to dial %q", address)
|
return nil, errors.Wrapf(err, "failed to dial %q", address)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package app
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands/containers"
|
"github.com/containerd/containerd/cmd/ctr/commands/containers"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands/content"
|
"github.com/containerd/containerd/cmd/ctr/commands/content"
|
||||||
@ -44,7 +43,7 @@ var extraCmds = []cli.Command{}
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Discard grpc logs so that they don't mess with our stdio
|
// Discard grpc logs so that they don't mess with our stdio
|
||||||
grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
|
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
|
||||||
|
|
||||||
cli.VersionPrinter = func(c *cli.Context) {
|
cli.VersionPrinter = func(c *cli.Context) {
|
||||||
fmt.Println(c.App.Name, version.Package, c.App.Version)
|
fmt.Println(c.App.Name, version.Package, c.App.Version)
|
||||||
|
Loading…
Reference in New Issue
Block a user