Skip to content

Commit

Permalink
Detect default hostname in its variants
Browse files Browse the repository at this point in the history
On some environments, `hostname` returns localhost whereas on others it
returns `localhost.localdomain`. This commit ensures that we'll catch
both.

It also increases verbosity of initcontainers to ease debugging of
similar issues in the future.

Signed-off-by: Antoni Segura Puimedon <antoni@redhat.com>
  • Loading branch information
celebdor authored and openshift-cherrypick-robot committed Mar 5, 2020
1 parent b318921 commit a556c2e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions templates/common/baremetal/files/baremetal-mdns-publisher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ contents:
- name: verify-hostname
image: {{ .Images.baremetalRuntimeCfgImage }}
env:
- name: DEFAULT_LOCAL_HOSTNAME
value: "localhost"
- name: RUNTIMECFG_HOSTNAME_PATH
value: "/etc/mdns/hostname"
command:
- "/bin/bash"
- "-c"
- |
#/bin/bash
#!/bin/bash
set -xv
function get_hostname()
{
if [[ -s $RUNTIMECFG_HOSTNAME_PATH ]]; then
Expand All @@ -45,9 +44,8 @@ contents:
hostname
fi
}
while [ "$(get_hostname)" == "$DEFAULT_LOCAL_HOSTNAME" ]
do
echo "hostname is still ${DEFAULT_LOCAL_HOSTNAME}"
while [[ "$(get_hostname)" =~ ^localhost(.localdomain)?$ ]]; do
echo "hostname is still set to a default value"
sleep 1
done
volumeMounts:
Expand All @@ -71,6 +69,7 @@ contents:
- "/config"
- "--out-dir"
- "/etc/mdns"
- "--verbose"
resources: {}
volumeMounts:
- name: kubeconfig
Expand Down

0 comments on commit a556c2e

Please sign in to comment.