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

Add support for DNSNameResolver #4045

Merged
merged 5 commits into from
May 8, 2024
Merged

Conversation

arkadeepsen
Copy link
Contributor

@arkadeepsen arkadeepsen commented Dec 9, 2023

This PR adds the support for DNSNameResolver in ovnk as per the enhancement proposal openshift/enhancements#1335.

This feature is enabled via a new flag enable-dns-name-resolver. However, enable-egress-firewall flag should also be set for this feature to be enabled.

cluster-manager watches for events related to EgressFirewall objects and creates/deletes the DNSNameResolver objects based on the events.

ovnkube-controller watches DNSNameResolver to get the latest IP addresses associated with a DNS name. resolver is initialized instead ofegressFirewallDNS and it is used to create/destroy/update address sets related to DNS names.

If the enable-dns-name-resolver is not enabled, then the behavior of ovnk doesn't change.

@coveralls
Copy link

coveralls commented Dec 9, 2023

Coverage Status

coverage: 52.689% (+0.3%) from 52.418%
when pulling 6788da1 on arkadeepsen:dnsnameresolver
into 9bf6a48 on ovn-org:master.

Copy link
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

Thanks for this work @arkadeepsen !
Did a first round, feel free to ping me for more info/help on these comments :)

go-controller/pkg/clustermanager/clustermanager.go Outdated Show resolved Hide resolved
go-controller/pkg/clustermanager/clustermanager.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall_resolver.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall_resolver.go Outdated Show resolved Hide resolved
go-controller/pkg/clustermanager/dnsnameresolver_test.go Outdated Show resolved Hide resolved
go-controller/pkg/kube/kube.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall_resolver.go Outdated Show resolved Hide resolved
go-controller/pkg/util/util.go Outdated Show resolved Hide resolved
@arkadeepsen
Copy link
Contributor Author

@npinaeva I have made the suggested changes. PTAL.

Copy link
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

nice update! some more comments :)

go-controller/pkg/kube/kube.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/default_network_controller.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/dnsnameresolver.go Outdated Show resolved Hide resolved
@tssurya tssurya added feature/egress-firewall All issues related to egress firewall kind/feature All issues/PRs that are new features labels Mar 14, 2024
@tssurya tssurya added this to the v1.0.0 milestone Mar 14, 2024
Copy link

netlify bot commented Mar 26, 2024

Deploy Preview for subtle-torrone-bb0c84 ready!

Name Link
🔨 Latest commit c9a2169
🔍 Latest deploy log https://app.netlify.com/sites/subtle-torrone-bb0c84/deploys/662936d36165a50009a01690
😎 Deploy Preview https://deploy-preview-4045--subtle-torrone-bb0c84.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

getting better every time!

go-controller/pkg/factory/factory.go Outdated Show resolved Hide resolved
go-controller/pkg/factory/factory.go Outdated Show resolved Hide resolved
go-controller/pkg/factory/factory.go Outdated Show resolved Hide resolved
go-controller/pkg/util/util.go Outdated Show resolved Hide resolved
Copy link
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

nice progress!

go-controller/pkg/ovn/dnsnameresolver.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall.go Outdated Show resolved Hide resolved
Err: fmt.Errorf("error adding DNS name %s: addressSetFactory is nil", request.DNSName),
}
}
asIndex := GetEgressFirewallDNSAddrSetDbIDs(request.DNSName, extEgDNS.controllerName)
Copy link
Member

Choose a reason for hiding this comment

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

note to self: we may need to rename addrset owner to DNSName instead of egress firewall at some point

Copy link
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

interface looks great!

Copy link
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

Looks like we use underscores for folder names, so I think we should rename ovn/dns-name-resolver folder.
Also, it may be a good time to start splitting this into commits, I am thinking we should have separate commits for

  • vendor bump
  • crd change
  • cluster manager side
  • everything else

go-controller/pkg/util/dnsnameresolver.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall_test.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall_test.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall_test.go Outdated Show resolved Hide resolved
@npinaeva
Copy link
Member

btw #4251 got merged

@arkadeepsen
Copy link
Contributor Author

btw #4251 got merged

@npinaeva updated code accordingly

@arkadeepsen arkadeepsen force-pushed the dnsnameresolver branch 2 times, most recently from e3888c0 to cecb24c Compare April 23, 2024 21:57
@arkadeepsen arkadeepsen force-pushed the dnsnameresolver branch 3 times, most recently from e38a75c to c9a2169 Compare April 24, 2024 16:44
npinaeva
npinaeva previously approved these changes May 6, 2024
Copy link
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

thank you for patience and a great contribution @arkadeepsen!

@arkadeepsen
Copy link
Contributor Author

thank you for patience and a great contribution @arkadeepsen!

Thanks @npinaeva for providing your feedback and suggestions to the PR.

Copy link
Contributor

@trozet trozet left a comment

Choose a reason for hiding this comment

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

Can we add e2es to make sure this new feature works?

// objects in the cluster.
type Controller struct {
lock sync.Mutex
ocpNetworkClient ocpnetworkclientset.Interface
Copy link
Contributor

Choose a reason for hiding this comment

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

so does this feature work without openshift? I think there should be some update to our docs to talk about this new feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the doc explaining how to use the feature.

// names and mark them as unreferenced.
addrSetReferenced := map[string]bool{}
predicate := libovsdbops.GetPredicate[*nbdb.AddressSet](predicateIDs, func(item *nbdb.AddressSet) bool {
fmt.Printf("Address Set: %s\n", item.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

should remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

// Set addrSetReferenced[addrSetName] = true if referencing acl exists.
_, err = libovsdbops.FindACLsWithPredicate(nbClient, func(item *nbdb.ACL) bool {
for addrSetName := range addrSetReferenced {
fmt.Printf("ACL: %s\n", item.Match)
Copy link
Contributor

Choose a reason for hiding this comment

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

this too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

// acl then delete it.
ops := []ovsdb.Operation{}
for addrSetName, isReferenced := range addrSetReferenced {
fmt.Printf("Address Set: %s, is referenced: %t\n", addrSetName, isReferenced)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

// Delete the stale address sets.
_, err = libovsdbops.TransactAndCheck(nbClient, ops)
if err != nil {
return fmt.Errorf("failed to trasact db ops: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

"failed to transact db ops to delete address sets..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the error message.

@npinaeva
Copy link
Member

npinaeva commented May 8, 2024

Can we add e2es to make sure this new feature works?

that is planned as a separate PR, as it requires some more work to add dnsresolver to the kind cluster here https://github.com/openshift/coredns-ocp-dnsnameresolver. The feature will need only the operator provided by ^ to work. In openshift it is deployed as a part of cluster-dns-operator, but we need some more time to make it work with kind.

Signed-off-by: arkadeepsen <arsen@redhat.com>
…upport wildcard DNS name

Signed-off-by: arkadeepsen <arsen@redhat.com>
Signed-off-by: arkadeepsen <arsen@redhat.com>
Signed-off-by: arkadeepsen <arsen@redhat.com>
Signed-off-by: arkadeepsen <arsen@redhat.com>
The DNS name resolver should be configured in the following components for it to work
in a cluster:

### [DNSNameResolver operator](https://github.com/openshift/coredns-ocp-dnsnameresolver/tree/main/operator)
Copy link
Member

Choose a reason for hiding this comment

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

I think we will automate this in our kind.sh script, so maybe we can omit this section for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we not need these details if someone wants to deploy in any other cluster apart from kind?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think its a good idea to keep it for now until we have automated install. We also have the helm install now so we will need to make sure it installs with kind and helm. @flavio-fernandes fyi

@trozet trozet merged commit cc2006c into ovn-org:master May 8, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/egress-firewall All issues related to egress firewall kind/feature All issues/PRs that are new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants