mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-24 06:27:39 +00:00
vc: add agent.container_pipe_size annotation
This adds the `agent.container_pipe_size` annotation which allows configuration of the size of the pipes for stdout/stderr for containers inside the guest. fixes #2467 Signed-off-by: Alex Price <aprice@atlassian.com>
This commit is contained in:
parent
e94cf0f135
commit
4c28717335
@ -162,13 +162,14 @@ func ephemeralPath() string {
|
|||||||
// KataAgentConfig is a structure storing information needed
|
// KataAgentConfig is a structure storing information needed
|
||||||
// to reach the Kata Containers agent.
|
// to reach the Kata Containers agent.
|
||||||
type KataAgentConfig struct {
|
type KataAgentConfig struct {
|
||||||
LongLiveConn bool
|
LongLiveConn bool
|
||||||
UseVSock bool
|
UseVSock bool
|
||||||
Debug bool
|
Debug bool
|
||||||
Trace bool
|
Trace bool
|
||||||
TraceMode string
|
ContainerPipeSize uint32
|
||||||
TraceType string
|
TraceMode string
|
||||||
KernelModules []string
|
TraceType string
|
||||||
|
KernelModules []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// KataAgentState is the structure describing the data stored from this
|
// KataAgentState is the structure describing the data stored from this
|
||||||
@ -265,6 +266,11 @@ func KataAgentKernelParams(config KataAgentConfig) []Param {
|
|||||||
params = append(params, Param{Key: "agent.trace", Value: config.TraceType})
|
params = append(params, Param{Key: "agent.trace", Value: config.TraceType})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.ContainerPipeSize > 0 {
|
||||||
|
containerPipeSize := strconv.FormatUint(uint64(config.ContainerPipeSize), 10)
|
||||||
|
params = append(params, Param{Key: vcAnnotations.ContainerPipeSizeKernelParam, Value: containerPipeSize})
|
||||||
|
}
|
||||||
|
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@ -923,11 +924,12 @@ func TestKataAgentKernelParams(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
type testData struct {
|
type testData struct {
|
||||||
debug bool
|
debug bool
|
||||||
trace bool
|
trace bool
|
||||||
traceMode string
|
containerPipeSize uint32
|
||||||
traceType string
|
traceMode string
|
||||||
expectedParams []Param
|
traceType string
|
||||||
|
expectedParams []Param
|
||||||
}
|
}
|
||||||
|
|
||||||
debugParam := Param{Key: "agent.log", Value: "debug"}
|
debugParam := Param{Key: "agent.log", Value: "debug"}
|
||||||
@ -937,58 +939,64 @@ func TestKataAgentKernelParams(t *testing.T) {
|
|||||||
|
|
||||||
traceFooParam := Param{Key: "agent.trace", Value: "foo"}
|
traceFooParam := Param{Key: "agent.trace", Value: "foo"}
|
||||||
|
|
||||||
|
containerPipeSizeParam := Param{Key: vcAnnotations.ContainerPipeSizeKernelParam, Value: "2097152"}
|
||||||
|
|
||||||
data := []testData{
|
data := []testData{
|
||||||
{false, false, "", "", []Param{}},
|
{false, false, 0, "", "", []Param{}},
|
||||||
{true, false, "", "", []Param{debugParam}},
|
{true, false, 0, "", "", []Param{debugParam}},
|
||||||
|
|
||||||
{false, false, "foo", "", []Param{}},
|
{false, false, 0, "foo", "", []Param{}},
|
||||||
{false, false, "foo", "", []Param{}},
|
{false, false, 0, "foo", "", []Param{}},
|
||||||
{false, false, "", "foo", []Param{}},
|
{false, false, 0, "", "foo", []Param{}},
|
||||||
{false, false, "", "foo", []Param{}},
|
{false, false, 0, "", "foo", []Param{}},
|
||||||
{false, false, "foo", "foo", []Param{}},
|
{false, false, 0, "foo", "foo", []Param{}},
|
||||||
{false, true, "foo", "foo", []Param{}},
|
{false, true, 0, "foo", "foo", []Param{}},
|
||||||
|
|
||||||
{false, false, agentTraceModeDynamic, "", []Param{}},
|
{false, false, 0, agentTraceModeDynamic, "", []Param{}},
|
||||||
{false, false, agentTraceModeStatic, "", []Param{}},
|
{false, false, 0, agentTraceModeStatic, "", []Param{}},
|
||||||
{false, false, "", agentTraceTypeIsolated, []Param{}},
|
{false, false, 0, "", agentTraceTypeIsolated, []Param{}},
|
||||||
{false, false, "", agentTraceTypeCollated, []Param{}},
|
{false, false, 0, "", agentTraceTypeCollated, []Param{}},
|
||||||
{false, false, "foo", agentTraceTypeIsolated, []Param{}},
|
{false, false, 0, "foo", agentTraceTypeIsolated, []Param{}},
|
||||||
{false, false, "foo", agentTraceTypeCollated, []Param{}},
|
{false, false, 0, "foo", agentTraceTypeCollated, []Param{}},
|
||||||
|
|
||||||
{false, false, agentTraceModeDynamic, agentTraceTypeIsolated, []Param{}},
|
{false, false, 0, agentTraceModeDynamic, agentTraceTypeIsolated, []Param{}},
|
||||||
{false, false, agentTraceModeDynamic, agentTraceTypeCollated, []Param{}},
|
{false, false, 0, agentTraceModeDynamic, agentTraceTypeCollated, []Param{}},
|
||||||
|
|
||||||
{false, false, agentTraceModeStatic, agentTraceTypeCollated, []Param{}},
|
{false, false, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{}},
|
||||||
{false, false, agentTraceModeStatic, agentTraceTypeCollated, []Param{}},
|
{false, false, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{}},
|
||||||
|
|
||||||
{false, true, agentTraceModeDynamic, agentTraceTypeIsolated, []Param{}},
|
{false, true, 0, agentTraceModeDynamic, agentTraceTypeIsolated, []Param{}},
|
||||||
{false, true, agentTraceModeDynamic, agentTraceTypeCollated, []Param{}},
|
{false, true, 0, agentTraceModeDynamic, agentTraceTypeCollated, []Param{}},
|
||||||
{true, true, agentTraceModeDynamic, agentTraceTypeCollated, []Param{debugParam}},
|
{true, true, 0, agentTraceModeDynamic, agentTraceTypeCollated, []Param{debugParam}},
|
||||||
|
|
||||||
{false, true, "", agentTraceTypeIsolated, []Param{}},
|
{false, true, 0, "", agentTraceTypeIsolated, []Param{}},
|
||||||
{false, true, "", agentTraceTypeCollated, []Param{}},
|
{false, true, 0, "", agentTraceTypeCollated, []Param{}},
|
||||||
{true, true, "", agentTraceTypeIsolated, []Param{debugParam}},
|
{true, true, 0, "", agentTraceTypeIsolated, []Param{debugParam}},
|
||||||
{true, true, "", agentTraceTypeCollated, []Param{debugParam}},
|
{true, true, 0, "", agentTraceTypeCollated, []Param{debugParam}},
|
||||||
{false, true, "foo", agentTraceTypeIsolated, []Param{}},
|
{false, true, 0, "foo", agentTraceTypeIsolated, []Param{}},
|
||||||
{false, true, "foo", agentTraceTypeCollated, []Param{}},
|
{false, true, 0, "foo", agentTraceTypeCollated, []Param{}},
|
||||||
{true, true, "foo", agentTraceTypeIsolated, []Param{debugParam}},
|
{true, true, 0, "foo", agentTraceTypeIsolated, []Param{debugParam}},
|
||||||
{true, true, "foo", agentTraceTypeCollated, []Param{debugParam}},
|
{true, true, 0, "foo", agentTraceTypeCollated, []Param{debugParam}},
|
||||||
|
|
||||||
{false, true, agentTraceModeStatic, agentTraceTypeIsolated, []Param{traceIsolatedParam}},
|
{false, true, 0, agentTraceModeStatic, agentTraceTypeIsolated, []Param{traceIsolatedParam}},
|
||||||
{false, true, agentTraceModeStatic, agentTraceTypeCollated, []Param{traceCollatedParam}},
|
{false, true, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{traceCollatedParam}},
|
||||||
{true, true, agentTraceModeStatic, agentTraceTypeIsolated, []Param{traceIsolatedParam, debugParam}},
|
{true, true, 0, agentTraceModeStatic, agentTraceTypeIsolated, []Param{traceIsolatedParam, debugParam}},
|
||||||
{true, true, agentTraceModeStatic, agentTraceTypeCollated, []Param{traceCollatedParam, debugParam}},
|
{true, true, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{traceCollatedParam, debugParam}},
|
||||||
|
|
||||||
{false, true, agentTraceModeStatic, "foo", []Param{traceFooParam}},
|
{false, true, 0, agentTraceModeStatic, "foo", []Param{traceFooParam}},
|
||||||
{true, true, agentTraceModeStatic, "foo", []Param{debugParam, traceFooParam}},
|
{true, true, 0, agentTraceModeStatic, "foo", []Param{debugParam, traceFooParam}},
|
||||||
|
|
||||||
|
{false, false, 0, "", "", []Param{}},
|
||||||
|
{false, false, 2097152, "", "", []Param{containerPipeSizeParam}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, d := range data {
|
for i, d := range data {
|
||||||
config := KataAgentConfig{
|
config := KataAgentConfig{
|
||||||
Debug: d.debug,
|
Debug: d.debug,
|
||||||
Trace: d.trace,
|
Trace: d.trace,
|
||||||
TraceMode: d.traceMode,
|
TraceMode: d.traceMode,
|
||||||
TraceType: d.traceType,
|
TraceType: d.traceType,
|
||||||
|
ContainerPipeSize: d.containerPipeSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
count := len(d.expectedParams)
|
count := len(d.expectedParams)
|
||||||
|
@ -237,6 +237,11 @@ const (
|
|||||||
|
|
||||||
// AgentTraceMode is a sandbox annotation to specify the trace type for the agent.
|
// AgentTraceMode is a sandbox annotation to specify the trace type for the agent.
|
||||||
AgentTraceType = kataAnnotAgentPrefix + "trace_type"
|
AgentTraceType = kataAnnotAgentPrefix + "trace_type"
|
||||||
|
|
||||||
|
// AgentContainerPipeSize is an annotation to specify the size of the pipes created for containers
|
||||||
|
AgentContainerPipeSize = kataAnnotAgentPrefix + ContainerPipeSizeOption
|
||||||
|
ContainerPipeSizeOption = "container_pipe_size"
|
||||||
|
ContainerPipeSizeKernelParam = "agent." + ContainerPipeSizeOption
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -775,6 +775,14 @@ func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error
|
|||||||
c.TraceType = value
|
c.TraceType = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if value, ok := ocispec.Annotations[vcAnnotations.AgentContainerPipeSize]; ok {
|
||||||
|
containerPipeSize, err := strconv.ParseUint(value, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error parsing annotation for %s: Please specify uint32 value", vcAnnotations.AgentContainerPipeSize)
|
||||||
|
}
|
||||||
|
c.ContainerPipeSize = uint32(containerPipeSize)
|
||||||
|
}
|
||||||
|
|
||||||
config.AgentConfig = c
|
config.AgentConfig = c
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -701,13 +701,37 @@ func TestAddAgentAnnotations(t *testing.T) {
|
|||||||
"e1000e InterruptThrottleRate=3000,3000,3000 EEE=1",
|
"e1000e InterruptThrottleRate=3000,3000,3000 EEE=1",
|
||||||
"i915 enable_ppgtt=0",
|
"i915 enable_ppgtt=0",
|
||||||
},
|
},
|
||||||
|
ContainerPipeSize: 1024,
|
||||||
}
|
}
|
||||||
|
|
||||||
ocispec.Annotations[vcAnnotations.KernelModules] = strings.Join(expectedAgentConfig.KernelModules, KernelModulesSeparator)
|
ocispec.Annotations[vcAnnotations.KernelModules] = strings.Join(expectedAgentConfig.KernelModules, KernelModulesSeparator)
|
||||||
|
ocispec.Annotations[vcAnnotations.AgentContainerPipeSize] = "1024"
|
||||||
addAnnotations(ocispec, &config)
|
addAnnotations(ocispec, &config)
|
||||||
assert.Exactly(expectedAgentConfig, config.AgentConfig)
|
assert.Exactly(expectedAgentConfig, config.AgentConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContainerPipeSizeAnnotation(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
config := vc.SandboxConfig{
|
||||||
|
Annotations: make(map[string]string),
|
||||||
|
AgentConfig: vc.KataAgentConfig{},
|
||||||
|
}
|
||||||
|
|
||||||
|
ocispec := specs.Spec{
|
||||||
|
Annotations: make(map[string]string),
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedAgentConfig := vc.KataAgentConfig{
|
||||||
|
ContainerPipeSize: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
ocispec.Annotations[vcAnnotations.AgentContainerPipeSize] = "foo"
|
||||||
|
err := addAnnotations(ocispec, &config)
|
||||||
|
assert.Error(err)
|
||||||
|
assert.Exactly(expectedAgentConfig, config.AgentConfig)
|
||||||
|
}
|
||||||
|
|
||||||
func TestAddHypervisorAnnotations(t *testing.T) {
|
func TestAddHypervisorAnnotations(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ func TestVMConfigGrpc(t *testing.T) {
|
|||||||
HypervisorType: QemuHypervisor,
|
HypervisorType: QemuHypervisor,
|
||||||
HypervisorConfig: newQemuConfig(),
|
HypervisorConfig: newQemuConfig(),
|
||||||
AgentType: KataContainersAgent,
|
AgentType: KataContainersAgent,
|
||||||
AgentConfig: KataAgentConfig{false, true, false, false, "", "", []string{}},
|
AgentConfig: KataAgentConfig{false, true, false, false, 0, "", "", []string{}},
|
||||||
ProxyType: NoopProxyType,
|
ProxyType: NoopProxyType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user