Skip to content

hubble: Trim FQDN trailing dots in GetNames#12366

Merged
pchaigno merged 2 commits intomasterfrom
pr/gandro/hubble-fix-fqdn-getter
Jul 2, 2020
Merged

hubble: Trim FQDN trailing dots in GetNames#12366
pchaigno merged 2 commits intomasterfrom
pr/gandro/hubble-fix-fqdn-getter

Conversation

@gandro
Copy link
Copy Markdown
Member

@gandro gandro commented Jul 1, 2020

Hubble v0.5 used to display FQDN names without a trailing dot for
absolute paths, i.e. cilium.io instead of cilium.io.

We accidentally changed this in Hubble v0.6 when we started accessing
the Cilium DNS cache directly. This in in turn broke filtering on FQDNs
(--{from-,to-,}fqdn), as the filtering logic does not work with trailing
dots. Output in Hubble UI, Hubble CLI and metrics also are incompatible
with v0.5.

This PR restores the old behavior of stripping trailing dots from
the source and destination name via DNSGetter. A test is added to CI
to ensure we don't regress again.

@gandro gandro added release-note/bug This PR fixes an issue in a previous release of Cilium. kind/regression This functionality worked fine before, but was broken in a newer release of Cilium. needs-backport/1.7 labels Jul 1, 2020
@gandro
Copy link
Copy Markdown
Member Author

gandro commented Jul 1, 2020

test-focus K8sPolicy*

Hubble v0.5 used to display FQDN names without a trailing dot for
absolute paths, i.e. `cilium.io` instead of `cilium.io.`.

We accidentally changed this in Hubble v0.6 when we started accessing
the Cilium DNS cache directly. This in in turn broke filtering on FQDNs
(--{from-,to-,}fqdn), as the filtering logic does not assume trailing
dots, same as Hubble UI, the CLI and metrics.

This commit restores the old behavior of stripping trailing dots from
the source and destination name.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
@gandro gandro force-pushed the pr/gandro/hubble-fix-fqdn-getter branch from 8a5d382 to 7900024 Compare July 1, 2020 17:16
@gandro
Copy link
Copy Markdown
Member Author

gandro commented Jul 1, 2020

test-focus K8sPolicy*

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 1, 2020

Coverage Status

Coverage increased (+0.005%) to 36.914% when pulling 0346ee7 on pr/gandro/hubble-fix-fqdn-getter into 425fbd7 on master.

This performs an additional `hubble observe` invocation when testing
DNS-based policies. We expect Hubble to annotate the `destination_names`
field of the test flows with the observed DNS name exactly as stated
in the test.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
@gandro gandro force-pushed the pr/gandro/hubble-fix-fqdn-getter branch from 7900024 to 0346ee7 Compare July 2, 2020 13:49
@gandro gandro marked this pull request as ready for review July 2, 2020 14:10
@gandro gandro requested a review from a team as a code owner July 2, 2020 14:10
@gandro gandro requested a review from a team July 2, 2020 14:10
@gandro
Copy link
Copy Markdown
Member Author

gandro commented Jul 2, 2020

test-me-please

Copy link
Copy Markdown
Member

@rolinh rolinh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a moment, I wondered about DNS requests to root name servers (dig .) but in this context I think we're fine.
Thanks for the fix and nice catch!

EDIT: this should be labeled for backport to v1.8, not v1.7 right?
EDIT2: fixed

// GetNamesOf fetches FQDNs of a given IP from the perspective of
// the endpoint with ID sourceEpID
// the endpoint with ID sourceEpID. The returned names must not have
// trailing dots.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though the reason is included in the commit, commits are volatile. I think the same reason should be included here since devs are more likely to find this comment than the commit message.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a side note: if this is a requirement, shouldn't a consumer of DNSGetter strip the dot so there is no new getters added without this requirement?

Copy link
Copy Markdown
Member Author

@gandro gandro Jul 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can extend the comment in a follow-up PR. I would like to avoid to restart CI just for this.

on a side note: if this is a requirement, shouldn't a consumer of DNSGetter strip the dot so there is no new getters added without this requirement?

It's part of the interface implementation contract to not return trailing dots. Having to modify each and every call site to clean up the result because it was violating the implementation contract seems weird to me.

@maintainer-s-little-helper maintainer-s-little-helper Bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jul 2, 2020
@pchaigno pchaigno merged commit 00fc18f into master Jul 2, 2020
@pchaigno pchaigno deleted the pr/gandro/hubble-fix-fqdn-getter branch July 2, 2020 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/regression This functionality worked fine before, but was broken in a newer release of Cilium. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants