Merge pull request #801 from Random-Liu/fix-ctr-timeout
FIx ctr cri timeout.
This commit is contained in:
commit
8bcb9a9539
@ -49,16 +49,16 @@ var loadCommand = cli.Command{
|
|||||||
timeout = context.GlobalDuration("timeout")
|
timeout = context.GlobalDuration("timeout")
|
||||||
cancel gocontext.CancelFunc
|
cancel gocontext.CancelFunc
|
||||||
)
|
)
|
||||||
cl, err := client.NewCRIPluginClient(address, timeout)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "failed to create grpc client")
|
|
||||||
}
|
|
||||||
if timeout > 0 {
|
if timeout > 0 {
|
||||||
ctx, cancel = gocontext.WithTimeout(gocontext.Background(), timeout)
|
ctx, cancel = gocontext.WithTimeout(gocontext.Background(), timeout)
|
||||||
} else {
|
} else {
|
||||||
ctx, cancel = gocontext.WithCancel(ctx)
|
ctx, cancel = gocontext.WithCancel(ctx)
|
||||||
}
|
}
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
cl, err := client.NewCRIPluginClient(ctx, address)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "failed to create grpc client")
|
||||||
|
}
|
||||||
for _, path := range context.Args() {
|
for _, path := range context.Args() {
|
||||||
absPath, err := filepath.Abs(path)
|
absPath, err := filepath.Abs(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -87,7 +88,9 @@ func ConnectDaemons() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to connect containerd")
|
return errors.Wrap(err, "failed to connect containerd")
|
||||||
}
|
}
|
||||||
criPluginClient, err = client.NewCRIPluginClient(*criEndpoint, timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
criPluginClient, err = client.NewCRIPluginClient(ctx, *criEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to connect cri plugin")
|
return errors.Wrap(err, "failed to connect cri plugin")
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -29,13 +28,11 @@ import (
|
|||||||
|
|
||||||
// NewCRIPluginClient creates grpc client of cri plugin
|
// NewCRIPluginClient creates grpc client of cri plugin
|
||||||
// TODO(random-liu): Wrap grpc functions.
|
// TODO(random-liu): Wrap grpc functions.
|
||||||
func NewCRIPluginClient(endpoint string, timeout time.Duration) (api.CRIPluginServiceClient, error) {
|
func NewCRIPluginClient(ctx context.Context, endpoint string) (api.CRIPluginServiceClient, error) {
|
||||||
addr, dialer, err := util.GetAddressAndDialer(endpoint)
|
addr, dialer, err := util.GetAddressAndDialer(endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to get dialer")
|
return nil, errors.Wrap(err, "failed to get dialer")
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
|
||||||
defer cancel()
|
|
||||||
conn, err := grpc.DialContext(ctx, addr,
|
conn, err := grpc.DialContext(ctx, addr,
|
||||||
grpc.WithBlock(),
|
grpc.WithBlock(),
|
||||||
grpc.WithInsecure(),
|
grpc.WithInsecure(),
|
||||||
|
Loading…
Reference in New Issue
Block a user