summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-05-09 04:48:49 -0400
committerGitHub <noreply@github.com>2022-05-09 04:48:49 -0400
commitccb6211c7beff29ba0d0d374665e1b24262c276f (patch)
tree740b480f8610df79055a2b18ca077aaa1bbfa7ac /pkg
parenta0ecb8675d1c45f083a70a6b3faaebd22abe5417 (diff)
parentb58e7e7f11f99b22d68cbbf28c8d52ff10be482e (diff)
downloadpodman-ccb6211c7beff29ba0d0d374665e1b24262c276f.tar.gz
podman-ccb6211c7beff29ba0d0d374665e1b24262c276f.tar.bz2
podman-ccb6211c7beff29ba0d0d374665e1b24262c276f.zip
Merge pull request #14121 from cdoern/kube
play kube log tag handling
Diffstat (limited to 'pkg')
-rw-r--r--pkg/specgen/generate/container_create.go1
-rw-r--r--pkg/specgen/generate/kube/kube.go14
2 files changed, 13 insertions, 2 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index 19a2b702c..04e24d625 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -425,7 +425,6 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l
options = append(options, libpod.WithMaxLogSize(s.LogConfiguration.Size))
}
if len(s.LogConfiguration.Options) > 0 && s.LogConfiguration.Options["tag"] != "" {
- // Note: I'm really guessing here.
options = append(options, libpod.WithLogTag(s.LogConfiguration.Options["tag"]))
}
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go
index 4c11e4bff..d56b50fd5 100644
--- a/pkg/specgen/generate/kube/kube.go
+++ b/pkg/specgen/generate/kube/kube.go
@@ -29,6 +29,7 @@ import (
"github.com/docker/go-units"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
)
func ToPodOpt(ctx context.Context, podName string, p entities.PodCreateOptions, podYAML *v1.PodTemplateSpec) (entities.PodCreateOptions, error) {
@@ -153,6 +154,7 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
Driver: opts.LogDriver,
}
+ s.LogConfiguration.Options = make(map[string]string)
for _, o := range opts.LogOptions {
split := strings.SplitN(o, "=", 2)
if len(split) < 2 {
@@ -170,7 +172,17 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
}
s.LogConfiguration.Size = logSize
default:
- s.LogConfiguration.Options[split[0]] = split[1]
+ switch len(split[1]) {
+ case 0:
+ return nil, errors.Wrapf(define.ErrInvalidArg, "invalid log option")
+ default:
+ // tags for journald only
+ if s.LogConfiguration.Driver == "" || s.LogConfiguration.Driver == define.JournaldLogging {
+ s.LogConfiguration.Options[split[0]] = split[1]
+ } else {
+ logrus.Warnf("Can only set tags with journald log driver but driver is %q", s.LogConfiguration.Driver)
+ }
+ }
}
}