mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +00:00
vendor: Update the agent vendoring based on pkg/types
Some agent types definition that were generic enough to be reused everywhere, have been split from the initial grpc package. This prevents from importing the entire protobuf package through the grpc one, and prevents binaries such as kata-netmon to stay in sync with the types definitions. Fixes #856 Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
c7a9e454ac
commit
309dcf9977
10
Gopkg.lock
generated
10
Gopkg.lock
generated
@ -130,14 +130,15 @@
|
||||
revision = "e82e8498c5a214b24ac75e0a05ace556bf91a9ab"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:672470f31bc4e50f9ba09a1af7ab6035bf8b1452db64dfd79b1a22614bb30710"
|
||||
digest = "1:e96806ae1b041a36386249b22ef9eaf5af1788c0f86f686c6296e5a9caf53df8"
|
||||
name = "github.com/kata-containers/agent"
|
||||
packages = [
|
||||
"pkg/types",
|
||||
"protocols/client",
|
||||
"protocols/grpc",
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "7e8e20b10b71fe3044a24175b8a686421e9d2c24"
|
||||
revision = "dd8f32c7a2e6e7effed9d12bac97e7d48473e684"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:04054595e5c5a35d1553a7f3464d18577caf597445d643992998643df56d4afd"
|
||||
@ -173,11 +174,11 @@
|
||||
revision = "0351df1c5a66838d0c392b4ac4cf9450de844e2d"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:57234a321bf1f8f98a8a9a5122a2404cc60d0800516f4ab7a7b2375e4b2d19ea"
|
||||
digest = "1:0d447d4961f4f9270457fbc20d0261bba8d3056f395efd2e2480e2dfa4487a60"
|
||||
name = "github.com/opencontainers/runtime-spec"
|
||||
packages = ["specs-go"]
|
||||
pruneopts = "NUT"
|
||||
revision = "4e3b9264a330d094b0386c3703c5f379119711e8"
|
||||
revision = "5806c35637336642129d03657419829569abc5aa"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:7da29c22bcc5c2ffb308324377dc00b5084650348c2799e573ed226d8cc9faf0"
|
||||
@ -406,6 +407,7 @@
|
||||
"github.com/gogo/protobuf/proto",
|
||||
"github.com/gogo/protobuf/types",
|
||||
"github.com/intel/govmm/qemu",
|
||||
"github.com/kata-containers/agent/pkg/types",
|
||||
"github.com/kata-containers/agent/protocols/client",
|
||||
"github.com/kata-containers/agent/protocols/grpc",
|
||||
"github.com/kubernetes-incubator/cri-o/pkg/annotations",
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/opencontainers/runtime-spec"
|
||||
revision = "4e3b9264a330d094b0386c3703c5f379119711e8"
|
||||
revision = "5806c35637336642129d03657419829569abc5aa"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/stretchr/testify"
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/kata-containers/agent"
|
||||
revision = "7e8e20b10b71fe3044a24175b8a686421e9d2c24"
|
||||
revision = "dd8f32c7a2e6e7effed9d12bac97e7d48473e684"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/containerd/cri-containerd"
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/containernetworking/plugins/pkg/ns"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
@ -158,7 +158,7 @@ func networkModifyCommand(ctx context.Context, containerID, input string, opType
|
||||
}
|
||||
switch opType {
|
||||
case interfaceType:
|
||||
var inf, resultingInf *grpc.Interface
|
||||
var inf, resultingInf *types.Interface
|
||||
if err = json.NewDecoder(f).Decode(&inf); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -177,7 +177,7 @@ func networkModifyCommand(ctx context.Context, containerID, input string, opType
|
||||
}
|
||||
json.NewEncoder(output).Encode(resultingInf)
|
||||
case routeType:
|
||||
var routes, resultingRoutes []*grpc.Route
|
||||
var routes, resultingRoutes []*types.Route
|
||||
if err = json.NewDecoder(f).Decode(&routes); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -215,7 +215,7 @@ func networkListCommand(ctx context.Context, containerID string, opType networkT
|
||||
|
||||
switch opType {
|
||||
case interfaceType:
|
||||
var interfaces []*grpc.Interface
|
||||
var interfaces []*types.Interface
|
||||
interfaces, err = vci.ListInterfaces(ctx, sandboxID)
|
||||
if err != nil {
|
||||
kataLog.WithField("existing-interfaces", fmt.Sprintf("%+v", interfaces)).
|
||||
@ -223,7 +223,7 @@ func networkListCommand(ctx context.Context, containerID string, opType networkT
|
||||
}
|
||||
json.NewEncoder(file).Encode(interfaces)
|
||||
case routeType:
|
||||
var routes []*grpc.Route
|
||||
var routes []*types.Route
|
||||
routes, err = vci.ListRoutes(ctx, sandboxID)
|
||||
if err != nil {
|
||||
kataLog.WithField("resulting-routes", fmt.Sprintf("%+v", routes)).
|
||||
|
@ -18,25 +18,25 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/containernetworking/plugins/pkg/ns"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var (
|
||||
testAddInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
testAddInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
testRemoveInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
testRemoveInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
testListInterfacesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*grpc.Interface, error) {
|
||||
testListInterfacesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
testUpdateRoutsFuncReturnNil = func(ctx context.Context, sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
testUpdateRoutsFuncReturnNil = func(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
testListRoutesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*grpc.Route, error) {
|
||||
testListRoutesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
)
|
||||
|
1093
vendor/github.com/kata-containers/agent/pkg/types/types.pb.go
generated
vendored
Normal file
1093
vendor/github.com/kata-containers/agent/pkg/types/types.pb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
vendor/github.com/kata-containers/agent/protocols/client/client.go
generated
vendored
24
vendor/github.com/kata-containers/agent/protocols/client/client.go
generated
vendored
@ -165,6 +165,26 @@ func parse(sock string) (string, *url.URL, error) {
|
||||
return grpcAddr, addr, nil
|
||||
}
|
||||
|
||||
// This function is meant to run in a go routine since it will send ping
|
||||
// commands every second. It behaves as a heartbeat to maintain a proper
|
||||
// communication state with the Yamux server in the agent.
|
||||
func heartBeat(session *yamux.Session) {
|
||||
if session == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
if session.IsClosed() {
|
||||
break
|
||||
}
|
||||
|
||||
session.Ping()
|
||||
|
||||
// 1 Hz heartbeat
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func agentDialer(addr *url.URL, enableYamux bool) dialer {
|
||||
var d dialer
|
||||
switch addr.Scheme {
|
||||
@ -196,11 +216,15 @@ func agentDialer(addr *url.URL, enableYamux bool) dialer {
|
||||
sessionConfig := yamux.DefaultConfig()
|
||||
// Disable keepAlive since we don't know how much time a container can be paused
|
||||
sessionConfig.EnableKeepAlive = false
|
||||
sessionConfig.ConnectionWriteTimeout = time.Second
|
||||
session, err = yamux.Client(conn, sessionConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Start the heartbeat in a separate go routine
|
||||
go heartBeat(session)
|
||||
|
||||
var stream net.Conn
|
||||
stream, err = session.Open()
|
||||
if err != nil {
|
||||
|
1745
vendor/github.com/kata-containers/agent/protocols/grpc/agent.pb.go
generated
vendored
1745
vendor/github.com/kata-containers/agent/protocols/grpc/agent.pb.go
generated
vendored
File diff suppressed because it is too large
Load Diff
30
vendor/github.com/kata-containers/agent/protocols/grpc/health.pb.go
generated
vendored
30
vendor/github.com/kata-containers/agent/protocols/grpc/health.pb.go
generated
vendored
@ -108,7 +108,10 @@ func init() {
|
||||
}
|
||||
func (this *CheckRequest) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*CheckRequest)
|
||||
@ -121,7 +124,10 @@ func (this *CheckRequest) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -132,7 +138,10 @@ func (this *CheckRequest) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *HealthCheckResponse) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*HealthCheckResponse)
|
||||
@ -145,7 +154,10 @@ func (this *HealthCheckResponse) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -156,7 +168,10 @@ func (this *HealthCheckResponse) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *VersionCheckResponse) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*VersionCheckResponse)
|
||||
@ -169,7 +184,10 @@ func (this *VersionCheckResponse) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
|
310
vendor/github.com/kata-containers/agent/protocols/grpc/oci.pb.go
generated
vendored
310
vendor/github.com/kata-containers/agent/protocols/grpc/oci.pb.go
generated
vendored
@ -1499,7 +1499,10 @@ func init() {
|
||||
}
|
||||
func (this *Spec) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Spec)
|
||||
@ -1512,7 +1515,10 @@ func (this *Spec) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1560,7 +1566,10 @@ func (this *Spec) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Process) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Process)
|
||||
@ -1573,7 +1582,10 @@ func (this *Process) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1632,7 +1644,10 @@ func (this *Process) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Box) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Box)
|
||||
@ -1645,7 +1660,10 @@ func (this *Box) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1659,7 +1677,10 @@ func (this *Box) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *User) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*User)
|
||||
@ -1672,7 +1693,10 @@ func (this *User) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1697,7 +1721,10 @@ func (this *User) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxCapabilities) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxCapabilities)
|
||||
@ -1710,7 +1737,10 @@ func (this *LinuxCapabilities) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1758,7 +1788,10 @@ func (this *LinuxCapabilities) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *POSIXRlimit) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*POSIXRlimit)
|
||||
@ -1771,7 +1804,10 @@ func (this *POSIXRlimit) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1788,7 +1824,10 @@ func (this *POSIXRlimit) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Mount) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Mount)
|
||||
@ -1801,7 +1840,10 @@ func (this *Mount) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1826,7 +1868,10 @@ func (this *Mount) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Root) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Root)
|
||||
@ -1839,7 +1884,10 @@ func (this *Root) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1853,7 +1901,10 @@ func (this *Root) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Hooks) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Hooks)
|
||||
@ -1866,7 +1917,10 @@ func (this *Hooks) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1898,7 +1952,10 @@ func (this *Hooks) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Hook) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Hook)
|
||||
@ -1911,7 +1968,10 @@ func (this *Hook) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -1941,7 +2001,10 @@ func (this *Hook) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Linux) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Linux)
|
||||
@ -1954,7 +2017,10 @@ func (this *Linux) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2036,7 +2102,10 @@ func (this *Linux) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Windows) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Windows)
|
||||
@ -2049,7 +2118,10 @@ func (this *Windows) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2060,7 +2132,10 @@ func (this *Windows) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *Solaris) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*Solaris)
|
||||
@ -2073,7 +2148,10 @@ func (this *Solaris) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2084,7 +2162,10 @@ func (this *Solaris) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxIDMapping) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxIDMapping)
|
||||
@ -2097,7 +2178,10 @@ func (this *LinuxIDMapping) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2114,7 +2198,10 @@ func (this *LinuxIDMapping) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxNamespace) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxNamespace)
|
||||
@ -2127,7 +2214,10 @@ func (this *LinuxNamespace) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2141,7 +2231,10 @@ func (this *LinuxNamespace) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxDevice) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxDevice)
|
||||
@ -2154,7 +2247,10 @@ func (this *LinuxDevice) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2183,7 +2279,10 @@ func (this *LinuxDevice) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxResources) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxResources)
|
||||
@ -2196,7 +2295,10 @@ func (this *LinuxResources) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2235,7 +2337,10 @@ func (this *LinuxResources) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxMemory) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxMemory)
|
||||
@ -2248,7 +2353,10 @@ func (this *LinuxMemory) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2277,7 +2385,10 @@ func (this *LinuxMemory) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxCPU) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxCPU)
|
||||
@ -2290,7 +2401,10 @@ func (this *LinuxCPU) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2319,7 +2433,10 @@ func (this *LinuxCPU) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxWeightDevice) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxWeightDevice)
|
||||
@ -2332,7 +2449,10 @@ func (this *LinuxWeightDevice) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2352,7 +2472,10 @@ func (this *LinuxWeightDevice) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxThrottleDevice) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxThrottleDevice)
|
||||
@ -2365,7 +2488,10 @@ func (this *LinuxThrottleDevice) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2382,7 +2508,10 @@ func (this *LinuxThrottleDevice) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxBlockIO) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxBlockIO)
|
||||
@ -2395,7 +2524,10 @@ func (this *LinuxBlockIO) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2449,7 +2581,10 @@ func (this *LinuxBlockIO) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxPids) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxPids)
|
||||
@ -2462,7 +2597,10 @@ func (this *LinuxPids) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2473,7 +2611,10 @@ func (this *LinuxPids) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxDeviceCgroup) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxDeviceCgroup)
|
||||
@ -2486,7 +2627,10 @@ func (this *LinuxDeviceCgroup) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2509,7 +2653,10 @@ func (this *LinuxDeviceCgroup) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxNetwork) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxNetwork)
|
||||
@ -2522,7 +2669,10 @@ func (this *LinuxNetwork) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2541,7 +2691,10 @@ func (this *LinuxNetwork) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxHugepageLimit) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxHugepageLimit)
|
||||
@ -2554,7 +2707,10 @@ func (this *LinuxHugepageLimit) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2568,7 +2724,10 @@ func (this *LinuxHugepageLimit) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxInterfacePriority) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxInterfacePriority)
|
||||
@ -2581,7 +2740,10 @@ func (this *LinuxInterfacePriority) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2595,7 +2757,10 @@ func (this *LinuxInterfacePriority) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxSeccomp) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxSeccomp)
|
||||
@ -2608,7 +2773,10 @@ func (this *LinuxSeccomp) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2635,7 +2803,10 @@ func (this *LinuxSeccomp) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxSeccompArg) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxSeccompArg)
|
||||
@ -2648,7 +2819,10 @@ func (this *LinuxSeccompArg) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2668,7 +2842,10 @@ func (this *LinuxSeccompArg) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxSyscall) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxSyscall)
|
||||
@ -2681,7 +2858,10 @@ func (this *LinuxSyscall) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
@ -2708,7 +2888,10 @@ func (this *LinuxSyscall) Equal(that interface{}) bool {
|
||||
}
|
||||
func (this *LinuxIntelRdt) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
that1, ok := that.(*LinuxIntelRdt)
|
||||
@ -2721,7 +2904,10 @@ func (this *LinuxIntelRdt) Equal(that interface{}) bool {
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
if this == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
|
80
vendor/github.com/opencontainers/runtime-spec/specs-go/config.go
generated
vendored
80
vendor/github.com/opencontainers/runtime-spec/specs-go/config.go
generated
vendored
@ -25,6 +25,8 @@ type Spec struct {
|
||||
Solaris *Solaris `json:"solaris,omitempty" platform:"solaris"`
|
||||
// Windows is platform-specific configuration for Windows based containers.
|
||||
Windows *Windows `json:"windows,omitempty" platform:"windows"`
|
||||
// VM specifies configuration for virtual-machine-based containers.
|
||||
VM *VM `json:"vm,omitempty" platform:"vm"`
|
||||
}
|
||||
|
||||
// Process contains information to start a specific application inside the container.
|
||||
@ -158,8 +160,8 @@ type Linux struct {
|
||||
ReadonlyPaths []string `json:"readonlyPaths,omitempty"`
|
||||
// MountLabel specifies the selinux context for the mounts in the container.
|
||||
MountLabel string `json:"mountLabel,omitempty"`
|
||||
// IntelRdt contains Intel Resource Director Technology (RDT) information
|
||||
// for handling resource constraints (e.g., L3 cache) for the container
|
||||
// IntelRdt contains Intel Resource Director Technology (RDT) information for
|
||||
// handling resource constraints (e.g., L3 cache, memory bandwidth) for the container
|
||||
IntelRdt *LinuxIntelRdt `json:"intelRdt,omitempty"`
|
||||
}
|
||||
|
||||
@ -194,10 +196,10 @@ const (
|
||||
|
||||
// LinuxIDMapping specifies UID/GID mappings
|
||||
type LinuxIDMapping struct {
|
||||
// HostID is the starting UID/GID on the host to be mapped to 'ContainerID'
|
||||
HostID uint32 `json:"hostID"`
|
||||
// ContainerID is the starting UID/GID in the container
|
||||
ContainerID uint32 `json:"containerID"`
|
||||
// HostID is the starting UID/GID on the host to be mapped to 'ContainerID'
|
||||
HostID uint32 `json:"hostID"`
|
||||
// Size is the number of IDs to be mapped
|
||||
Size uint32 `json:"size"`
|
||||
}
|
||||
@ -320,6 +322,14 @@ type LinuxNetwork struct {
|
||||
Priorities []LinuxInterfacePriority `json:"priorities,omitempty"`
|
||||
}
|
||||
|
||||
// LinuxRdma for Linux cgroup 'rdma' resource management (Linux 4.11)
|
||||
type LinuxRdma struct {
|
||||
// Maximum number of HCA handles that can be opened. Default is "no limit".
|
||||
HcaHandles *uint32 `json:"hcaHandles,omitempty"`
|
||||
// Maximum number of HCA objects that can be created. Default is "no limit".
|
||||
HcaObjects *uint32 `json:"hcaObjects,omitempty"`
|
||||
}
|
||||
|
||||
// LinuxResources has container runtime resource constraints
|
||||
type LinuxResources struct {
|
||||
// Devices configures the device whitelist.
|
||||
@ -336,6 +346,10 @@ type LinuxResources struct {
|
||||
HugepageLimits []LinuxHugepageLimit `json:"hugepageLimits,omitempty"`
|
||||
// Network restriction configuration
|
||||
Network *LinuxNetwork `json:"network,omitempty"`
|
||||
// Rdma resource restriction configuration.
|
||||
// Limits are a set of key value pairs that define RDMA resource limits,
|
||||
// where the key is device name and value is resource limits.
|
||||
Rdma map[string]LinuxRdma `json:"rdma,omitempty"`
|
||||
}
|
||||
|
||||
// LinuxDevice represents the mknod information for a Linux special device file
|
||||
@ -419,6 +433,8 @@ type SolarisAnet struct {
|
||||
type Windows struct {
|
||||
// LayerFolders contains a list of absolute paths to directories containing image layers.
|
||||
LayerFolders []string `json:"layerFolders"`
|
||||
// Devices are the list of devices to be mapped into the container.
|
||||
Devices []WindowsDevice `json:"devices,omitempty"`
|
||||
// Resources contains information for handling resource constraints for the container.
|
||||
Resources *WindowsResources `json:"resources,omitempty"`
|
||||
// CredentialSpec contains a JSON object describing a group Managed Service Account (gMSA) specification.
|
||||
@ -433,6 +449,14 @@ type Windows struct {
|
||||
Network *WindowsNetwork `json:"network,omitempty"`
|
||||
}
|
||||
|
||||
// WindowsDevice represents information about a host device to be mapped into the container.
|
||||
type WindowsDevice struct {
|
||||
// Device identifier: interface class GUID, etc.
|
||||
ID string `json:"id"`
|
||||
// Device identifier type: "class", etc.
|
||||
IDType string `json:"idType"`
|
||||
}
|
||||
|
||||
// WindowsResources has container runtime resource constraints for containers running on Windows.
|
||||
type WindowsResources struct {
|
||||
// Memory restriction configuration.
|
||||
@ -479,6 +503,8 @@ type WindowsNetwork struct {
|
||||
DNSSearchList []string `json:"DNSSearchList,omitempty"`
|
||||
// Name (ID) of the container that we will share with the network stack.
|
||||
NetworkSharedContainerName string `json:"networkSharedContainerName,omitempty"`
|
||||
// name (ID) of the network namespace that will be used for the container.
|
||||
NetworkNamespace string `json:"networkNamespace,omitempty"`
|
||||
}
|
||||
|
||||
// WindowsHyperV contains information for configuring a container to run with Hyper-V isolation.
|
||||
@ -487,6 +513,42 @@ type WindowsHyperV struct {
|
||||
UtilityVMPath string `json:"utilityVMPath,omitempty"`
|
||||
}
|
||||
|
||||
// VM contains information for virtual-machine-based containers.
|
||||
type VM struct {
|
||||
// Hypervisor specifies hypervisor-related configuration for virtual-machine-based containers.
|
||||
Hypervisor VMHypervisor `json:"hypervisor,omitempty"`
|
||||
// Kernel specifies kernel-related configuration for virtual-machine-based containers.
|
||||
Kernel VMKernel `json:"kernel"`
|
||||
// Image specifies guest image related configuration for virtual-machine-based containers.
|
||||
Image VMImage `json:"image,omitempty"`
|
||||
}
|
||||
|
||||
// VMHypervisor contains information about the hypervisor to use for a virtual machine.
|
||||
type VMHypervisor struct {
|
||||
// Path is the host path to the hypervisor used to manage the virtual machine.
|
||||
Path string `json:"path"`
|
||||
// Parameters specifies parameters to pass to the hypervisor.
|
||||
Parameters string `json:"parameters,omitempty"`
|
||||
}
|
||||
|
||||
// VMKernel contains information about the kernel to use for a virtual machine.
|
||||
type VMKernel struct {
|
||||
// Path is the host path to the kernel used to boot the virtual machine.
|
||||
Path string `json:"path"`
|
||||
// Parameters specifies parameters to pass to the kernel.
|
||||
Parameters string `json:"parameters,omitempty"`
|
||||
// InitRD is the host path to an initial ramdisk to be used by the kernel.
|
||||
InitRD string `json:"initrd,omitempty"`
|
||||
}
|
||||
|
||||
// VMImage contains information about the virtual machine root image.
|
||||
type VMImage struct {
|
||||
// Path is the host path to the root image that the VM kernel would boot into.
|
||||
Path string `json:"path"`
|
||||
// Format is the root image format type (e.g. "qcow2", "raw", "vhd", etc).
|
||||
Format string `json:"format"`
|
||||
}
|
||||
|
||||
// LinuxSeccomp represents syscall restrictions
|
||||
type LinuxSeccomp struct {
|
||||
DefaultAction LinuxSeccompAction `json:"defaultAction"`
|
||||
@ -561,10 +623,16 @@ type LinuxSyscall struct {
|
||||
Args []LinuxSeccompArg `json:"args,omitempty"`
|
||||
}
|
||||
|
||||
// LinuxIntelRdt has container runtime resource constraints
|
||||
// for Intel RDT/CAT which introduced in Linux 4.10 kernel
|
||||
// LinuxIntelRdt has container runtime resource constraints for Intel RDT
|
||||
// CAT and MBA features which introduced in Linux 4.10 and 4.12 kernel
|
||||
type LinuxIntelRdt struct {
|
||||
// The identity for RDT Class of Service
|
||||
ClosID string `json:"closID,omitempty"`
|
||||
// The schema for L3 cache id and capacity bitmask (CBM)
|
||||
// Format: "L3:<cache_id0>=<cbm0>;<cache_id1>=<cbm1>;..."
|
||||
L3CacheSchema string `json:"l3CacheSchema,omitempty"`
|
||||
|
||||
// The schema of memory bandwidth percentage per L3 cache id
|
||||
// Format: "MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;..."
|
||||
MemBwSchema string `json:"memBwSchema,omitempty"`
|
||||
}
|
||||
|
2
vendor/github.com/opencontainers/runtime-spec/specs-go/version.go
generated
vendored
2
vendor/github.com/opencontainers/runtime-spec/specs-go/version.go
generated
vendored
@ -11,7 +11,7 @@ const (
|
||||
VersionPatch = 1
|
||||
|
||||
// VersionDev indicates development branch. Releases will be empty string.
|
||||
VersionDev = ""
|
||||
VersionDev = "-dev"
|
||||
)
|
||||
|
||||
// Version is the specification version that the package types support.
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
@ -229,16 +230,16 @@ type agent interface {
|
||||
reseedRNG(data []byte) error
|
||||
|
||||
// updateInterface will tell the agent to update a nic for an existed Sandbox.
|
||||
updateInterface(inf *grpc.Interface) (*grpc.Interface, error)
|
||||
updateInterface(inf *types.Interface) (*types.Interface, error)
|
||||
|
||||
// listInterfaces will tell the agent to list interfaces of an existed Sandbox
|
||||
listInterfaces() ([]*grpc.Interface, error)
|
||||
listInterfaces() ([]*types.Interface, error)
|
||||
|
||||
// updateRoutes will tell the agent to update route table for an existed Sandbox.
|
||||
updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error)
|
||||
updateRoutes(routes []*types.Route) ([]*types.Route, error)
|
||||
|
||||
// listRoutes will tell the agent to list routes of an existed Sandbox
|
||||
listRoutes() ([]*grpc.Route, error)
|
||||
listRoutes() ([]*types.Route, error)
|
||||
|
||||
// getGuestDetails will tell the agent to get some information of guest
|
||||
getGuestDetails(*grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
deviceApi "github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
deviceConfig "github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
@ -867,7 +867,7 @@ func AddDevice(ctx context.Context, sandboxID string, info deviceConfig.DeviceIn
|
||||
return s.AddDevice(info)
|
||||
}
|
||||
|
||||
func toggleInterface(ctx context.Context, sandboxID string, inf *grpc.Interface, add bool) (*grpc.Interface, error) {
|
||||
func toggleInterface(ctx context.Context, sandboxID string, inf *types.Interface, add bool) (*types.Interface, error) {
|
||||
if sandboxID == "" {
|
||||
return nil, errNeedSandboxID
|
||||
}
|
||||
@ -892,7 +892,7 @@ func toggleInterface(ctx context.Context, sandboxID string, inf *grpc.Interface,
|
||||
}
|
||||
|
||||
// AddInterface is the virtcontainers add interface entry point.
|
||||
func AddInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
span, ctx := trace(ctx, "AddInterface")
|
||||
defer span.Finish()
|
||||
|
||||
@ -900,7 +900,7 @@ func AddInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*
|
||||
}
|
||||
|
||||
// RemoveInterface is the virtcontainers remove interface entry point.
|
||||
func RemoveInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
span, ctx := trace(ctx, "RemoveInterface")
|
||||
defer span.Finish()
|
||||
|
||||
@ -908,7 +908,7 @@ func RemoveInterface(ctx context.Context, sandboxID string, inf *grpc.Interface)
|
||||
}
|
||||
|
||||
// ListInterfaces is the virtcontainers list interfaces entry point.
|
||||
func ListInterfaces(ctx context.Context, sandboxID string) ([]*grpc.Interface, error) {
|
||||
func ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
||||
span, ctx := trace(ctx, "ListInterfaces")
|
||||
defer span.Finish()
|
||||
|
||||
@ -932,7 +932,7 @@ func ListInterfaces(ctx context.Context, sandboxID string) ([]*grpc.Interface, e
|
||||
}
|
||||
|
||||
// UpdateRoutes is the virtcontainers update routes entry point.
|
||||
func UpdateRoutes(ctx context.Context, sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
||||
span, ctx := trace(ctx, "UpdateRoutes")
|
||||
defer span.Finish()
|
||||
|
||||
@ -956,7 +956,7 @@ func UpdateRoutes(ctx context.Context, sandboxID string, routes []*grpc.Route) (
|
||||
}
|
||||
|
||||
// ListRoutes is the virtcontainers list routes entry point.
|
||||
func ListRoutes(ctx context.Context, sandboxID string) ([]*grpc.Route, error) {
|
||||
func ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
||||
span, ctx := trace(ctx, "ListRoutes")
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/containernetworking/plugins/pkg/ns"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -2422,12 +2422,12 @@ func TestNetworkOperation(t *testing.T) {
|
||||
cleanUp()
|
||||
|
||||
assert := assert.New(t)
|
||||
inf := &grpc.Interface{
|
||||
inf := &types.Interface{
|
||||
Name: "eno1",
|
||||
Mtu: 1500,
|
||||
HwAddr: "02:00:ca:fe:00:48",
|
||||
}
|
||||
ip := grpc.IPAddress{
|
||||
ip := types.IPAddress{
|
||||
Family: 0,
|
||||
Address: "192.168.0.101",
|
||||
Mask: "24",
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"github.com/vishvananda/netlink"
|
||||
|
||||
proxyClient "github.com/clearcontainers/proxy/client"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
"github.com/kata-containers/runtime/virtcontainers/pkg/hyperstart"
|
||||
@ -888,22 +889,22 @@ func (h *hyper) onlineCPUMem(cpus uint32, cpuOnly bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *hyper) updateInterface(inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (h *hyper) updateInterface(inf *types.Interface) (*types.Interface, error) {
|
||||
// hyperstart-agent does not support update interface
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (h *hyper) listInterfaces() ([]*grpc.Interface, error) {
|
||||
func (h *hyper) listInterfaces() ([]*types.Interface, error) {
|
||||
// hyperstart-agent does not support list interfaces
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (h *hyper) updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func (h *hyper) updateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
||||
// hyperstart-agent does not support update routes
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (h *hyper) listRoutes() ([]*grpc.Route, error) {
|
||||
func (h *hyper) listRoutes() ([]*types.Route, error) {
|
||||
// hyperstart-agent does not support list routes
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"context"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
@ -152,26 +152,26 @@ func (impl *VCImpl) AddDevice(ctx context.Context, sandboxID string, info config
|
||||
}
|
||||
|
||||
// AddInterface implements the VC function of the same name.
|
||||
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
return AddInterface(ctx, sandboxID, inf)
|
||||
}
|
||||
|
||||
// RemoveInterface implements the VC function of the same name.
|
||||
func (impl *VCImpl) RemoveInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (impl *VCImpl) RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
return RemoveInterface(ctx, sandboxID, inf)
|
||||
}
|
||||
|
||||
// ListInterfaces implements the VC function of the same name.
|
||||
func (impl *VCImpl) ListInterfaces(ctx context.Context, sandboxID string) ([]*grpc.Interface, error) {
|
||||
func (impl *VCImpl) ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
||||
return ListInterfaces(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// UpdateRoutes implements the VC function of the same name.
|
||||
func (impl *VCImpl) UpdateRoutes(ctx context.Context, sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func (impl *VCImpl) UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
||||
return UpdateRoutes(ctx, sandboxID, routes)
|
||||
}
|
||||
|
||||
// ListRoutes implements the VC function of the same name.
|
||||
func (impl *VCImpl) ListRoutes(ctx context.Context, sandboxID string) ([]*grpc.Route, error) {
|
||||
func (impl *VCImpl) ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
||||
return ListRoutes(ctx, sandboxID)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"io"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
@ -48,11 +48,11 @@ type VC interface {
|
||||
|
||||
AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
||||
|
||||
AddInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error)
|
||||
RemoveInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error)
|
||||
ListInterfaces(ctx context.Context, sandboxID string) ([]*grpc.Interface, error)
|
||||
UpdateRoutes(ctx context.Context, sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error)
|
||||
ListRoutes(ctx context.Context, sandboxID string) ([]*grpc.Route, error)
|
||||
AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
||||
RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
||||
ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error)
|
||||
UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error)
|
||||
ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error)
|
||||
}
|
||||
|
||||
// VCSandbox is the Sandbox interface
|
||||
@ -86,11 +86,11 @@ type VCSandbox interface {
|
||||
|
||||
AddDevice(info config.DeviceInfo) (api.Device, error)
|
||||
|
||||
AddInterface(inf *grpc.Interface) (*grpc.Interface, error)
|
||||
RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error)
|
||||
ListInterfaces() ([]*grpc.Interface, error)
|
||||
UpdateRoutes(routes []*grpc.Route) ([]*grpc.Route, error)
|
||||
ListRoutes() ([]*grpc.Route, error)
|
||||
AddInterface(inf *types.Interface) (*types.Interface, error)
|
||||
RemoveInterface(inf *types.Interface) (*types.Interface, error)
|
||||
ListInterfaces() ([]*types.Interface, error)
|
||||
UpdateRoutes(routes []*types.Route) ([]*types.Route, error)
|
||||
ListRoutes() ([]*types.Route, error)
|
||||
}
|
||||
|
||||
// VCContainer is the Container interface
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
kataclient "github.com/kata-containers/agent/protocols/client"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
@ -383,7 +384,7 @@ func (k *kataAgent) exec(sandbox *Sandbox, c Container, cmd Cmd) (*Process, erro
|
||||
k.state.URL, cmd, []ns.NSType{}, enterNSList)
|
||||
}
|
||||
|
||||
func (k *kataAgent) updateInterface(ifc *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (k *kataAgent) updateInterface(ifc *types.Interface) (*types.Interface, error) {
|
||||
// send update interface request
|
||||
ifcReq := &grpc.UpdateInterfaceRequest{
|
||||
Interface: ifc,
|
||||
@ -395,13 +396,13 @@ func (k *kataAgent) updateInterface(ifc *grpc.Interface) (*grpc.Interface, error
|
||||
"resulting-interface": fmt.Sprintf("%+v", resultingInterface),
|
||||
}).WithError(err).Error("update interface request failed")
|
||||
}
|
||||
if resultInterface, ok := resultingInterface.(*grpc.Interface); ok {
|
||||
if resultInterface, ok := resultingInterface.(*types.Interface); ok {
|
||||
return resultInterface, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (k *kataAgent) updateInterfaces(interfaces []*grpc.Interface) error {
|
||||
func (k *kataAgent) updateInterfaces(interfaces []*types.Interface) error {
|
||||
for _, ifc := range interfaces {
|
||||
if _, err := k.updateInterface(ifc); err != nil {
|
||||
return err
|
||||
@ -410,7 +411,7 @@ func (k *kataAgent) updateInterfaces(interfaces []*grpc.Interface) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k *kataAgent) updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func (k *kataAgent) updateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
||||
if routes != nil {
|
||||
routesReq := &grpc.UpdateRoutesRequest{
|
||||
Routes: &grpc.Routes{
|
||||
@ -433,7 +434,7 @@ func (k *kataAgent) updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (k *kataAgent) listInterfaces() ([]*grpc.Interface, error) {
|
||||
func (k *kataAgent) listInterfaces() ([]*types.Interface, error) {
|
||||
req := &grpc.ListInterfacesRequest{}
|
||||
resultingInterfaces, err := k.sendReq(req)
|
||||
if err != nil {
|
||||
@ -446,7 +447,7 @@ func (k *kataAgent) listInterfaces() ([]*grpc.Interface, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (k *kataAgent) listRoutes() ([]*grpc.Route, error) {
|
||||
func (k *kataAgent) listRoutes() ([]*types.Route, error) {
|
||||
req := &grpc.ListRoutesRequest{}
|
||||
resultingRoutes, err := k.sendReq(req)
|
||||
if err != nil {
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
pb "github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
@ -184,16 +185,16 @@ func (p *gRPCProxy) DestroySandbox(ctx context.Context, req *pb.DestroySandboxRe
|
||||
return emptyResp, nil
|
||||
}
|
||||
|
||||
func (p *gRPCProxy) AddInterface(ctx context.Context, req *pb.AddInterfaceRequest) (*pb.Interface, error) {
|
||||
func (p *gRPCProxy) AddInterface(ctx context.Context, req *pb.AddInterfaceRequest) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (p *gRPCProxy) RemoveInterface(ctx context.Context, req *pb.RemoveInterfaceRequest) (*pb.Interface, error) {
|
||||
func (p *gRPCProxy) RemoveInterface(ctx context.Context, req *pb.RemoveInterfaceRequest) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (p *gRPCProxy) UpdateInterface(ctx context.Context, req *pb.UpdateInterfaceRequest) (*pb.Interface, error) {
|
||||
return &pb.Interface{}, nil
|
||||
func (p *gRPCProxy) UpdateInterface(ctx context.Context, req *pb.UpdateInterfaceRequest) (*types.Interface, error) {
|
||||
return &types.Interface{}, nil
|
||||
}
|
||||
|
||||
func (p *gRPCProxy) UpdateRoutes(ctx context.Context, req *pb.UpdateRoutesRequest) (*pb.Routes, error) {
|
||||
@ -799,7 +800,7 @@ func TestAgentNetworkOperation(t *testing.T) {
|
||||
_, err = k.listInterfaces()
|
||||
assert.Nil(err)
|
||||
|
||||
_, err = k.updateRoutes([]*pb.Route{})
|
||||
_, err = k.updateRoutes([]*types.Route{})
|
||||
assert.Nil(err)
|
||||
|
||||
_, err = k.listRoutes()
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/runtime/virtcontainers/pkg/uuid"
|
||||
"github.com/kata-containers/runtime/virtcontainers/utils"
|
||||
)
|
||||
@ -1148,18 +1148,18 @@ func deleteNetNS(netNSPath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*grpc.Interface, []*grpc.Route, error) {
|
||||
func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*types.Interface, []*types.Route, error) {
|
||||
|
||||
if networkNS.NetNsPath == "" {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
var routes []*grpc.Route
|
||||
var ifaces []*grpc.Interface
|
||||
var routes []*types.Route
|
||||
var ifaces []*types.Interface
|
||||
|
||||
for _, endpoint := range networkNS.Endpoints {
|
||||
|
||||
var ipAddresses []*grpc.IPAddress
|
||||
var ipAddresses []*types.IPAddress
|
||||
for _, addr := range endpoint.Properties().Addrs {
|
||||
// Skip IPv6 because not supported
|
||||
if addr.IP.To4() == nil {
|
||||
@ -1175,14 +1175,14 @@ func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*grpc.Interface,
|
||||
continue
|
||||
}
|
||||
netMask, _ := addr.Mask.Size()
|
||||
ipAddress := grpc.IPAddress{
|
||||
Family: grpc.IPFamily_v4,
|
||||
ipAddress := types.IPAddress{
|
||||
Family: types.IPFamily_v4,
|
||||
Address: addr.IP.String(),
|
||||
Mask: fmt.Sprintf("%d", netMask),
|
||||
}
|
||||
ipAddresses = append(ipAddresses, &ipAddress)
|
||||
}
|
||||
ifc := grpc.Interface{
|
||||
ifc := types.Interface{
|
||||
IPAddresses: ipAddresses,
|
||||
Device: endpoint.Name(),
|
||||
Name: endpoint.Name(),
|
||||
@ -1193,7 +1193,7 @@ func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*grpc.Interface,
|
||||
ifaces = append(ifaces, &ifc)
|
||||
|
||||
for _, route := range endpoint.Properties().Routes {
|
||||
var r grpc.Route
|
||||
var r types.Route
|
||||
|
||||
if route.Dst != nil {
|
||||
r.Dest = route.Dst.String()
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
@ -161,16 +161,16 @@ func TestGenerateInterfacesAndRoutes(t *testing.T) {
|
||||
//
|
||||
// Build expected results:
|
||||
//
|
||||
expectedAddresses := []*grpc.IPAddress{
|
||||
expectedAddresses := []*types.IPAddress{
|
||||
{Family: 0, Address: "172.17.0.2", Mask: "16"},
|
||||
{Family: 0, Address: "182.17.0.2", Mask: "16"},
|
||||
}
|
||||
|
||||
expectedInterfaces := []*grpc.Interface{
|
||||
expectedInterfaces := []*types.Interface{
|
||||
{Device: "eth0", Name: "eth0", IPAddresses: expectedAddresses, Mtu: 1500, HwAddr: "02:00:ca:fe:00:04"},
|
||||
}
|
||||
|
||||
expectedRoutes := []*grpc.Route{
|
||||
expectedRoutes := []*types.Route{
|
||||
{Dest: "", Gateway: "172.17.0.1", Device: "eth0", Source: "", Scope: uint32(254)},
|
||||
{Dest: "172.17.0.0/16", Gateway: "172.17.0.1", Device: "eth0", Source: "172.17.0.2"},
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ package virtcontainers
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"golang.org/x/net/context"
|
||||
@ -94,22 +95,22 @@ func (n *noopAgent) onlineCPUMem(cpus uint32, cpuOnly bool) error {
|
||||
}
|
||||
|
||||
// updateInterface is the Noop agent Interface update implementation. It does nothing.
|
||||
func (n *noopAgent) updateInterface(inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (n *noopAgent) updateInterface(inf *types.Interface) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// listInterfaces is the Noop agent Interfaces list implementation. It does nothing.
|
||||
func (n *noopAgent) listInterfaces() ([]*grpc.Interface, error) {
|
||||
func (n *noopAgent) listInterfaces() ([]*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// updateRoutes is the Noop agent Routes update implementation. It does nothing.
|
||||
func (n *noopAgent) updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func (n *noopAgent) updateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// listRoutes is the Noop agent Routes list implementation. It does nothing.
|
||||
func (n *noopAgent) listRoutes() ([]*grpc.Route, error) {
|
||||
func (n *noopAgent) listRoutes() ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
@ -254,7 +254,7 @@ func (m *VCMock) AddDevice(ctx context.Context, sandboxID string, info config.De
|
||||
}
|
||||
|
||||
// AddInterface implements the VC function of the same name.
|
||||
func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
if m.AddInterfaceFunc != nil {
|
||||
return m.AddInterfaceFunc(ctx, sandboxID, inf)
|
||||
}
|
||||
@ -263,7 +263,7 @@ func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *grpc.I
|
||||
}
|
||||
|
||||
// RemoveInterface implements the VC function of the same name.
|
||||
func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
||||
if m.RemoveInterfaceFunc != nil {
|
||||
return m.RemoveInterfaceFunc(ctx, sandboxID, inf)
|
||||
}
|
||||
@ -272,7 +272,7 @@ func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *grp
|
||||
}
|
||||
|
||||
// ListInterfaces implements the VC function of the same name.
|
||||
func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*grpc.Interface, error) {
|
||||
func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
||||
if m.ListInterfacesFunc != nil {
|
||||
return m.ListInterfacesFunc(ctx, sandboxID)
|
||||
}
|
||||
@ -281,7 +281,7 @@ func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*grpc.
|
||||
}
|
||||
|
||||
// UpdateRoutes implements the VC function of the same name.
|
||||
func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
||||
if m.UpdateRoutesFunc != nil {
|
||||
return m.UpdateRoutesFunc(ctx, sandboxID, routes)
|
||||
}
|
||||
@ -290,7 +290,7 @@ func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*g
|
||||
}
|
||||
|
||||
// ListRoutes implements the VC function of the same name.
|
||||
func (m *VCMock) ListRoutes(ctx context.Context, sandboxID string) ([]*grpc.Route, error) {
|
||||
func (m *VCMock) ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
||||
if m.ListRoutesFunc != nil {
|
||||
return m.ListRoutesFunc(ctx, sandboxID)
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
"github.com/kata-containers/runtime/virtcontainers/factory"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -748,7 +748,7 @@ func TestVCMockAddInterface(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.AddInterfaceFunc = func(ctx context.Context, sid string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
m.AddInterfaceFunc = func(ctx context.Context, sid string, inf *types.Interface) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -775,7 +775,7 @@ func TestVCMockRemoveInterface(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.RemoveInterfaceFunc = func(ctx context.Context, sid string, inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
m.RemoveInterfaceFunc = func(ctx context.Context, sid string, inf *types.Interface) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -802,7 +802,7 @@ func TestVCMockListInterfaces(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.ListInterfacesFunc = func(ctx context.Context, sid string) ([]*grpc.Interface, error) {
|
||||
m.ListInterfacesFunc = func(ctx context.Context, sid string) ([]*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -829,7 +829,7 @@ func TestVCMockUpdateRoutes(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.UpdateRoutesFunc = func(ctx context.Context, sid string, routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
m.UpdateRoutesFunc = func(ctx context.Context, sid string, routes []*types.Route) ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -856,7 +856,7 @@ func TestVCMockListRoutes(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.ListRoutesFunc = func(ctx context.Context, sid string) ([]*grpc.Route, error) {
|
||||
m.ListRoutesFunc = func(ctx context.Context, sid string) ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"io"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
@ -153,26 +153,26 @@ func (s *Sandbox) AddDevice(info config.DeviceInfo) (api.Device, error) {
|
||||
}
|
||||
|
||||
// AddInterface implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) AddInterface(inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (s *Sandbox) AddInterface(inf *types.Interface) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// RemoveInterface implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (s *Sandbox) RemoveInterface(inf *types.Interface) (*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ListInterfaces implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) ListInterfaces() ([]*grpc.Interface, error) {
|
||||
func (s *Sandbox) ListInterfaces() ([]*types.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// UpdateRoutes implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) UpdateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func (s *Sandbox) UpdateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ListRoutes implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) ListRoutes() ([]*grpc.Route, error) {
|
||||
func (s *Sandbox) ListRoutes() ([]*types.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"context"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
@ -69,9 +69,9 @@ type VCMock struct {
|
||||
|
||||
AddDeviceFunc func(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
||||
|
||||
AddInterfaceFunc func(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error)
|
||||
RemoveInterfaceFunc func(ctx context.Context, sandboxID string, inf *grpc.Interface) (*grpc.Interface, error)
|
||||
ListInterfacesFunc func(ctx context.Context, sandboxID string) ([]*grpc.Interface, error)
|
||||
UpdateRoutesFunc func(ctx context.Context, sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error)
|
||||
ListRoutesFunc func(ctx context.Context, sandboxID string) ([]*grpc.Route, error)
|
||||
AddInterfaceFunc func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
||||
RemoveInterfaceFunc func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
||||
ListInterfacesFunc func(ctx context.Context, sandboxID string) ([]*types.Interface, error)
|
||||
UpdateRoutesFunc func(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error)
|
||||
ListRoutesFunc func(ctx context.Context, sandboxID string) ([]*types.Route, error)
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/kata-containers/agent/pkg/types"
|
||||
"github.com/kata-containers/agent/protocols/grpc"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
@ -1076,7 +1077,7 @@ func (s *Sandbox) removeNetwork() error {
|
||||
return s.network.remove(s)
|
||||
}
|
||||
|
||||
func (s *Sandbox) generateNetInfo(inf *grpc.Interface) (NetworkInfo, error) {
|
||||
func (s *Sandbox) generateNetInfo(inf *types.Interface) (NetworkInfo, error) {
|
||||
hw, err := net.ParseMAC(inf.HwAddr)
|
||||
if err != nil {
|
||||
return NetworkInfo{}, err
|
||||
@ -1114,7 +1115,7 @@ func (s *Sandbox) generateNetInfo(inf *grpc.Interface) (NetworkInfo, error) {
|
||||
}
|
||||
|
||||
// AddInterface adds new nic to the sandbox.
|
||||
func (s *Sandbox) AddInterface(inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (s *Sandbox) AddInterface(inf *types.Interface) (*types.Interface, error) {
|
||||
netInfo, err := s.generateNetInfo(inf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1145,7 +1146,7 @@ func (s *Sandbox) AddInterface(inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
}
|
||||
|
||||
// RemoveInterface removes a nic of the sandbox.
|
||||
func (s *Sandbox) RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error) {
|
||||
func (s *Sandbox) RemoveInterface(inf *types.Interface) (*types.Interface, error) {
|
||||
for i, endpoint := range s.networkNS.Endpoints {
|
||||
if endpoint.HardwareAddr() == inf.HwAddr {
|
||||
s.Logger().WithField("endpoint-type", endpoint.Type()).Info("Hot detaching endpoint")
|
||||
@ -1163,17 +1164,17 @@ func (s *Sandbox) RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error)
|
||||
}
|
||||
|
||||
// ListInterfaces lists all nics and their configurations in the sandbox.
|
||||
func (s *Sandbox) ListInterfaces() ([]*grpc.Interface, error) {
|
||||
func (s *Sandbox) ListInterfaces() ([]*types.Interface, error) {
|
||||
return s.agent.listInterfaces()
|
||||
}
|
||||
|
||||
// UpdateRoutes updates the sandbox route table (e.g. for portmapping support).
|
||||
func (s *Sandbox) UpdateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) {
|
||||
func (s *Sandbox) UpdateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
||||
return s.agent.updateRoutes(routes)
|
||||
}
|
||||
|
||||
// ListRoutes lists all routes and their configurations in the sandbox.
|
||||
func (s *Sandbox) ListRoutes() ([]*grpc.Route, error) {
|
||||
func (s *Sandbox) ListRoutes() ([]*types.Route, error) {
|
||||
return s.agent.listRoutes()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user