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

Add agent trace support #1442

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 21 additions & 41 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[[constraint]]
name = "github.com/clearcontainers/proxy"
revision = "1d2a6a3ea132a86abd0731408b7dc34f2fc17d55"

[[constraint]]
name = "github.com/containernetworking/plugins"
revision = "7f98c94613021d8b57acfa1a2f0c8d0f6fd7ae5a"
Expand Down
26 changes: 24 additions & 2 deletions cli/config/configuration-fc.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,30 @@ path = "@SHIMPATH@"
#enable_tracing = true

[agent.@PROJECT_TYPE@]
# There is no field for this section. The goal is only to be able to
# specify which type of agent the user wants to use.
# If enabled, make the agent display debug-level messages.
# (default: disabled)
#enable_debug = true

# Enable agent tracing.
#
# If enabled, the default trace mode is "dynamic" and the
# default trace type is "isolated". The trace mode and type are set
# explicity with the `trace_type=` and `trace_mode=` options.
#
# Notes:
#
# - Tracing is ONLY enabled when `enable_tracing` is set: explicitly
# setting `trace_mode=` and/or `trace_type=` without setting `enable_tracing`
# will NOT activate agent tracing.
#
# - See https://github.com/kata-containers/agent/blob/master/TRACING.md for
# full details.
#
# (default: disabled)
#enable_tracing = true
Copy link

Choose a reason for hiding this comment

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

I wonder if it's time to have a specific section for tracing, [trace] might be...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point. Yes, we could make a sub-section like the one below, but it might involve more rework as none of the other sections have sub-sections in them:

[agent.kata]

enable_debug = true

[agent.kata.trace]
enabled = true
mode = "dynamic"
type = "isolated"

But we haven't done that historically. For example, we have two "groups" of options for the hypervisor section:

memory_slots = ...
memory_offset = ...

block_device_driver = ...
block_device_cache_set = ...
block_device_cache_noflush = ...

For consistency they would also need new subsections too.

I am tempted to suggest -- although not ideal I know -- that we keep the status quo for now and potentially totally rework the configuration handling in v2.

#
#trace_mode = "dynamic"
#trace_type = "isolated"
Copy link

Choose a reason for hiding this comment

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

are there option mutually exclusive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


[netmon]
# If enabled, the network monitoring process gets started when the
Expand Down
26 changes: 24 additions & 2 deletions cli/config/configuration-qemu.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,30 @@ path = "@SHIMPATH@"
#enable_tracing = true

[agent.@PROJECT_TYPE@]
# There is no field for this section. The goal is only to be able to
# specify which type of agent the user wants to use.
# If enabled, make the agent display debug-level messages.
# (default: disabled)
#enable_debug = true

# Enable agent tracing.
#
# If enabled, the default trace mode is "dynamic" and the
# default trace type is "isolated". The trace mode and type are set
# explicity with the `trace_type=` and `trace_mode=` options.
#
# Notes:
#
# - Tracing is ONLY enabled when `enable_tracing` is set: explicitly
# setting `trace_mode=` and/or `trace_type=` without setting `enable_tracing`
# will NOT activate agent tracing.
#
# - See https://github.com/kata-containers/agent/blob/master/TRACING.md for
# full details.
#
# (default: disabled)
#enable_tracing = true
#
#trace_mode = "dynamic"
#trace_type = "isolated"

[netmon]
# If enabled, the network monitoring process gets started when the
Expand Down
33 changes: 27 additions & 6 deletions cli/kata-env.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 Intel Corporation
// Copyright (c) 2017-2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -27,7 +27,7 @@ import (
//
// XXX: Increment for every change to the output format
// (meaning any change to the EnvInfo type).
const formatVersion = "1.0.21"
const formatVersion = "1.0.23"
Copy link

Choose a reason for hiding this comment

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

mathematics has changed since I left the school 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha! Well, there are two bumps to this number in this PR :)


// MetaInfo stores information on the format of the output itself
type MetaInfo struct {
Expand Down Expand Up @@ -112,7 +112,11 @@ type ShimInfo struct {

// AgentInfo stores agent details
type AgentInfo struct {
Type string
Type string
Debug bool
Trace bool
TraceMode string
TraceType string
}

// DistroInfo stores host operating system distribution details.
Expand Down Expand Up @@ -308,12 +312,26 @@ func getShimInfo(config oci.RuntimeConfig) (ShimInfo, error) {
return shim, nil
}

func getAgentInfo(config oci.RuntimeConfig) AgentInfo {
func getAgentInfo(config oci.RuntimeConfig) (AgentInfo, error) {
agent := AgentInfo{
Type: string(config.AgentType),
}

return agent
switch config.AgentType {
case vc.KataContainersAgent:
agentConfig, ok := config.AgentConfig.(vc.KataAgentConfig)
if !ok {
return AgentInfo{}, errors.New("cannot determine Kata agent config")
}
agent.Debug = agentConfig.Debug
agent.Trace = agentConfig.Trace
agent.TraceMode = agentConfig.TraceMode
agent.TraceType = agentConfig.TraceType
default:
// Nothing useful to report for the other agent types
}

return agent, nil
}

func getHypervisorInfo(config oci.RuntimeConfig) HypervisorInfo {
Expand Down Expand Up @@ -361,7 +379,10 @@ func getEnvInfo(configFile string, config oci.RuntimeConfig) (env EnvInfo, err e
return EnvInfo{}, err
}

agent := getAgentInfo(config)
agent, err := getAgentInfo(config)
if err != nil {
return EnvInfo{}, err
}

hypervisor := getHypervisorInfo(config)

Expand Down
Loading