Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FQDN policy support for IPv6 #3869

Merged
merged 1 commit into from Jun 13, 2022
Merged

Fix FQDN policy support for IPv6 #3869

merged 1 commit into from Jun 13, 2022

Conversation

tnqn
Copy link
Member

@tnqn tnqn commented Jun 8, 2022

IPv6 address must be wrapped with "[]" when used in network API.

This patch ensures that the auto-discovered and the user-provided DNS
servers use correct format. It also adds the missing configuration
"dnsServerOverride" to the configuration file.

Signed-off-by: Quan Tian qtian@vmware.com

Fixes #3873

@tnqn tnqn added action/backport Indicates a PR that requires backports. action/release-note Indicates a PR that should be included in release notes. area/network-policy Issues or PRs related to network policies. labels Jun 8, 2022
@tnqn
Copy link
Member Author

tnqn commented Jun 8, 2022

/test-ipv6-only-e2e
/test-ipv6-e2e
/test-all

@tnqn tnqn force-pushed the fix-fqdn-ipv6 branch 2 times, most recently from 329caa1 to 47207e5 Compare June 8, 2022 10:50
@tnqn
Copy link
Member Author

tnqn commented Jun 8, 2022

/test-ipv6-only-e2e
/test-ipv6-e2e
/test-all

@tnqn
Copy link
Member Author

tnqn commented Jun 8, 2022

/test-ipv6-only-e2e
/test-ipv6-e2e
/test-e2e

Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

In the commit description:

dns server -> DNS servers

@@ -207,6 +207,11 @@ nodePortLocal:
# Defaults to "". It must be a host string, a host:port pair, or a URL to the base of the apiserver.
kubeAPIServerOverride: {{ .Values.kubeAPIServerOverride | quote }}

# Provide the address of DNS server, to override the kube-dns service. It's used to resolve hostname in FQDN policy.
# Defaults to "". It must be a host string or a host:port pair of the dns server (e.g. 10.96.0.10, 10.96.0.10:53,
Copy link
Contributor

Choose a reason for hiding this comment

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

dns -> DNS

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

jianjuns
jianjuns previously approved these changes Jun 8, 2022
builder := &ClusterNetworkPolicySpecBuilder{}
builder = builder.SetName("test-acnp-fqdn-cluster-svc").
SetTier("application").
SetPriority(1.0)
for idx, service := range services {
builder.AddFQDNRule(svcDNSName(service), ProtocolTCP, nil, nil, nil, fmt.Sprintf("r%d", idx*2), []ACNPAppliedToSpec{{NSSelector: map[string]string{"ns": namespaces["y"]}, PodSelector: map[string]string{"pod": "b"}}}, crdv1alpha1.RuleActionReject)
builder.AddFQDNRule(svcDNSName(service), ProtocolTCP, nil, nil, nil, fmt.Sprintf("r%d", idx*2+1), []ACNPAppliedToSpec{{NSSelector: map[string]string{"ns": namespaces["z"]}, PodSelector: map[string]string{"pod": "c"}}}, crdv1alpha1.RuleActionDrop)
builder.AddFQDNRule(svcFQDN(service), ProtocolTCP, nil, nil, nil, fmt.Sprintf("r%d", idx*2), []ACNPAppliedToSpec{{NSSelector: map[string]string{"ns": namespaces["y"]}, PodSelector: map[string]string{"pod": "b"}}}, crdv1alpha1.RuleActionReject)
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on your comment above, should we use svcDNSName here?

Copy link
Member Author

@tnqn tnqn Jun 9, 2022

Choose a reason for hiding this comment

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

We expect the string set in the rule to be FQDN, not short names, right? otherwise it should be written with wildcard. The dns go library doesn't append the domains in the search list like what the system resolver does, using short name here would get no resolution result.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you mean now. If that's the case why do we need the svcDNSName function then?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's used in podToAddrTestStep as the server address. As the function comment explains, if we use FQDN as the server address, the client would first try FQDN.<namespace>.svc.cluster.local, then FQDN.svc.cluster.local, then FQDN.cluster.local, last FQDN, likely exceeding the timeout.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Thanks for the explanation. Maybe worth adding to the comment in the podToAddrTestStep below that each client Pod's /etc/resolve.conf will append svc.cluster.local as first dns resolution trial, just for laymans like me to understand this better when we look back at the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

used another way to avoid unnecessary resolution attemps, and add comment to explain it, PTAL

@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2022

Codecov Report

Merging #3869 (822caa0) into main (4e60600) will decrease coverage by 10.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #3869       +/-   ##
===========================================
- Coverage   64.42%   54.22%   -10.20%     
===========================================
  Files         291      407      +116     
  Lines       42745    58804    +16059     
===========================================
+ Hits        27539    31888     +4349     
- Misses      12990    24282    +11292     
- Partials     2216     2634      +418     
Flag Coverage Δ
integration-tests 37.44% <ø> (?)
kind-e2e-tests 43.85% <9.09%> (-7.00%) ⬇️
unit-tests 44.77% <90.90%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/controller/networkpolicy/fqdn.go 39.51% <100.00%> (-36.00%) ⬇️
pkg/util/ip/ip.go 78.86% <100.00%> (+0.10%) ⬆️
...g/agent/apiserver/handlers/featuregates/handler.go 9.09% <0.00%> (-72.73%) ⬇️
pkg/apis/controlplane/v1beta2/helper.go 40.00% <0.00%> (-60.00%) ⬇️
pkg/controller/egress/store/egressgroup.go 1.72% <0.00%> (-54.32%) ⬇️
...kg/apiserver/registry/system/supportbundle/rest.go 22.17% <0.00%> (-50.44%) ⬇️
pkg/support/dump.go 7.90% <0.00%> (-49.16%) ⬇️
pkg/support/dump_others.go 0.00% <0.00%> (-44.74%) ⬇️
pkg/agent/types/networkpolicy.go 37.83% <0.00%> (-43.25%) ⬇️
.../agent/flowexporter/priorityqueue/priorityqueue.go 49.36% <0.00%> (-43.04%) ⬇️
... and 171 more

@tnqn
Copy link
Member Author

tnqn commented Jun 9, 2022

/test-ipv6-only-e2e
/test-ipv6-e2e
/test-all

@tnqn
Copy link
Member Author

tnqn commented Jun 9, 2022

/test-ipv6-only-e2e
/test-ipv6-e2e
/test-all

Dyanngg
Dyanngg previously approved these changes Jun 9, 2022
Copy link
Contributor

@Dyanngg Dyanngg left a comment

Choose a reason for hiding this comment

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

LGTM

IPv6 address must be wrapped with "[]" when used in network API.

This patch ensures that the auto-discovered and the user-provided DNS
servers use correct format. It also adds the missing configuration
"dnsServerOverride" to the configuration file.

Signed-off-by: Quan Tian <qtian@vmware.com>
@tnqn
Copy link
Member Author

tnqn commented Jun 10, 2022

/test-ipv6-only-e2e
/test-ipv6-e2e
/test-all

@tnqn
Copy link
Member Author

tnqn commented Jun 13, 2022

/test-ipv6-only-e2e
/test-ipv6-e2e

@tnqn tnqn merged commit 7817152 into antrea-io:main Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/backport Indicates a PR that requires backports. action/release-note Indicates a PR that should be included in release notes. area/network-policy Issues or PRs related to network policies.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Antrea policies with exact FQDN doesn't work on IPv6 clusters
4 participants