-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Describe the rationale for the suggested feature.
Currently the Host DNS analyzere example only shows how to spot wildcard DNS. It does not show how to spot when DNS does or does not resolve.
This is actually a moderately tricky thing to do reliably due to vagaries of jsonCompare
and the k8s json path library.
Describe the feature
Add an example of checking a name that will fail if the name does not resolve and pass if it does, as so:
apiVersion: troubleshoot.sh/v1beta2
kind: HostPreflight
metadata:
name: sample
spec:
collectors:
- dns:
collectorName: valid-check
hostnames:
- example.com
- foo.bar
analyzers:
- jsonCompare:
checkName: Resolves foo.bar
fileName: host-collectors/dns/valid-check/result.json
jsonPath: "{$.query['foo\\.bar'][0].record}"
value: |
""
outcomes:
- fail:
when: 'true'
message: 'Unable to resolve foo.bar'
- pass:
when: 'false'
message: 'Resolved foo.bar'
Additional context
It's surprising that you need to escape the .
in foo.bar
in the jsonPath
expression, because according to the JSONPath specification you should not need to in a string lookup, so it's important to document it here.
A jsonPath
expression that does not match anything in the json document returns an empty string, and if the collector does not resolve the name it sets record
to an empty string, which makes it hard to distinguish between a broken JSONPath and the name not resolving.