diff options
author | baude <bbaude@redhat.com> | 2021-01-19 15:51:01 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2021-01-20 13:07:31 -0600 |
commit | f43046745386d8cd15e010a6ade65619ad12b383 (patch) | |
tree | 6fe2543805da1c05e64daf20ad93779152bdad95 /pkg | |
parent | fe4f9ba303affde0b838e19c862b45206ae2feed (diff) | |
download | podman-f43046745386d8cd15e010a6ade65619ad12b383.tar.gz podman-f43046745386d8cd15e010a6ade65619ad12b383.tar.bz2 podman-f43046745386d8cd15e010a6ade65619ad12b383.zip |
Set log driver for compatability containers
when using the compatibility api to create containers, now reflect the
use of k8s-file as json-file so that clients, which are
unaware of k8s-file, can work. specifically, if the container is using
k8s-file as the log driver, we change the log type in container
inspection to json-file. These terms are used interchangably in other
locations in libpod/podman.
this fixes log messages in compose as well.
[NO TESTS NEEDED]
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/compat/containers.go | 10 | ||||
-rw-r--r-- | pkg/specgen/generate/container.go | 8 |
2 files changed, 18 insertions, 0 deletions
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 |