summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-21 13:56:17 -0500
committerGitHub <noreply@github.com>2021-01-21 13:56:17 -0500
commit469c2031fc1529ff81e1d8d9f05099ddca265174 (patch)
tree1fea8ee0e6c20a2be0da81f6f0413d7ce2bd2415
parentac4ccdc3f17d6161b61831af231120748dd46982 (diff)
parent22d2caeeb1acadaced47bbacccec5f597e0d99f4 (diff)
downloadpodman-469c2031fc1529ff81e1d8d9f05099ddca265174.tar.gz
podman-469c2031fc1529ff81e1d8d9f05099ddca265174.tar.bz2
podman-469c2031fc1529ff81e1d8d9f05099ddca265174.zip
Merge pull request #9055 from baude/v3backportcomposelog
[3.0] Set log driver for compatability containers
-rw-r--r--cmd/podman/common/create.go2
-rw-r--r--cmd/podman/common/create_opts.go7
-rw-r--r--cmd/podman/common/specgen.go2
-rw-r--r--pkg/api/handlers/compat/containers.go10
-rw-r--r--pkg/specgen/generate/container.go8
5 files changed, 27 insertions, 2 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index 280175f95..17fba5427 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -402,7 +402,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
logDriverFlagName := "log-driver"
createFlags.StringVar(
&cf.LogDriver,
- logDriverFlagName, "",
+ logDriverFlagName, logDriver(),
"Logging driver for the container",
)
_ = cmd.RegisterFlagCompletionFunc(logDriverFlagName, AutocompleteLogDriver)
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 9635f4135..f252618ce 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -517,3 +517,10 @@ func volumes() []string {
}
return nil
}
+
+func logDriver() string {
+ if !registry.IsRemote() {
+ return containerConfig.Containers.LogDriver
+ }
+ return ""
+}
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 287836d9f..4cc53a630 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -463,7 +463,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
if s.LogConfiguration == nil {
s.LogConfiguration = &specgen.LogConfig{}
}
- s.LogConfiguration.Driver = define.KubernetesLogging
+
if ld := c.LogDriver; len(ld) > 0 {
s.LogConfiguration.Driver = ld
}
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index 6e1945db1..5c5586323 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -326,6 +326,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
state.Running = true
}
+ // docker calls the configured state "created"
+ if state.Status == define.ContainerStateConfigured.String() {
+ state.Status = define.ContainerStateCreated.String()
+ }
+
formatCapabilities(inspect.HostConfig.CapDrop)
formatCapabilities(inspect.HostConfig.CapAdd)
@@ -337,6 +342,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
if err := json.Unmarshal(h, &hc); err != nil {
return nil, err
}
+
+ // k8s-file == json-file
+ if hc.LogConfig.Type == define.KubernetesLogging {
+ hc.LogConfig.Type = define.JSONLogging
+ }
g, err := json.Marshal(inspect.GraphDriver)
if err != nil {
return nil, err
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index 2feb1d3b2..cc3f7928c 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -257,6 +257,14 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
}
}
+ if s.LogConfiguration == nil {
+ s.LogConfiguration = &specgen.LogConfig{}
+ }
+ // set log-driver from common if not already set
+ if len(s.LogConfiguration.Driver) < 1 {
+ s.LogConfiguration.Driver = rtc.Containers.LogDriver
+ }
+
warnings, err := verifyContainerResources(s)
if err != nil {
return warnings, err