bbox 1.28.4 and nslookup question (sorry)
sonishi85 opened this issue · comments
Sorry for another nslookup question but..I am using bbox 1.28.4 image as a K8s initContainer. Whenever I make a call to nslookup that fails, the container exits before I can check the return code.
initContainers:
...
imagePullPolicy: Always
command:
- sh
- -c
- "set -ex\n
echo Init container running for $(hostname)\n
nslookup kubernetes.default\n
if [[ $? -ne 0 ]]; then\n
echo oops\n
fi\n
nslookup foo.bar\n
if [[ $? -ne 0 ]]; then\n
echo oops\n
fi\n"
The pod ends up in a crash backoff state. The log from the failed init container:
+ hostname
+ echo Init container running 'for' jnpr-ipb-redis-0
+ nslookup kubernetes.default
Init container running for jnpr-ipb-redis-0
Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Name: kubernetes.default
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local
+ '[[' 0 -ne 0 ]]
+ nslookup foo.bar
Server: 10.96.0.10
nslookup: can't resolve 'foo.bar'
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Never executes the next line after nslookup foo.bar. Am I missing something obvious here?
set -e
-e Exit immediately if a command exits with a non-zero status.
Your nslookup foo.bar
is a non-zero exit and so set -e
exits before the if
loop runs
ok, my bad. Forgot I had added that switch and have been staring at this for too long. Thanks @wglambert