Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions container/rkt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package rkt

import (
"fmt"
"net"
"sync"
"time"

Expand All @@ -27,6 +28,7 @@ import (

const (
defaultRktAPIServiceAddr = "localhost:15441"
timeout = 2 * time.Second
)

var (
Expand All @@ -37,10 +39,19 @@ var (

func Client() (rktapi.PublicAPIClient, error) {
once.Do(func() {
apisvcConn, err := grpc.Dial(defaultRktAPIServiceAddr, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
conn, err := net.DialTimeout("tcp", defaultRktAPIServiceAddr, timeout)
if err != nil {
rktClient = nil
rktClientErr = fmt.Errorf("rkt: cannot connect to rkt api service: %v", err)
rktClientErr = fmt.Errorf("rkt: cannot tcp Dial rkt api service: %v", err)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do return nil, fmt.Errorf... instead

}

conn.Close()

apisvcConn, err := grpc.Dial(defaultRktAPIServiceAddr, grpc.WithInsecure(), grpc.WithTimeout(timeout))
if err != nil {
rktClient = nil
rktClientErr = fmt.Errorf("rkt: cannot grpc Dial rkt api service: %v", err)
return
}

Expand Down