mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
libpod: Validate that log tag requires journald driver
Currently validation that log tag requires journald driver is done in several places and emits only warning. Making it an error and moving to `(c *Container) validate()` is a more correct approach. Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
@@ -20,7 +20,6 @@ import (
|
||||
"github.com/containers/podman/v6/pkg/signal"
|
||||
"github.com/containers/podman/v6/pkg/specgen"
|
||||
"github.com/openshift/imagebuilder"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.podman.io/common/libimage"
|
||||
"go.podman.io/common/pkg/config"
|
||||
"go.podman.io/image/v5/manifest"
|
||||
@@ -332,16 +331,11 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
|
||||
s.LogConfiguration.Driver = rtc.Containers.LogDriver
|
||||
}
|
||||
if len(rtc.Containers.LogTag) > 0 {
|
||||
if s.LogConfiguration.Driver != define.JSONLogging {
|
||||
if s.LogConfiguration.Options == nil {
|
||||
s.LogConfiguration.Options = make(map[string]string)
|
||||
}
|
||||
|
||||
if _, exists := s.LogConfiguration.Options["tag"]; !exists {
|
||||
s.LogConfiguration.Options["tag"] = rtc.Containers.LogTag
|
||||
}
|
||||
} else {
|
||||
logrus.Warnf("log_tag %q is not allowed with %q log_driver", rtc.Containers.LogTag, define.JSONLogging)
|
||||
if s.LogConfiguration.Options == nil {
|
||||
s.LogConfiguration.Options = make(map[string]string)
|
||||
}
|
||||
if _, exists := s.LogConfiguration.Options["tag"]; !exists {
|
||||
s.LogConfiguration.Options["tag"] = rtc.Containers.LogTag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/docker/docker/pkg/meminfo"
|
||||
"github.com/docker/go-units"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.podman.io/common/libimage"
|
||||
"go.podman.io/common/libnetwork/types"
|
||||
"go.podman.io/common/pkg/config"
|
||||
@@ -265,17 +264,10 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
|
||||
}
|
||||
s.LogConfiguration.Size = logSize
|
||||
default:
|
||||
switch len(val) {
|
||||
case 0:
|
||||
if len(val) == 0 {
|
||||
return nil, fmt.Errorf("invalid log option: %w", define.ErrInvalidArg)
|
||||
default:
|
||||
// tags for journald only
|
||||
if s.LogConfiguration.Driver == "" || s.LogConfiguration.Driver == define.JournaldLogging {
|
||||
s.LogConfiguration.Options[opt] = val
|
||||
} else {
|
||||
logrus.Warnf("Can only set tags with journald log driver but driver is %q", s.LogConfiguration.Driver)
|
||||
}
|
||||
}
|
||||
s.LogConfiguration.Options[opt] = val
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user