Merge pull request #26564 from mheon/fix_rhel_96776

Fix `podman inspect` to correctly handle log_size_max
This commit is contained in:
openshift-merge-bot[bot] authored and GitHub committed 2025-07-04 09:45:33 +00:00
commit 293a2ed3e7
5 files changed
+34 -6

No files matched your search

+8
View File
@@ -669,6 +669,14 @@ func (c *Container) LogTag() string {
return c.config.LogTag
}
// LogSizeMax returns the maximum size of the container's log file.
func (c *Container) LogSizeMax() int64 {
if c.config.LogSize > 0 {
return c.config.LogSize
}
return c.runtime.config.Containers.LogSizeMax
}
// RestartPolicy returns the container's restart policy.
func (c *Container) RestartPolicy() string {
return c.config.RestartPolicy
+1 -1
View File
@@ -378,7 +378,7 @@ type ContainerMiscConfig struct {
LogPath string `json:"logPath"`
// LogTag is the tag used for logging
LogTag string `json:"logTag"`
// LogSize is the tag used for logging
// LogSize is the maximum size of the container's log file
LogSize int64 `json:"logSize"`
// LogDriver driver for logs
LogDriver string `json:"logDriver"`
+1 -1
View File
@@ -498,7 +498,7 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
logConfig := new(define.InspectLogConfig)
logConfig.Type = c.config.LogDriver
logConfig.Path = c.config.LogPath
logConfig.Size = units.HumanSize(float64(c.config.LogSize))
logConfig.Size = units.HumanSize(float64(c.LogSizeMax()))
logConfig.Tag = c.config.LogTag
hostConfig.LogConfig = logConfig
+1 -4
View File
@@ -1342,10 +1342,7 @@ func (r *ConmonOCIRuntime) sharedConmonArgs(ctr *Container, cuuid, bundlePath, p
logrus.Debugf("%s messages will be logged to syslog", r.conmonPath)
args = append(args, "--syslog")
size := r.logSizeMax
if ctr.config.LogSize > 0 {
size = ctr.config.LogSize
}
size := ctr.LogSizeMax()
if size > 0 {
args = append(args, "--log-size-max", strconv.FormatInt(size, 10))
}
+23
View File
@@ -1804,4 +1804,27 @@ RUN umount /etc/hostname; rm /etc/hostname
run_podman rmi $randomname
}
@test "podman run --log-opt size= and containers.conf log_size_max" {
skip_if_remote "remote does not support CONTAINERS_CONF"
containersconf=$PODMAN_TMPDIR/containers.conf
cat >$containersconf <<EOF
[containers]
log_driver = "k8s-file"
log_size_max = 400000000
EOF
c1name=c1_$(safename)
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman create --name $c1name $IMAGE ls /
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman inspect --format '{{ .HostConfig.LogConfig.Size }}' $c1name
is "$output" "400MB"
c2name=c2_$(safename)
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman create --name $c2name --log-opt max-size=8000 $IMAGE ls /
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman inspect --format '{{ .HostConfig.LogConfig.Size }}' $c2name
is "$output" "8kB"
run_podman rm -f $c1name $c2name
}
# vim: filetype=sh