From 384a08f1ee3e52cdfdd207a7f8afb3e39b09f42b Mon Sep 17 00:00:00 2001 From: Moustafa Baiou Date: Fri, 29 Oct 2021 20:47:03 -0400 Subject: [PATCH] fix: host rewrite results in incorrect result for `hostname -f` The issue was with the ordering of the /etc/hosts file which changed in #135 Closes #174 --- pkg/controllers/resources/pods/translate/hosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controllers/resources/pods/translate/hosts.go b/pkg/controllers/resources/pods/translate/hosts.go index b506a0bfc..d22c2fbd8 100644 --- a/pkg/controllers/resources/pods/translate/hosts.go +++ b/pkg/controllers/resources/pods/translate/hosts.go @@ -16,7 +16,7 @@ func rewritePodHostnameFQDN(pPod *corev1.Pod, hostsRewriteImage, fromHost, toHos Name: HostsRewriteContainerName, Image: hostsRewriteImage, Command: []string{"sh"}, - Args: []string{"-c", "sed -E -e 's/^(\\d+.\\d+.\\d+.\\d+\\s+)" + fromHost + "$/\\1 " + toHostname + " " + toHostnameFQDN + "/' /etc/hosts > /hosts/hosts"}, + Args: []string{"-c", "sed -E -e 's/^(\\d+.\\d+.\\d+.\\d+\\s+)" + fromHost + "$/\\1 " + toHostnameFQDN + " " + toHostname + "/' /etc/hosts > /hosts/hosts"}, VolumeMounts: []corev1.VolumeMount{ { MountPath: "/hosts",