Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
annotations: add Annotations for the agent.
Browse files Browse the repository at this point in the history
The annotations handle the tracing config for the agent.

Signed-off-by: Archana Shinde <[email protected]>
  • Loading branch information
amshinde committed Oct 3, 2019
1 parent 5b78a8a commit 8405b56
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
10 changes: 10 additions & 0 deletions virtcontainers/pkg/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const (
BlockDeviceCacheNoflush = kataAnnotHypervisorPrefix + "block_device_cache_noflush"
)

// Agent related annotations
const (
kataAnnotRuntimePrefix = kataConfAnnotationsPrefix + "runtime."

Expand Down Expand Up @@ -215,6 +216,15 @@ const (
// The first word is considered as the module name and the rest as its parameters.
//
KernelModules = kataAnnotAgentPrefix + "kernel_modules"

// AgentTrace is a sandbox annotation to enable tracing for the agent.
AgentTrace = kataAnnotAgentPrefix + "enable_tracing"

// AgentTraceMode is a sandbox annotation to specify the trace mode for the agent.
AgentTraceMode = kataAnnotAgentPrefix + "trace_mode"

// AgentTraceMode is a sandbox annotation to specify the trace type for the agent.
AgentTraceType = kataAnnotAgentPrefix + "trace_type"
)

const (
Expand Down
29 changes: 25 additions & 4 deletions virtcontainers/pkg/oci/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,14 +714,35 @@ func addRuntimeConfigOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig) e
}

func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error {
c, ok := config.AgentConfig.(vc.KataAgentConfig)
if !ok {
return nil
}

if value, ok := ocispec.Annotations[vcAnnotations.KernelModules]; ok {
if c, ok := config.AgentConfig.(vc.KataAgentConfig); ok {
modules := strings.Split(value, KernelModulesSeparator)
c.KernelModules = modules
config.AgentConfig = c
modules := strings.Split(value, KernelModulesSeparator)
c.KernelModules = modules
config.AgentConfig = c
}

if value, ok := ocispec.Annotations[vcAnnotations.AgentTrace]; ok {
trace, err := strconv.ParseBool(value)
if err != nil {
return fmt.Errorf("Error parsing annotation for agent.trace: Please specify boolean value 'true|false'")
}
c.Trace = trace
}

if value, ok := ocispec.Annotations[vcAnnotations.AgentTraceMode]; ok {
c.TraceMode = value
}

if value, ok := ocispec.Annotations[vcAnnotations.AgentTraceType]; ok {
c.TraceType = value
}

config.AgentConfig = c

return nil
}

Expand Down

0 comments on commit 8405b56

Please sign in to comment.