Skip to content

Commit

Permalink
Add default for log-tag
Browse files Browse the repository at this point in the history
Needed for containers/podman#10204

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Jun 9, 2021
1 parent 1ba176c commit 2ca5af7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/containers.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ that no size limit is imposed. If it is positive, it must be >= 8192 to
match/exceed conmon's read buffer. The file is truncated and re-opened so the
limit is never exceeded.

**log_tag**=""

Default format tag for container log messages. This is useful for creating a specific tag for container log messages. Container log messages default to using the truncated container ID as a tag.

**netns**="private"

Default way to to create a NET namespace for the container.
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ type ContainersConfig struct {
// Negative values indicate that the log file won't be truncated.
LogSizeMax int64 `toml:"log_size_max,omitempty"`

// Specifies default format tag for container log messages.
// This is useful for creating a specific tag for container log messages.
// Containers logs default to truncated container ID as a tag.
LogTag string `toml:"log_tag,omitempty"`

// NetNS indicates how to create a network namespace for the container
NetNS string `toml:"netns,omitempty"`

Expand Down
3 changes: 3 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ var _ = Describe("Config", func() {
gomega.Expect(err).To(gomega.BeNil())
gomega.Expect(config).ToNot(gomega.BeNil())
gomega.Expect(config.Containers.ApparmorProfile).To(gomega.Equal("overridden-default"))
gomega.Expect(config.Containers.LogDriver).To(gomega.Equal("journald"))
gomega.Expect(config.Containers.LogTag).To(gomega.Equal("{{.Name}}|{{.ID}}"))
gomega.Expect(config.Containers.LogSizeMax).To(gomega.Equal(int64(100000)))
gomega.Expect(config.Engine.ImageParallelCopies).To(gomega.Equal(uint(10)))
gomega.Expect(config.Engine.ImageDefaultFormat).To(gomega.Equal("v2s2"))
})
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/containers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ default_sysctls = [
#
# log_size_max = -1

# Specifies default format tag for container log messages.
# This is useful for creating a specific tag for container log messages.
# messages. Containers logs default to truncated container ID as a tag.
#
# log_tag = ""

# Default way to to create a Network namespace for the container
# Options are:
# `private` Create private Network Namespace for the container.
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/testdata/containers_override.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[containers]

apparmor_profile = "overridden-default"
log_driver = "journald"
log_tag="{{.Name}}|{{.ID}}"
log_size_max = 100000

[engine]
image_parallel_copies=10
Expand Down

0 comments on commit 2ca5af7

Please sign in to comment.