Bug 1876912 - dns-node-resolver fails: svc_ips[*]: unbound variable
Summary: dns-node-resolver fails: svc_ips[*]: unbound variable
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: DNS
Version: 4.6
Hardware: All
OS: Linux
Target Milestone: ---
: 4.6.0
Assignee: Miciah Dashiel Butler Masters
QA Contact: Hongan Li
: 1876928 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2020-09-08 13:49 UTC by Andy McCrae
Modified: 2020-09-14 08:36 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:
Target Upstream Version:

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Github openshift cluster-dns-operator pull 193 None closed Bug 1876912: Fix "unbound variable" error on Bash 4.2 2020-09-22 12:19:45 UTC

Description Andy McCrae 2020-09-08 13:49:56 UTC
Description of problem:

Since https://github.com/openshift/cluster-dns-operator/commit/6b4360e49537e2a1667165b730746db642b32751 the dns-node-resolver fails to start in 4.6 with the following error:

/bin/bash: line 38: svc_ips[*]: unbound variable

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Deploy Openshift 
2. Wait for dns-default pod to CrashLoopBackOff
3. Check pod definition

Actual results:

dns-node-resolver doesn't start with the above error.

Expected results:

dns-node-resolver starts normally.

Additional info:

This is related to https://bugzilla.redhat.com/show_bug.cgi?id=1872080 in that the change made to the svc_ips approach is compatible with newer bash versions included in Rhel8+, but not compatible with the older bash in Rhel 7.

For e.g. on Rhel 8.2 /w bash 4.4.19(1):

# bash -c 'set -u; declare -a ary; echo "${#ary[@]}"'
bash: ary: unbound variable
# bash -c 'set -u; declare -A ary; echo "${ary[*]}"'
# echo $?

On Rhel 7.6 /w bash 4.2.46(2):
# bash -c 'set -u; declare -a ary; echo "${#ary[@]}"'
# bash -c 'set -u; declare -A ary; echo "${ary[*]}"'
bash: ary[*]: unbound variable

https://bugzilla.redhat.com/show_bug.cgi?id=1875566 is filed to deal with the initial case in bash itself.

Comment 1 Stephen Greene 2020-09-08 17:39:39 UTC
*** Bug 1876928 has been marked as a duplicate of this bug. ***

Comment 4 Hongan Li 2020-09-14 08:36:26 UTC
verified with 4.6.0-0.nightly-2020-09-12-230035 and dns pods work well. 

# oc -n openshift-dns get ds/dns-default -oyaml
            # Update /etc/hosts only if we get valid service IPs
            # We will not update /etc/hosts when there is coredns service outage or api unavailability
            # Stale entries could exist in /etc/hosts if the service is deleted
            if [[ -n "${svc_ips[*]-}" ]]; then
              # Build a new hosts file from /etc/hosts with our custom entries filtered out

# oc -n openshift-dns get pod
NAME                READY   STATUS    RESTARTS   AGE
dns-default-4p4dl   3/3     Running   0          7h46m
dns-default-7wgpb   3/3     Running   0          7h46m
dns-default-9fccl   3/3     Running   0          7h55m
dns-default-gqjxc   3/3     Running   0          7h55m
dns-default-kk9h5   3/3     Running   0          7h46m
dns-default-l2nr8   3/3     Running   0          7h55m

Note You need to log in before you can comment on or make changes to this bug.