From 8f844a66d5d144eeb92870c27171dc8b35788d4f Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 5 Jan 2021 11:48:37 -0500 Subject: Ensure that user-specified HOSTNAME is honored When adding the HOSTNAME environment variable, only do so if it is not already present in the spec. If it is already present, it was likely added by the user, and we should honor their requested value. Fixes #8886 Signed-off-by: Matthew Heon --- pkg/specgen/generate/namespaces.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkg/specgen/generate/namespaces.go') diff --git a/pkg/specgen/generate/namespaces.go b/pkg/specgen/generate/namespaces.go index 036c7b7a1..3cd5a3c9c 100644 --- a/pkg/specgen/generate/namespaces.go +++ b/pkg/specgen/generate/namespaces.go @@ -364,7 +364,9 @@ func specConfigureNamespaces(s *specgen.SpecGenerator, g *generate.Generator, rt // namespaces? g.SetHostname(hostname) } - g.AddProcessEnv("HOSTNAME", hostname) + if _, ok := s.Env["HOSTNAME"]; !ok && s.Hostname != "" { + g.AddProcessEnv("HOSTNAME", hostname) + } // User switch s.UserNS.NSMode { -- cgit v1.2.3-54-g00ecf