Bug 1872080: Avoid a bash "unbound variable" error#192
Bug 1872080: Avoid a bash "unbound variable" error#192openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Conversation
0a887e1 to
a411700
Compare
|
lol wut was the check broken before and always false? Or maybe this is caused by the RHEL 8 migration? |
Under "set -u", if svc_ips is declared-but-empty, then
"${#svc_ips[@]}" results in an "unbound variable" error (which, under
"set -e" causes the script to exit with an error). However,
"${svc_ips[@]}" expands to the empty string, as expected.
|
So yeah, the RHCOS 8 images appear to not have You could do something like: (The cat+pipe is needed because otherwise |
|
Sorry, I know nothing about how rhcos 7 and 8 differ. @jupierce and @yselkowitz are the best candidates for questions around that. |
|
In what container is the script which calls |
|
oh, duh, I'm mixing up RHCOS and UBI... I was thinking we couldn't install extra RPMs by hand but obviously we can |
4530ed8 to
5c7efff
Compare
Looks like |
|
@jupierce should diffutils be explicitly added to base for this? |
yselkowitz
left a comment
There was a problem hiding this comment.
If the script is run in cli, then installing cmp in this operator isn't going to help.
| FROM registry.svc.ci.openshift.org/ocp/4.6:base | ||
|
|
||
| # dns-node-resolver needs "cmp" | ||
| RUN dnf install -y diffutils && dnf clean all |
|
openshift/images#35 should fix this via inheritance. |
yeah, I hadn't realized it was using a different image when I pushed that commit |
|
(I later un-pushed that commit) |
|
/retest |
|
/lgtm |
|
/retitle Bug 1872080: Avoid a bash "unbound variable" error |
|
@danwinship: This pull request references Bugzilla bug 1872080, which is valid. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/assign @ironcladlou |
|
Looks like theres also the possibility of an unbound variable error here: svc_ips is derived from ips.@danwinship mind addressing that statement in this PR as well? |
|
Ah, nevermind, after further reading, the cluster-dns-operator/assets/dns/daemonset.yaml Lines 117 to 119 in 5c7efff /approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danwinship, sgreene570, yselkowitz The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
|
/hold |
Could you elaborate on whats going wrong? |
|
/hold cancel |
|
The logs are still showing |
| # 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 [[ "${#svc_ips[@]}" -ne 0 ]]; then | ||
| if [[ -n "${svc_ips[*]}" ]]; then |
There was a problem hiding this comment.
Why is this necessary? This works for me on RHEL76:
$ echo $BASH_VERSION
4.2.46(2)-release
$ set -u
$ declare -A svc_ips
$ [[ "${#svc_ips[@]}" -ne 0 ]]
$ echo $?
1
$Do we need to report a BZ against RHEL8's Bash?
There was a problem hiding this comment.
I filed BZ#1875566, "Bash says a declared but empty array is unbound".
There was a problem hiding this comment.
The behavior in 4.2 was a bug. It was fixed incorrectly in 4.3 (making both ${#svc_ips[@]} and ${svc_ips[@]} an error) and then fully fixed in 4.4 (making the former an error but the latter not). This has to do with POSIX compliance or something.
There was a problem hiding this comment.
This PR seems to have fixed clusters using the RHEL 8 base, but broke clusters using the prior RHEL 7 base:
eg
sh-4.2# echo $BASH_VERSION
4.2.46(2)-release
sh-4.2# set -u
sh-4.2# declare -A svc_ips
sh-4.2# [[-n "${svc_ips[*]}"]]
sh: svc_ips[*]: unbound variable
There was a problem hiding this comment.
Would [[ -n "${svc_ips[*]-}" ]] work on both Bash 4.2 and 4.4?
There was a problem hiding this comment.
Would
[[ -n "${svc_ips[*]-}" ]]work on both Bash 4.2 and 4.4?
I think so... what exactly does the - change?
There was a problem hiding this comment.
${parameter-default} means to substitute the value of the variable parameter if it is set, or the literal value default (which in our case is the empty string) if parameter is not set.
There was a problem hiding this comment.
Ah, I had tried changing the original ${#svc_ips[@]} to ${#svc_ips[@]:-0}, which does not work.
There was a problem hiding this comment.
#193 changes the test to [[ -n "${svc_ips[*]-}" ]].
|
missing cmp would be indicative of a stale cache, problem has already been fixed in 4.6:base |
|
Failures look unrelated. /retest |
Seen in https://openshift-gce-devel.appspot.com/build/origin-ci-test/logs/periodic-ci-openshift-ovn-kubernetes-master-e2e-metal-ipi-dualstack-periodic/1299134739436802048/. There is some larger failure mode here which is not yet diagnosed, but on the way to figuring that out I saw that the current error-handling code in the
dns-node-resolverpod is not working, resulting in the container crashing with:rather than sleeping and looping