mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-24 22:43:05 +00:00
tracing: Remove trace mode and trace type
Remove the `trace_mode` and `trace_type` agent tracing options as decided in the Architecture Committee meeting. See: - https://github.com/kata-containers/kata-containers/pull/2062 Fixes: #2352. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
119edcc443
commit
321be0f794
@ -34,8 +34,6 @@ There are several kinds of Kata configurations and they are listed below.
|
||||
| `io.katacontainers.config.agent.enable_tracing` | `boolean` | enable tracing for the agent |
|
||||
| `io.katacontainers.config.agent.container_pipe_size` | uint32 | specify the size of the std(in/out) pipes created for containers |
|
||||
| `io.katacontainers.config.agent.kernel_modules` | string | the list of kernel modules and their parameters that will be loaded in the guest kernel. Semicolon separated list of kernel modules and their parameters. These modules will be loaded in the guest kernel using `modprobe`(8). E.g., `e1000e InterruptThrottleRate=3000,3000,3000 EEE=1; i915 enable_ppgtt=0` |
|
||||
| `io.katacontainers.config.agent.trace_mode` | string | the trace mode for the agent |
|
||||
| `io.katacontainers.config.agent.trace_type` | string | the trace type for the agent |
|
||||
|
||||
## Hypervisor Options
|
||||
| Key | Value Type | Comments |
|
||||
|
@ -2,7 +2,6 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
use crate::tracer;
|
||||
use anyhow::{bail, ensure, Context, Result};
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashSet;
|
||||
@ -33,7 +32,7 @@ const VSOCK_PORT: u16 = 1024;
|
||||
// Environment variables used for development and testing
|
||||
const SERVER_ADDR_ENV_VAR: &str = "KATA_AGENT_SERVER_ADDR";
|
||||
const LOG_LEVEL_ENV_VAR: &str = "KATA_AGENT_LOG_LEVEL";
|
||||
const TRACE_TYPE_ENV_VAR: &str = "KATA_AGENT_TRACE_TYPE";
|
||||
const TRACING_ENV_VAR: &str = "KATA_AGENT_TRACING";
|
||||
|
||||
const ERR_INVALID_LOG_LEVEL: &str = "invalid log level";
|
||||
const ERR_INVALID_LOG_LEVEL_PARAM: &str = "invalid log level parameter";
|
||||
@ -73,7 +72,7 @@ pub struct AgentConfig {
|
||||
pub container_pipe_size: i32,
|
||||
pub server_addr: String,
|
||||
pub unified_cgroup_hierarchy: bool,
|
||||
pub tracing: tracer::TraceType,
|
||||
pub tracing: bool,
|
||||
pub endpoints: AgentEndpoints,
|
||||
}
|
||||
|
||||
@ -88,7 +87,7 @@ pub struct AgentConfigBuilder {
|
||||
pub container_pipe_size: Option<i32>,
|
||||
pub server_addr: Option<String>,
|
||||
pub unified_cgroup_hierarchy: Option<bool>,
|
||||
pub tracing: Option<tracer::TraceType>,
|
||||
pub tracing: Option<bool>,
|
||||
pub endpoints: Option<EndpointsConfig>,
|
||||
}
|
||||
|
||||
@ -148,7 +147,7 @@ impl Default for AgentConfig {
|
||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||
server_addr: format!("{}:{}", VSOCK_ADDR, VSOCK_PORT),
|
||||
unified_cgroup_hierarchy: false,
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
tracing: false,
|
||||
endpoints: Default::default(),
|
||||
}
|
||||
}
|
||||
@ -213,11 +212,11 @@ impl AgentConfig {
|
||||
// Support "bare" tracing option for backwards compatibility with
|
||||
// Kata 1.x.
|
||||
if param == &TRACE_MODE_OPTION {
|
||||
config.tracing = tracer::TraceType::Isolated;
|
||||
config.tracing = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
parse_cmdline_param!(param, TRACE_MODE_OPTION, config.tracing, get_trace_type);
|
||||
parse_cmdline_param!(param, TRACE_MODE_OPTION, config.tracing, get_bool_value);
|
||||
|
||||
// parse cmdline options
|
||||
parse_cmdline_param!(param, LOG_LEVEL_OPTION, config.log_level, get_log_level);
|
||||
@ -277,10 +276,10 @@ impl AgentConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(value) = env::var(TRACE_TYPE_ENV_VAR) {
|
||||
if let Ok(result) = value.parse::<tracer::TraceType>() {
|
||||
config.tracing = result;
|
||||
}
|
||||
if let Ok(value) = env::var(TRACING_ENV_VAR) {
|
||||
let name_value = format!("{}={}", TRACING_ENV_VAR, value);
|
||||
|
||||
config.tracing = get_bool_value(&name_value)?;
|
||||
}
|
||||
|
||||
// We did not get a configuration file: allow all endpoints.
|
||||
@ -343,25 +342,6 @@ fn get_log_level(param: &str) -> Result<slog::Level> {
|
||||
logrus_to_slog_level(fields[1])
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
fn get_trace_type(param: &str) -> Result<tracer::TraceType> {
|
||||
ensure!(!param.is_empty(), "invalid trace type parameter");
|
||||
|
||||
let fields: Vec<&str> = param.split('=').collect();
|
||||
ensure!(
|
||||
fields[0] == TRACE_MODE_OPTION,
|
||||
"invalid trace type key name"
|
||||
);
|
||||
|
||||
if fields.len() == 1 {
|
||||
return Ok(tracer::TraceType::Isolated);
|
||||
}
|
||||
|
||||
let result = fields[1].parse::<tracer::TraceType>()?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
fn get_hotplug_timeout(param: &str) -> Result<time::Duration> {
|
||||
let fields: Vec<&str> = param.split('=').collect();
|
||||
@ -446,10 +426,6 @@ mod tests {
|
||||
use std::time;
|
||||
use tempfile::tempdir;
|
||||
|
||||
const ERR_INVALID_TRACE_TYPE_PARAM: &str = "invalid trace type parameter";
|
||||
const ERR_INVALID_TRACE_TYPE: &str = "invalid trace type";
|
||||
const ERR_INVALID_TRACE_TYPE_KEY: &str = "invalid trace type key name";
|
||||
|
||||
// Parameters:
|
||||
//
|
||||
// 1: expected Result
|
||||
@ -500,7 +476,7 @@ mod tests {
|
||||
container_pipe_size: i32,
|
||||
server_addr: &'a str,
|
||||
unified_cgroup_hierarchy: bool,
|
||||
tracing: tracer::TraceType,
|
||||
tracing: bool,
|
||||
}
|
||||
|
||||
impl Default for TestData<'_> {
|
||||
@ -515,7 +491,7 @@ mod tests {
|
||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||
server_addr: TEST_SERVER_ADDR,
|
||||
unified_cgroup_hierarchy: false,
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
tracing: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -774,49 +750,115 @@ mod tests {
|
||||
},
|
||||
TestData {
|
||||
contents: "trace",
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: ".trace",
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.tracer",
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trac",
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace",
|
||||
tracing: tracer::TraceType::Isolated,
|
||||
tracing: true,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=isolated",
|
||||
tracing: tracer::TraceType::Isolated,
|
||||
contents: "agent.trace=true",
|
||||
tracing: true,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=disabled",
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
contents: "agent.trace=false",
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=0",
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=1",
|
||||
tracing: true,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=a",
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=foo",
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=.",
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "agent.trace=,",
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACE_TYPE=isolated"],
|
||||
tracing: tracer::TraceType::Isolated,
|
||||
env_vars: vec!["KATA_AGENT_TRACING="],
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACE_TYPE=disabled"],
|
||||
tracing: tracer::TraceType::Disabled,
|
||||
env_vars: vec!["KATA_AGENT_TRACING=''"],
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACING=0"],
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACING=."],
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACING=,"],
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACING=foo"],
|
||||
tracing: false,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACING=1"],
|
||||
tracing: true,
|
||||
..Default::default()
|
||||
},
|
||||
TestData {
|
||||
contents: "",
|
||||
env_vars: vec!["KATA_AGENT_TRACING=true"],
|
||||
tracing: true,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
@ -1302,64 +1344,6 @@ Caused by:
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_trace_type() {
|
||||
#[derive(Debug)]
|
||||
struct TestData<'a> {
|
||||
param: &'a str,
|
||||
result: Result<tracer::TraceType>,
|
||||
}
|
||||
|
||||
let tests = &[
|
||||
TestData {
|
||||
param: "",
|
||||
result: Err(anyhow!(ERR_INVALID_TRACE_TYPE_PARAM)),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.tracer",
|
||||
result: Err(anyhow!(ERR_INVALID_TRACE_TYPE_KEY)),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.trac",
|
||||
result: Err(anyhow!(ERR_INVALID_TRACE_TYPE_KEY)),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.trace=",
|
||||
result: Err(anyhow!(ERR_INVALID_TRACE_TYPE)),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.trace==",
|
||||
result: Err(anyhow!(ERR_INVALID_TRACE_TYPE)),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.trace=foo",
|
||||
result: Err(anyhow!(ERR_INVALID_TRACE_TYPE)),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.trace",
|
||||
result: Ok(tracer::TraceType::Isolated),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.trace=isolated",
|
||||
result: Ok(tracer::TraceType::Isolated),
|
||||
},
|
||||
TestData {
|
||||
param: "agent.trace=disabled",
|
||||
result: Ok(tracer::TraceType::Disabled),
|
||||
},
|
||||
];
|
||||
|
||||
for (i, d) in tests.iter().enumerate() {
|
||||
let msg = format!("test[{}]: {:?}", i, d);
|
||||
|
||||
let result = get_trace_type(d.param);
|
||||
|
||||
let msg = format!("{}: result: {:?}", msg, result);
|
||||
|
||||
assert_result!(d.result, result, msg);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_config_builder_from_string() {
|
||||
let config = AgentConfig::from_str(
|
||||
|
@ -196,8 +196,8 @@ async fn real_main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
ttrpc_log_guard = Ok(slog_stdlog::init().map_err(|e| e)?);
|
||||
}
|
||||
|
||||
if config.tracing != tracer::TraceType::Disabled {
|
||||
let _ = tracer::setup_tracing(NAME, &logger, &config)?;
|
||||
if config.tracing {
|
||||
tracer::setup_tracing(NAME, &logger)?;
|
||||
}
|
||||
|
||||
let root_span = span!(tracing::Level::TRACE, "root-span");
|
||||
@ -239,7 +239,7 @@ async fn real_main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
drop(span_guard);
|
||||
drop(root_span);
|
||||
|
||||
if config.tracing != tracer::TraceType::Disabled {
|
||||
if config.tracing {
|
||||
tracer::end_tracing();
|
||||
}
|
||||
|
||||
|
@ -3,61 +3,17 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use crate::config::AgentConfig;
|
||||
use anyhow::Result;
|
||||
use opentelemetry::sdk::propagation::TraceContextPropagator;
|
||||
use opentelemetry::{global, sdk::trace::Config, trace::TracerProvider};
|
||||
use serde::Deserialize;
|
||||
use slog::{info, o, Logger};
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use tracing_opentelemetry::OpenTelemetryLayer;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::Registry;
|
||||
use ttrpc::r#async::TtrpcContext;
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq)]
|
||||
pub enum TraceType {
|
||||
Disabled,
|
||||
Isolated,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TraceTypeError {
|
||||
details: String,
|
||||
}
|
||||
|
||||
impl TraceTypeError {
|
||||
fn new(msg: &str) -> TraceTypeError {
|
||||
TraceTypeError {
|
||||
details: msg.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for TraceTypeError {}
|
||||
|
||||
impl fmt::Display for TraceTypeError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.details)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for TraceType {
|
||||
type Err = TraceTypeError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"isolated" => Ok(TraceType::Isolated),
|
||||
"disabled" => Ok(TraceType::Disabled),
|
||||
_ => Err(TraceTypeError::new("invalid trace type")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup_tracing(name: &'static str, logger: &Logger, _agent_cfg: &AgentConfig) -> Result<()> {
|
||||
pub fn setup_tracing(name: &'static str, logger: &Logger) -> Result<()> {
|
||||
let logger = logger.new(o!("subsystem" => "vsock-tracer"));
|
||||
|
||||
let exporter = vsock_exporter::Exporter::builder()
|
||||
|
@ -117,10 +117,8 @@ type HypervisorInfo struct {
|
||||
|
||||
// AgentInfo stores agent details
|
||||
type AgentInfo struct {
|
||||
TraceMode string
|
||||
TraceType string
|
||||
Debug bool
|
||||
Trace bool
|
||||
Debug bool
|
||||
Trace bool
|
||||
}
|
||||
|
||||
// DistroInfo stores host operating system distribution details.
|
||||
@ -157,11 +155,11 @@ type EnvInfo struct {
|
||||
Meta MetaInfo
|
||||
Image ImageInfo
|
||||
Initrd InitrdInfo
|
||||
Agent AgentInfo
|
||||
Hypervisor HypervisorInfo
|
||||
Netmon NetmonInfo
|
||||
Runtime RuntimeInfo
|
||||
Netmon NetmonInfo
|
||||
Host HostInfo
|
||||
Agent AgentInfo
|
||||
}
|
||||
|
||||
func getMetaInfo() MetaInfo {
|
||||
@ -303,8 +301,6 @@ func getAgentInfo(config oci.RuntimeConfig) (AgentInfo, error) {
|
||||
agentConfig := config.AgentConfig
|
||||
agent.Debug = agentConfig.Debug
|
||||
agent.Trace = agentConfig.Trace
|
||||
agent.TraceMode = agentConfig.TraceMode
|
||||
agent.TraceType = agentConfig.TraceType
|
||||
|
||||
return agent, nil
|
||||
}
|
||||
|
@ -184,10 +184,6 @@ func getExpectedAgentDetails(config oci.RuntimeConfig) (AgentInfo, error) {
|
||||
return AgentInfo{
|
||||
Debug: agentConfig.Debug,
|
||||
Trace: agentConfig.Trace,
|
||||
|
||||
// No trace mode/type set by default
|
||||
TraceMode: "",
|
||||
TraceType: "",
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -677,14 +673,10 @@ func TestEnvGetAgentInfo(t *testing.T) {
|
||||
assert.True(t, agent.Debug)
|
||||
|
||||
agentConfig.Trace = true
|
||||
agentConfig.TraceMode = "traceMode"
|
||||
agentConfig.TraceType = "traceType"
|
||||
config.AgentConfig = agentConfig
|
||||
agent, err = getAgentInfo(config)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, agent.Trace)
|
||||
assert.Equal(t, agent.TraceMode, "traceMode")
|
||||
assert.Equal(t, agent.TraceType, "traceType")
|
||||
}
|
||||
|
||||
func testEnvShowTOMLSettings(t *testing.T, tmpdir string, tmpfile *os.File) error {
|
||||
|
@ -124,24 +124,17 @@ block_device_driver = "@DEFBLOCKSTORAGEDRIVER_ACRN@"
|
||||
|
||||
# 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.
|
||||
# If enabled, the agent will generate OpenTelemetry trace spans.
|
||||
#
|
||||
# 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.
|
||||
# - If the runtime also has tracing enabled, the agent spans will be
|
||||
# associated with the appropriate runtime parent span.
|
||||
# - If enabled, the runtime will wait for the container to shutdown,
|
||||
# increasing the container shutdown time slightly.
|
||||
#
|
||||
# (default: disabled)
|
||||
#enable_tracing = true
|
||||
#
|
||||
#trace_mode = "dynamic"
|
||||
#trace_type = "isolated"
|
||||
|
||||
# Enable debug console.
|
||||
|
||||
|
@ -144,24 +144,17 @@ block_device_driver = "virtio-blk"
|
||||
|
||||
# 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.
|
||||
# If enabled, the agent will generate OpenTelemetry trace spans.
|
||||
#
|
||||
# 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.
|
||||
# - If the runtime also has tracing enabled, the agent spans will be
|
||||
# associated with the appropriate runtime parent span.
|
||||
# - If enabled, the runtime will wait for the container to shutdown,
|
||||
# increasing the container shutdown time slightly.
|
||||
#
|
||||
# (default: disabled)
|
||||
#enable_tracing = true
|
||||
#
|
||||
#trace_mode = "dynamic"
|
||||
#trace_type = "isolated"
|
||||
|
||||
# Enable debug console.
|
||||
|
||||
|
@ -246,24 +246,17 @@ valid_entropy_sources = @DEFVALIDENTROPYSOURCES@
|
||||
|
||||
# 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.
|
||||
# If enabled, the agent will generate OpenTelemetry trace spans.
|
||||
#
|
||||
# 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.
|
||||
# - If the runtime also has tracing enabled, the agent spans will be
|
||||
# associated with the appropriate runtime parent span.
|
||||
# - If enabled, the runtime will wait for the container to shutdown,
|
||||
# increasing the container shutdown time slightly.
|
||||
#
|
||||
# (default: disabled)
|
||||
#enable_tracing = true
|
||||
#
|
||||
#trace_mode = "dynamic"
|
||||
#trace_type = "isolated"
|
||||
|
||||
# Comma separated list of kernel modules and their parameters.
|
||||
# These modules will be loaded in the guest kernel using modprobe(8).
|
||||
|
@ -422,24 +422,17 @@ valid_entropy_sources = @DEFVALIDENTROPYSOURCES@
|
||||
|
||||
# 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.
|
||||
# If enabled, the agent will generate OpenTelemetry trace spans.
|
||||
#
|
||||
# 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.
|
||||
# - If the runtime also has tracing enabled, the agent spans will be
|
||||
# associated with the appropriate runtime parent span.
|
||||
# - If enabled, the runtime will wait for the container to shutdown,
|
||||
# increasing the container shutdown time slightly.
|
||||
#
|
||||
# (default: disabled)
|
||||
#enable_tracing = true
|
||||
#
|
||||
#trace_mode = "dynamic"
|
||||
#trace_type = "isolated"
|
||||
|
||||
# Comma separated list of kernel modules and their parameters.
|
||||
# These modules will be loaded in the guest kernel using modprobe(8).
|
||||
|
@ -23,8 +23,6 @@ type RuntimeConfigOptions struct {
|
||||
NetmonPath string
|
||||
LogPath string
|
||||
BlockDeviceDriver string
|
||||
AgentTraceMode string
|
||||
AgentTraceType string
|
||||
SharedFS string
|
||||
VirtioFSDaemon string
|
||||
JaegerEndpoint string
|
||||
@ -137,8 +135,6 @@ func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string {
|
||||
[agent.kata]
|
||||
enable_debug = ` + strconv.FormatBool(config.AgentDebug) + `
|
||||
enable_tracing = ` + strconv.FormatBool(config.AgentTrace) + `
|
||||
trace_mode = "` + config.AgentTraceMode + `"` + `
|
||||
trace_type = "` + config.AgentTraceType + `"` + `
|
||||
|
||||
[netmon]
|
||||
path = "` + config.NetmonPath + `"
|
||||
|
@ -153,8 +153,6 @@ type runtime struct {
|
||||
}
|
||||
|
||||
type agent struct {
|
||||
TraceMode string `toml:"trace_mode"`
|
||||
TraceType string `toml:"trace_type"`
|
||||
KernelModules []string `toml:"kernel_modules"`
|
||||
Debug bool `toml:"enable_debug"`
|
||||
Tracing bool `toml:"enable_tracing"`
|
||||
@ -489,14 +487,6 @@ func (a agent) trace() bool {
|
||||
return a.Tracing
|
||||
}
|
||||
|
||||
func (a agent) traceMode() string {
|
||||
return a.TraceMode
|
||||
}
|
||||
|
||||
func (a agent) traceType() string {
|
||||
return a.TraceType
|
||||
}
|
||||
|
||||
func (a agent) kernelModules() []string {
|
||||
return a.KernelModules
|
||||
}
|
||||
@ -929,8 +919,6 @@ func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oc
|
||||
LongLiveConn: true,
|
||||
Debug: agent.debug(),
|
||||
Trace: agent.trace(),
|
||||
TraceMode: agent.traceMode(),
|
||||
TraceType: agent.traceType(),
|
||||
KernelModules: agent.kernelModules(),
|
||||
EnableDebugConsole: agent.debugConsoleEnabled(),
|
||||
DialTimeout: agent.dialTimout(),
|
||||
@ -976,10 +964,6 @@ func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {
|
||||
}
|
||||
|
||||
// next, check for agent specific kernel params
|
||||
err := vc.KataAgentSetDefaultTraceConfigOptions(&runtimeConfig.AgentConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params := vc.KataAgentKernelParams(runtimeConfig.AgentConfig)
|
||||
|
||||
|
@ -1152,9 +1152,6 @@ func TestAgentDefaults(t *testing.T) {
|
||||
|
||||
a.Tracing = true
|
||||
assert.Equal(a.trace(), a.Tracing)
|
||||
|
||||
assert.Equal(a.traceMode(), a.TraceMode)
|
||||
assert.Equal(a.traceType(), a.TraceType)
|
||||
}
|
||||
|
||||
func TestGetDefaultConfigFilePaths(t *testing.T) {
|
||||
|
@ -105,16 +105,6 @@ var (
|
||||
GuestDNSFile = "/etc/resolv.conf"
|
||||
)
|
||||
|
||||
const (
|
||||
agentTraceModeDynamic = "dynamic"
|
||||
agentTraceModeStatic = "static"
|
||||
agentTraceTypeIsolated = "isolated"
|
||||
agentTraceTypeCollated = "collated"
|
||||
|
||||
defaultAgentTraceMode = agentTraceModeDynamic
|
||||
defaultAgentTraceType = agentTraceTypeIsolated
|
||||
)
|
||||
|
||||
const (
|
||||
grpcCheckRequest = "grpc.CheckRequest"
|
||||
grpcExecProcessRequest = "grpc.ExecProcessRequest"
|
||||
@ -221,8 +211,6 @@ func ephemeralPath() string {
|
||||
// KataAgentConfig is a structure storing information needed
|
||||
// to reach the Kata Containers agent.
|
||||
type KataAgentConfig struct {
|
||||
TraceMode string
|
||||
TraceType string
|
||||
KernelModules []string
|
||||
ContainerPipeSize uint32
|
||||
DialTimeout uint32
|
||||
@ -268,34 +256,6 @@ func (k *kataAgent) longLiveConn() bool {
|
||||
return k.keepConn
|
||||
}
|
||||
|
||||
// KataAgentSetDefaultTraceConfigOptions validates agent trace options and
|
||||
// sets defaults.
|
||||
func KataAgentSetDefaultTraceConfigOptions(config *KataAgentConfig) error {
|
||||
if !config.Trace {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch config.TraceMode {
|
||||
case agentTraceModeDynamic:
|
||||
case agentTraceModeStatic:
|
||||
case "":
|
||||
config.TraceMode = defaultAgentTraceMode
|
||||
default:
|
||||
return fmt.Errorf("invalid kata agent trace mode: %q (need %q or %q)", config.TraceMode, agentTraceModeDynamic, agentTraceModeStatic)
|
||||
}
|
||||
|
||||
switch config.TraceType {
|
||||
case agentTraceTypeIsolated:
|
||||
case agentTraceTypeCollated:
|
||||
case "":
|
||||
config.TraceType = defaultAgentTraceType
|
||||
default:
|
||||
return fmt.Errorf("invalid kata agent trace type: %q (need %q or %q)", config.TraceType, agentTraceTypeIsolated, agentTraceTypeCollated)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// KataAgentKernelParams returns a list of Kata Agent specific kernel
|
||||
// parameters.
|
||||
func KataAgentKernelParams(config KataAgentConfig) []Param {
|
||||
@ -305,8 +265,8 @@ func KataAgentKernelParams(config KataAgentConfig) []Param {
|
||||
params = append(params, Param{Key: "agent.log", Value: "debug"})
|
||||
}
|
||||
|
||||
if config.Trace && config.TraceMode == agentTraceModeStatic {
|
||||
params = append(params, Param{Key: "agent.trace", Value: config.TraceType})
|
||||
if config.Trace {
|
||||
params = append(params, Param{Key: "agent.trace", Value: "true"})
|
||||
}
|
||||
|
||||
if config.ContainerPipeSize > 0 {
|
||||
@ -323,17 +283,14 @@ func KataAgentKernelParams(config KataAgentConfig) []Param {
|
||||
}
|
||||
|
||||
func (k *kataAgent) handleTraceSettings(config KataAgentConfig) bool {
|
||||
if !config.Trace {
|
||||
return false
|
||||
}
|
||||
|
||||
disableVMShutdown := false
|
||||
|
||||
switch config.TraceMode {
|
||||
case agentTraceModeStatic:
|
||||
if config.Trace {
|
||||
// Agent tracing requires that the agent be able to shutdown
|
||||
// cleanly. This is the only scenario where the agent is
|
||||
// responsible for stopping the VM: normally this is handled
|
||||
// by the runtime.
|
||||
disableVMShutdown = true
|
||||
case agentTraceModeDynamic:
|
||||
k.dynamicTracing = true
|
||||
}
|
||||
|
||||
return disableVMShutdown
|
||||
|
@ -997,75 +997,43 @@ func TestKataAgentKernelParams(t *testing.T) {
|
||||
debug bool
|
||||
trace bool
|
||||
containerPipeSize uint32
|
||||
traceMode string
|
||||
traceType string
|
||||
expectedParams []Param
|
||||
}
|
||||
|
||||
debugParam := Param{Key: "agent.log", Value: "debug"}
|
||||
|
||||
traceIsolatedParam := Param{Key: "agent.trace", Value: "isolated"}
|
||||
traceCollatedParam := Param{Key: "agent.trace", Value: "collated"}
|
||||
|
||||
traceFooParam := Param{Key: "agent.trace", Value: "foo"}
|
||||
traceParam := Param{Key: "agent.trace", Value: "true"}
|
||||
|
||||
containerPipeSizeParam := Param{Key: vcAnnotations.ContainerPipeSizeKernelParam, Value: "2097152"}
|
||||
|
||||
data := []testData{
|
||||
{false, false, 0, "", "", []Param{}},
|
||||
{true, false, 0, "", "", []Param{debugParam}},
|
||||
{false, false, 0, []Param{}},
|
||||
|
||||
{false, false, 0, "foo", "", []Param{}},
|
||||
{false, false, 0, "foo", "", []Param{}},
|
||||
{false, false, 0, "", "foo", []Param{}},
|
||||
{false, false, 0, "", "foo", []Param{}},
|
||||
{false, false, 0, "foo", "foo", []Param{}},
|
||||
{false, true, 0, "foo", "foo", []Param{}},
|
||||
// Debug
|
||||
{true, false, 0, []Param{debugParam}},
|
||||
|
||||
{false, false, 0, agentTraceModeDynamic, "", []Param{}},
|
||||
{false, false, 0, agentTraceModeStatic, "", []Param{}},
|
||||
{false, false, 0, "", agentTraceTypeIsolated, []Param{}},
|
||||
{false, false, 0, "", agentTraceTypeCollated, []Param{}},
|
||||
{false, false, 0, "foo", agentTraceTypeIsolated, []Param{}},
|
||||
{false, false, 0, "foo", agentTraceTypeCollated, []Param{}},
|
||||
// Tracing
|
||||
{false, true, 0, []Param{traceParam}},
|
||||
|
||||
{false, false, 0, agentTraceModeDynamic, agentTraceTypeIsolated, []Param{}},
|
||||
{false, false, 0, agentTraceModeDynamic, agentTraceTypeCollated, []Param{}},
|
||||
// Debug + Tracing
|
||||
{true, true, 0, []Param{debugParam, traceParam}},
|
||||
|
||||
{false, false, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{}},
|
||||
{false, false, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{}},
|
||||
// pipesize
|
||||
{false, false, 2097152, []Param{containerPipeSizeParam}},
|
||||
|
||||
{false, true, 0, agentTraceModeDynamic, agentTraceTypeIsolated, []Param{}},
|
||||
{false, true, 0, agentTraceModeDynamic, agentTraceTypeCollated, []Param{}},
|
||||
{true, true, 0, agentTraceModeDynamic, agentTraceTypeCollated, []Param{debugParam}},
|
||||
// Debug + pipesize
|
||||
{true, false, 2097152, []Param{debugParam, containerPipeSizeParam}},
|
||||
|
||||
{false, true, 0, "", agentTraceTypeIsolated, []Param{}},
|
||||
{false, true, 0, "", agentTraceTypeCollated, []Param{}},
|
||||
{true, true, 0, "", agentTraceTypeIsolated, []Param{debugParam}},
|
||||
{true, true, 0, "", agentTraceTypeCollated, []Param{debugParam}},
|
||||
{false, true, 0, "foo", agentTraceTypeIsolated, []Param{}},
|
||||
{false, true, 0, "foo", agentTraceTypeCollated, []Param{}},
|
||||
{true, true, 0, "foo", agentTraceTypeIsolated, []Param{debugParam}},
|
||||
{true, true, 0, "foo", agentTraceTypeCollated, []Param{debugParam}},
|
||||
// Tracing + pipesize
|
||||
{false, true, 2097152, []Param{traceParam, containerPipeSizeParam}},
|
||||
|
||||
{false, true, 0, agentTraceModeStatic, agentTraceTypeIsolated, []Param{traceIsolatedParam}},
|
||||
{false, true, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{traceCollatedParam}},
|
||||
{true, true, 0, agentTraceModeStatic, agentTraceTypeIsolated, []Param{traceIsolatedParam, debugParam}},
|
||||
{true, true, 0, agentTraceModeStatic, agentTraceTypeCollated, []Param{traceCollatedParam, debugParam}},
|
||||
|
||||
{false, true, 0, agentTraceModeStatic, "foo", []Param{traceFooParam}},
|
||||
{true, true, 0, agentTraceModeStatic, "foo", []Param{debugParam, traceFooParam}},
|
||||
|
||||
{false, false, 0, "", "", []Param{}},
|
||||
{false, false, 2097152, "", "", []Param{containerPipeSizeParam}},
|
||||
// Debug + Tracing + pipesize
|
||||
{true, true, 2097152, []Param{debugParam, traceParam, containerPipeSizeParam}},
|
||||
}
|
||||
|
||||
for i, d := range data {
|
||||
config := KataAgentConfig{
|
||||
Debug: d.debug,
|
||||
Trace: d.trace,
|
||||
TraceMode: d.traceMode,
|
||||
TraceType: d.traceType,
|
||||
ContainerPipeSize: d.containerPipeSize,
|
||||
}
|
||||
|
||||
@ -1090,25 +1058,20 @@ func TestKataAgentHandleTraceSettings(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
type testData struct {
|
||||
traceMode string
|
||||
trace bool
|
||||
expectDisableVMShutdown bool
|
||||
expectDynamicTracing bool
|
||||
}
|
||||
|
||||
data := []testData{
|
||||
{"", false, false, false},
|
||||
{"", true, false, false},
|
||||
{agentTraceModeStatic, true, true, false},
|
||||
{agentTraceModeDynamic, true, false, true},
|
||||
{false, false},
|
||||
{true, true},
|
||||
}
|
||||
|
||||
for i, d := range data {
|
||||
k := &kataAgent{}
|
||||
|
||||
config := KataAgentConfig{
|
||||
Trace: d.trace,
|
||||
TraceMode: d.traceMode,
|
||||
Trace: d.trace,
|
||||
}
|
||||
|
||||
disableVMShutdown := k.handleTraceSettings(config)
|
||||
@ -1118,78 +1081,6 @@ func TestKataAgentHandleTraceSettings(t *testing.T) {
|
||||
} else {
|
||||
assert.Falsef(disableVMShutdown, "test %d (%+v)", i, d)
|
||||
}
|
||||
|
||||
if d.expectDynamicTracing {
|
||||
assert.Truef(k.dynamicTracing, "test %d (%+v)", i, d)
|
||||
} else {
|
||||
assert.Falsef(k.dynamicTracing, "test %d (%+v)", i, d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestKataAgentSetDefaultTraceConfigOptions(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
type testData struct {
|
||||
traceMode string
|
||||
traceType string
|
||||
trace bool
|
||||
expectDefaultTraceMode bool
|
||||
expectDefaultTraceType bool
|
||||
expectError bool
|
||||
}
|
||||
|
||||
data := []testData{
|
||||
{"", "", false, false, false, false},
|
||||
{agentTraceModeDynamic, agentTraceTypeCollated, false, false, false, false},
|
||||
{agentTraceModeDynamic, agentTraceTypeIsolated, false, false, false, false},
|
||||
{agentTraceModeStatic, agentTraceTypeCollated, false, false, false, false},
|
||||
{agentTraceModeStatic, agentTraceTypeIsolated, false, false, false, false},
|
||||
|
||||
{agentTraceModeDynamic, agentTraceTypeCollated, true, false, false, false},
|
||||
{agentTraceModeDynamic, agentTraceTypeIsolated, true, false, false, false},
|
||||
|
||||
{agentTraceModeStatic, agentTraceTypeCollated, true, false, false, false},
|
||||
{agentTraceModeStatic, agentTraceTypeIsolated, true, false, false, false},
|
||||
|
||||
{agentTraceModeDynamic, "", true, false, true, false},
|
||||
{agentTraceModeDynamic, "invalid", true, false, false, true},
|
||||
|
||||
{agentTraceModeStatic, "", true, false, true, false},
|
||||
{agentTraceModeStatic, "invalid", true, false, false, true},
|
||||
|
||||
{"", agentTraceTypeIsolated, true, true, false, false},
|
||||
{"invalid", agentTraceTypeIsolated, true, false, false, true},
|
||||
|
||||
{"", agentTraceTypeCollated, true, true, false, false},
|
||||
{"invalid", agentTraceTypeCollated, true, false, false, true},
|
||||
|
||||
{"", "", true, true, true, false},
|
||||
{"invalid", "invalid", true, false, false, true},
|
||||
}
|
||||
|
||||
for i, d := range data {
|
||||
config := &KataAgentConfig{
|
||||
Trace: d.trace,
|
||||
TraceMode: d.traceMode,
|
||||
TraceType: d.traceType,
|
||||
}
|
||||
|
||||
err := KataAgentSetDefaultTraceConfigOptions(config)
|
||||
if d.expectError {
|
||||
assert.Error(err, "test %d (%+v)", i, d)
|
||||
continue
|
||||
} else {
|
||||
assert.NoError(err, "test %d (%+v)", i, d)
|
||||
}
|
||||
|
||||
if d.expectDefaultTraceMode {
|
||||
assert.Equalf(config.TraceMode, defaultAgentTraceMode, "test %d (%+v)", i, d)
|
||||
}
|
||||
|
||||
if d.expectDefaultTraceType {
|
||||
assert.Equalf(config.TraceType, defaultAgentTraceType, "test %d (%+v)", i, d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,12 +272,6 @@ const (
|
||||
// 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"
|
||||
|
||||
// AgentContainerPipeSize is an annotation to specify the size of the pipes created for containers
|
||||
AgentContainerPipeSize = kataAnnotAgentPrefix + ContainerPipeSizeOption
|
||||
ContainerPipeSizeOption = "container_pipe_size"
|
||||
|
@ -844,14 +844,6 @@ func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error
|
||||
return err
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.AgentTraceMode]; ok {
|
||||
c.TraceMode = value
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.AgentTraceType]; ok {
|
||||
c.TraceType = value
|
||||
}
|
||||
|
||||
if err := newAnnotationConfiguration(ocispec, vcAnnotations.AgentContainerPipeSize).setUint(func(containerPipeSize uint64) {
|
||||
c.ContainerPipeSize = uint32(containerPipeSize)
|
||||
}); err != nil {
|
||||
|
@ -122,8 +122,6 @@ func TestVMConfigGrpc(t *testing.T) {
|
||||
Trace: false,
|
||||
EnableDebugConsole: false,
|
||||
ContainerPipeSize: 0,
|
||||
TraceMode: "",
|
||||
TraceType: "",
|
||||
KernelModules: []string{}},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user