Skip to content

Commit

Permalink
logging: Add sandbox field
Browse files Browse the repository at this point in the history
Read the sandbox ID from the `agent.sandbox=` kernel command-line
option and add a `sandbox=` log field with this value.

This makes the logs more useful as every agent entry is now tied to a
sandboxID.

Fixes kata-containers#291.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Jul 4, 2018
1 parent 7b458b1 commit 04457e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
optionPrefix = "agent."
logLevelFlag = optionPrefix + "log"
devModeFlag = optionPrefix + "devmode"
sandboxFlag = optionPrefix + "sandbox"
kernelCmdlineFile = "/proc/cmdline"
)

Expand Down Expand Up @@ -94,6 +95,8 @@ func (c *agentConfig) parseCmdlineOption(option string) error {
if level == logrus.DebugLevel {
debug = true
}
case sandboxFlag:
agentLog = agentLog.WithField("sandbox", split[valuePosition])
default:
if strings.HasPrefix(split[optionPosition], optionPrefix) {
return grpcStatus.Errorf(codes.NotFound, "Unknown option %s", split[optionPosition])
Expand Down

0 comments on commit 04457e3

Please sign in to comment.