Fix coredns checks
The readiness probe and helm test currently rely on the return code of `dig`, which doesn't fail for NXDOMAIN, which means they are not checking that the names are actually resolved. This moves to using `host` instead which does check this. This also removes the checks for kubernetes etcd domain names, since that doesn't get deployed until after coredns. Change-Id: I0b459f52663c936ed4b8b216614c5b4824a0713f
This commit is contained in:
parent
45968eff4e
commit
6bc3847265
@ -17,12 +17,24 @@ class httpHandler(BaseHTTPRequestHandler):
|
|||||||
failed = False
|
failed = False
|
||||||
res = requests.get("http://127.0.0.1:{}/health".format(args.check_port))
|
res = requests.get("http://127.0.0.1:{}/health".format(args.check_port))
|
||||||
if res.status_code >= 400:
|
if res.status_code >= 400:
|
||||||
|
print('Failed /health check, status code = : {}'.format(res.status_code))
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
|
with open(args.filename, 'r') as fh:
|
||||||
|
for host in fh.read().splitlines():
|
||||||
|
# ignore blank lines
|
||||||
|
if not host:
|
||||||
|
continue
|
||||||
res = subprocess.run(
|
res = subprocess.run(
|
||||||
["dig", "+time=2", "+tries=1", "@127.0.0.1", "-f", args.filename],
|
["host", "-W=2", "-R=1", host, "127.0.0.1"],
|
||||||
stdout=subprocess.DEVNULL)
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
if res.returncode != 0:
|
if res.returncode != 0:
|
||||||
|
print('Failed to resolve host: "{}"'.format(host))
|
||||||
|
print(res.stdout)
|
||||||
failed = True
|
failed = True
|
||||||
|
break
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
print('Check failed')
|
print('Check failed')
|
||||||
self.send_response(500)
|
self.send_response(500)
|
||||||
|
@ -4,5 +4,5 @@ kind: ConfigMap
|
|||||||
metadata:
|
metadata:
|
||||||
name: {{ .Values.service.name }}-list
|
name: {{ .Values.service.name }}-list
|
||||||
data:
|
data:
|
||||||
names_to_resolve: |
|
names_to_resolve: |-
|
||||||
{{ tuple "etc/_list.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
{{ tuple "etc/_list.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
{{- range .Values.conf.test.names_to_resolve }}
|
{{- range .Values.conf.test.names_to_resolve -}}
|
||||||
{{ . }}
|
{{ . }}
|
||||||
{{- end }}
|
{{ end -}}
|
||||||
|
@ -40,16 +40,26 @@ spec:
|
|||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
SUCCESS=1
|
SUCCESS=1
|
||||||
{{- range .Values.conf.test.names_to_resolve }}
|
while read host; do
|
||||||
if dig {{ . }}; then
|
if [ -n "$host" ]; then
|
||||||
echo "Successfully resolved {{ . }}"
|
if host "$host"; then
|
||||||
|
echo "Successfully resolved: \"$host\""
|
||||||
else
|
else
|
||||||
echo "Failed to resolve {{ . }}"
|
echo "Failed to resolve: \"$host\""
|
||||||
SUCCESS=0
|
SUCCESS=0
|
||||||
fi
|
fi
|
||||||
{{- end }}
|
fi
|
||||||
|
done < /tmp/etc/names_to_resolve
|
||||||
if [ "$SUCCESS" != "1" ]; then
|
if [ "$SUCCESS" != "1" ]; then
|
||||||
echo "Test failed to resolve all names."
|
echo "Test failed to resolve all names."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
volumeMounts:
|
||||||
|
- name: dns-names
|
||||||
|
mountPath: /tmp/etc
|
||||||
|
volumes:
|
||||||
|
- name: dns-names
|
||||||
|
configMap:
|
||||||
|
name: {{ $envAll.Values.service.name }}-list
|
||||||
|
defaultMode: 0555
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -563,7 +563,6 @@ data:
|
|||||||
test:
|
test:
|
||||||
names_to_resolve:
|
names_to_resolve:
|
||||||
- calico-etcd.kube-system.svc.cluster.local
|
- calico-etcd.kube-system.svc.cluster.local
|
||||||
- kubernetes-etcd.kube-system.svc.cluster.local
|
|
||||||
- kubernetes.default.svc.cluster.local
|
- kubernetes.default.svc.cluster.local
|
||||||
images:
|
images:
|
||||||
tags:
|
tags:
|
||||||
|
@ -584,7 +584,6 @@ data:
|
|||||||
test:
|
test:
|
||||||
names_to_resolve:
|
names_to_resolve:
|
||||||
- calico-etcd.kube-system.svc.cluster.local
|
- calico-etcd.kube-system.svc.cluster.local
|
||||||
- kubernetes-etcd.kube-system.svc.cluster.local
|
|
||||||
- kubernetes.default.svc.cluster.local
|
- kubernetes.default.svc.cluster.local
|
||||||
|
|
||||||
images:
|
images:
|
||||||
|
@ -438,7 +438,6 @@ data:
|
|||||||
- att.com
|
- att.com
|
||||||
- calico-etcd.kube-system.svc.cluster.local
|
- calico-etcd.kube-system.svc.cluster.local
|
||||||
- google.com
|
- google.com
|
||||||
- kubernetes-etcd.kube-system.svc.cluster.local
|
|
||||||
- kubernetes.default.svc.cluster.local
|
- kubernetes.default.svc.cluster.local
|
||||||
|
|
||||||
images:
|
images:
|
||||||
|
@ -459,7 +459,6 @@ data:
|
|||||||
- att.com
|
- att.com
|
||||||
- calico-etcd.kube-system.svc.cluster.local
|
- calico-etcd.kube-system.svc.cluster.local
|
||||||
- google.com
|
- google.com
|
||||||
- kubernetes-etcd.kube-system.svc.cluster.local
|
|
||||||
- kubernetes.default.svc.cluster.local
|
- kubernetes.default.svc.cluster.local
|
||||||
|
|
||||||
images:
|
images:
|
||||||
|
Loading…
Reference in New Issue
Block a user