diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-27 20:37:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 20:37:03 +0200 |
commit | 733c38028df9d8c0b0688a54ef948a21b6260f26 (patch) | |
tree | ea9d691a33291bc4dc635296283c9f5de3d315a3 /libpod/container_internal_linux.go | |
parent | ccf009d22e45e9a517b65619d6d46a8d40cb3328 (diff) | |
parent | 1803b28d8cae1fd6c5e2ea508911309251a1349a (diff) | |
download | podman-733c38028df9d8c0b0688a54ef948a21b6260f26.tar.gz podman-733c38028df9d8c0b0688a54ef948a21b6260f26.tar.bz2 podman-733c38028df9d8c0b0688a54ef948a21b6260f26.zip |
Merge pull request #5999 from giuseppe/fix-pod-infra-container
v2, podman: fix pod tests
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 38dfa7ab7..8ee0fb456 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -385,6 +385,16 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { g.AddLinuxGIDMapping(uint32(0), uint32(0), uint32(1)) } } + + for _, i := range c.config.Spec.Linux.Namespaces { + if i.Type == spec.UTSNamespace { + hostname := c.Hostname() + g.SetHostname(hostname) + g.AddProcessEnv("HOSTNAME", hostname) + break + } + } + if c.config.UTSNsCtr != "" { if err := c.addNamespaceContainer(&g, UTSNS, c.config.UTSNsCtr, spec.UTSNamespace); err != nil { return nil, err @@ -418,15 +428,6 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { g.AddAnnotation(annotations.ContainerManager, annotations.ContainerManagerLibpod) } - for _, i := range c.config.Spec.Linux.Namespaces { - if i.Type == spec.UTSNamespace { - hostname := c.Hostname() - g.SetHostname(hostname) - g.AddProcessEnv("HOSTNAME", hostname) - break - } - } - // Only add container environment variable if not already present foundContainerEnv := false for _, env := range g.Config.Process.Env { @@ -583,6 +584,12 @@ func (c *Container) addNamespaceContainer(g *generate.Generator, ns LinuxNS, ctr return errors.Wrapf(err, "error retrieving dependency %s of container %s from state", ctr, c.ID()) } + if specNS == spec.UTSNamespace { + hostname := nsCtr.Hostname() + g.SetHostname(hostname) + g.AddProcessEnv("HOSTNAME", hostname) + } + // TODO need unlocked version of this for use in pods nsPath, err := nsCtr.NamespacePath(ns) if err != nil { |