vendor: update kata agent

bring support for logging through a hybrid vsock

shortlog:
95be1c3 agent: add support for logging to a vsock port
a03e23b protocols/client: improve hybrid vsock parser
6a96997 protocols/client: make schemes and hybrid vsock dialer public
e01f23c network: Add a testcase for setupDNS
d733185 network: Setup DNS for sandbox

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2019-10-07 15:27:21 +00:00
parent aa43e2a9ac
commit 2b40b6b094
3 changed files with 44 additions and 27 deletions

4
Gopkg.lock generated
View File

@ -397,7 +397,7 @@
revision = "8cba5a8e5f2816f26f9dc34b8ea968279a5a76eb" revision = "8cba5a8e5f2816f26f9dc34b8ea968279a5a76eb"
[[projects]] [[projects]]
digest = "1:54e0385cece7064d8afd967e0987e52cd8b261c8c7e22d84e8b25719d7379e74" digest = "1:903bfb87f41dc18a533d327b5b03fd2f562f34deafcbd0db93d4be3fa8d6099c"
name = "github.com/kata-containers/agent" name = "github.com/kata-containers/agent"
packages = [ packages = [
"pkg/types", "pkg/types",
@ -405,7 +405,7 @@
"protocols/grpc", "protocols/grpc",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "3ffb7ca1067565a45ee9fbfcb109eb85e7e899af" revision = "32c87e75c2e4c014961f104c3c59b87f2aee3384"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -52,7 +52,7 @@
[[constraint]] [[constraint]]
name = "github.com/kata-containers/agent" name = "github.com/kata-containers/agent"
revision = "3ffb7ca1067565a45ee9fbfcb109eb85e7e899af" revision = "32c87e75c2e4c014961f104c3c59b87f2aee3384"
[[constraint]] [[constraint]]
name = "github.com/containerd/cri-containerd" name = "github.com/containerd/cri-containerd"

View File

@ -27,9 +27,9 @@ import (
) )
const ( const (
unixSocketScheme = "unix" UnixSocketScheme = "unix"
vsockSocketScheme = "vsock" VSockSocketScheme = "vsock"
hybridVSockScheme = "hvsock" HybridVSockScheme = "hvsock"
) )
var defaultDialTimeout = 15 * time.Second var defaultDialTimeout = 15 * time.Second
@ -142,7 +142,7 @@ func parse(sock string) (string, *url.URL, error) {
var grpcAddr string var grpcAddr string
// validate more // validate more
switch addr.Scheme { switch addr.Scheme {
case vsockSocketScheme: case VSockSocketScheme:
if addr.Hostname() == "" || addr.Port() == "" || addr.Path != "" { if addr.Hostname() == "" || addr.Port() == "" || addr.Path != "" {
return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock scheme: %s", sock) return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock scheme: %s", sock)
} }
@ -152,19 +152,19 @@ func parse(sock string) (string, *url.URL, error) {
if _, err := strconv.ParseUint(addr.Port(), 10, 32); err != nil { if _, err := strconv.ParseUint(addr.Port(), 10, 32); err != nil {
return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock port: %s", sock) return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock port: %s", sock)
} }
grpcAddr = vsockSocketScheme + ":" + addr.Host grpcAddr = VSockSocketScheme + ":" + addr.Host
case unixSocketScheme: case UnixSocketScheme:
fallthrough fallthrough
case "": case "":
if (addr.Host == "" && addr.Path == "") || addr.Port() != "" { if (addr.Host == "" && addr.Path == "") || addr.Port() != "" {
return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid unix scheme: %s", sock) return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid unix scheme: %s", sock)
} }
if addr.Host == "" { if addr.Host == "" {
grpcAddr = unixSocketScheme + ":///" + addr.Path grpcAddr = UnixSocketScheme + ":///" + addr.Path
} else { } else {
grpcAddr = unixSocketScheme + ":///" + addr.Host + "/" + addr.Path grpcAddr = UnixSocketScheme + ":///" + addr.Host + "/" + addr.Path
} }
case hybridVSockScheme: case HybridVSockScheme:
if addr.Path == "" { if addr.Path == "" {
return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock scheme: %s", sock) return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock scheme: %s", sock)
} }
@ -178,7 +178,7 @@ func parse(sock string) (string, *url.URL, error) {
return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock port %s: %v", sock, err) return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock port %s: %v", sock, err)
} }
hybridVSockPort = uint32(port) hybridVSockPort = uint32(port)
grpcAddr = hybridVSockScheme + ":" + hvsocket[0] grpcAddr = HybridVSockScheme + ":" + hvsocket[0]
default: default:
return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid scheme: %s", sock) return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid scheme: %s", sock)
} }
@ -209,11 +209,11 @@ func heartBeat(session *yamux.Session) {
func agentDialer(addr *url.URL, enableYamux bool) dialer { func agentDialer(addr *url.URL, enableYamux bool) dialer {
var d dialer var d dialer
switch addr.Scheme { switch addr.Scheme {
case vsockSocketScheme: case VSockSocketScheme:
d = vsockDialer d = vsockDialer
case hybridVSockScheme: case HybridVSockScheme:
d = hybridVSockDialer d = HybridVSockDialer
case unixSocketScheme: case UnixSocketScheme:
fallthrough fallthrough
default: default:
d = unixDialer d = unixDialer
@ -281,7 +281,7 @@ func parseGrpcVsockAddr(sock string) (uint32, uint32, error) {
if len(sp) != 3 { if len(sp) != 3 {
return 0, 0, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock address: %s", sock) return 0, 0, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock address: %s", sock)
} }
if sp[0] != vsockSocketScheme { if sp[0] != VSockSocketScheme {
return 0, 0, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock URL scheme: %s", sp[0]) return 0, 0, grpcStatus.Errorf(codes.InvalidArgument, "Invalid vsock URL scheme: %s", sp[0])
} }
@ -297,16 +297,26 @@ func parseGrpcVsockAddr(sock string) (uint32, uint32, error) {
return uint32(cid), uint32(port), nil return uint32(cid), uint32(port), nil
} }
func parseGrpcHybridVSockAddr(sock string) (string, error) { func parseGrpcHybridVSockAddr(sock string) (string, uint32, error) {
sp := strings.Split(sock, ":") sp := strings.Split(sock, ":")
if len(sp) != 2 { // scheme and host are required
return "", grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock address: %s", sock) if len(sp) < 2 {
return "", 0, grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock address: %s", sock)
} }
if sp[0] != hybridVSockScheme { if sp[0] != HybridVSockScheme {
return "", grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock URL scheme: %s", sock) return "", 0, grpcStatus.Errorf(codes.InvalidArgument, "Invalid hybrid vsock URL scheme: %s", sock)
} }
return sp[1], nil port := uint32(0)
// the third is the port
if len(sp) == 3 {
p, err := strconv.ParseUint(sp[2], 10, 32)
if err == nil {
port = uint32(p)
}
}
return sp[1], port, nil
} }
// This would bypass the grpc dialer backoff strategy and handle dial timeout // This would bypass the grpc dialer backoff strategy and handle dial timeout
@ -371,8 +381,9 @@ func vsockDialer(sock string, timeout time.Duration) (net.Conn, error) {
return commonDialer(timeout, dialFunc, timeoutErr) return commonDialer(timeout, dialFunc, timeoutErr)
} }
func hybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) { // HybridVSockDialer dials to a hybrid virtio socket
udsPath, err := parseGrpcHybridVSockAddr(sock) func HybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) {
udsPath, port, err := parseGrpcHybridVSockAddr(sock)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -382,10 +393,16 @@ func hybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if port == 0 {
// use the port read at parse()
port = hybridVSockPort
}
// Once the connection is opened, the following command MUST BE sent, // Once the connection is opened, the following command MUST BE sent,
// the hypervisor needs to know the port number where the agent is listening in order to // the hypervisor needs to know the port number where the agent is listening in order to
// create the connection // create the connection
if _, err = conn.Write([]byte(fmt.Sprintf("CONNECT %d\n", hybridVSockPort))); err != nil { if _, err = conn.Write([]byte(fmt.Sprintf("CONNECT %d\n", port))); err != nil {
conn.Close() conn.Close()
return nil, err return nil, err
} }