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

CFE-851: Add OCP DNSNameResolver external plugin functionality #1

Merged
merged 18 commits into from
Mar 26, 2024

Conversation

arkadeepsen
Copy link
Contributor

This PR adds the new external plugin ocp_dnsnameresolver as per the enhancement proposal openshift/enhancements#1335

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 6, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 6, 2023

@arkadeepsen: This pull request references CFE-851 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set.

In response to this:

This PR adds the new external plugin ocp_dnsnameresolver as per the enhancement proposal openshift/enhancements#1335

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@arkadeepsen
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 6, 2023

@arkadeepsen: This pull request references CFE-851 which is a valid jira issue.

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@candita
Copy link

candita commented Nov 22, 2023

/assign @Miciah
/assign @alebedev87

Copy link
Contributor

@alebedev87 alebedev87 left a comment

Choose a reason for hiding this comment

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

Part 1: dockerfile, makefile, hack scripts and readme. To be continued...

OWNERS Show resolved Hide resolved
hack/add-plugin.sh Outdated Show resolved Hide resolved
hack/add-plugin.sh Outdated Show resolved Hide resolved
hack/add-plugin.sh Outdated Show resolved Hide resolved
hack/add-plugin.sh Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
…mt. Updated Dockerfile to use make build-coredns. Updated Makefile to add defaults for some env vars and to add verify rule. Updated isWildcard function to use HasPrefix rather than TrimPrefix and use "*." as the prefix.
Makefile Outdated Show resolved Hide resolved
hack/build-coredns.sh Outdated Show resolved Hide resolved
hack/verify-gofmt.sh Outdated Show resolved Hide resolved
@arkadeepsen
Copy link
Contributor Author

/retest

…. Update ocp version from 4.15 to 4.16 in Dockerfile.
@@ -0,0 +1,34 @@
reviewers:
Copy link
Member

Choose a reason for hiding this comment

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

I would say from the SDN team side, you could add myself to reviewers and danwinship to reviewers and approvers, since no one else from the team is involved in this effort for now. And we can add more people later if needed.

Copy link
Contributor

@alebedev87 alebedev87 left a comment

Choose a reason for hiding this comment

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

Part 2. First look at the go code. The handler and the unit tests are not reviewed yet.

hack/build-coredns.sh Outdated Show resolved Hide resolved
hack/build-coredns.sh Outdated Show resolved Hide resolved
setup.go Show resolved Hide resolved
setup.go Outdated Show resolved Hide resolved
setup.go Outdated Show resolved Hide resolved
dnsnameresolver.go Outdated Show resolved Hide resolved
dnsnameresolver.go Outdated Show resolved Hide resolved
dnsnameresolver.go Show resolved Hide resolved
dnsnameresolver.go Show resolved Hide resolved
setup.go Outdated Show resolved Hide resolved
…temp dir. Removed the '-mod=vendor' flag from the coredns go build command as coredns already contains the vendor directory.
… in all files. Added description about maps in dnsnameresolve.go.
…dency on the send channel in the initInformer function by using "k8s.io/apimachinery/pkg/util/wait" package functions in the TestServeDNS test function. Refactored updateResolvedNamesSuccess and updateResolvedNamesFailure functions and simplified the code by breaking them down into multple functions.
namespace.go Outdated Show resolved Hide resolved
…ng to kuberenetes plugin for starting server with unsynced informer.
Copy link
Contributor

@alebedev87 alebedev87 left a comment

Choose a reason for hiding this comment

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

Reviewed the handler's unit test. The coverage looks good to me. Some remarks and questions though.

// Create the DNSNameResolver object.
_, err := fakeNetworkClient.NetworkV1alpha1().DNSNameResolvers("dns").Create(context.TODO(), &dnsNameResolver, metav1.CreateOptions{})
if err != nil {
t.Fatalf("error injecting dns name resolver: %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.

Suggested change
t.Fatalf("error injecting dns name resolver: %v", err)
t.Fatalf("error creating dns name resolver: %v", err)

handler_test.go Outdated Show resolved Hide resolved
handler_test.go Outdated Show resolved Hide resolved
handler_test.go Show resolved Hide resolved
handler_test.go Outdated Show resolved Hide resolved
handler_test.go Show resolved Hide resolved
handler_test.go Outdated Show resolved Hide resolved
handler_test.go Outdated
},
},
{
name: "Update wildcard dns name resolver object status with wildcard dns name, then don't add regular dns name",
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference from Update wildcard dns name resolver object status with only wildcard dns name case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. It is a duplication of the same test. I'll remove this one.

handler_test.go Show resolved Hide resolved
Comment on lines +1666 to +1677
Answer: []dns.RR{
test.A("*.example.com. 30 IN A 1.1.1.1"),
test.A("*.example.com. 30 IN A 1.1.1.2"),
},
},
{
Qname: "www.example.com.",
Qtype: dns.TypeA,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{
test.A("www.example.com. 30 IN A 1.1.1.1"),
test.A("www.example.com. 30 IN A 1.1.1.2"),
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 it's better to make the IP addresses different here to make sure they were not mixed up by the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The IPs are made same to demonstrate that though the details of the regular DNS name is not added to the status of the DNSNameResolver corresponding to the wildcard DNS name, but added to the status of the DNSNameResolver corresponding to the regular DNS name.

This is in line with the previous comment (#1 (comment)) and tests the behavior for a DNSNameResolver object for a regular DNS name.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the sake of completeness of the behavior: can we have a test case where wildcard and regular name matching the wildcard would have different addresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

…ddress and DNS name functionality of the plugin. Update handler.go file to take care of edge cases of status update. Update dnsnameresolver.go file to take care of the case of multiple namespaces. Update handle_test.go to use diff on the entire status rather than iterating over each resolved name. Add new test cases for multiple namespaces, and NS and CNAME record types. Add more comments wherever possible to better explain the flow.
…racting the time since last lookup from the current time for the unit tests.
Copy link

openshift-ci bot commented Mar 19, 2024

@arkadeepsen: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@arkadeepsen
Copy link
Contributor Author

@alebedev87 I have updated the code to take care of the review comments. The response is inline.

To sum up what's expected before we can approve and merge the PR:

Added tests for multiple namespaces.

Refactored the comparison logic. Removed the polling as the informer is already synced via the sleep during the execution of the ServeDNS function. Refactor the logic to use diff directly on the status rather than iterating over the resolved name and using diff on each resolved name.

Updated the name to fakeNextPluginHandler.

Added the new field for getting the time since last lookup and that is subtracted from the current time when creating the objects.

Updated the description section of the README file for adding more details about how the plugin takes care of a DNS lookup.

Test cases for NS and CNAME are added,

The duplicate test case is removed.

The TTL of all IP address should have expired so that the plugin can remove the resolved name if the resolution failure becomes greater than or equal to 5 (#1 (comment)).

The test already exists (#1 (comment)).

  • Some comments to be added:

  • 1

Added the comment to explain the sleep.

Updated the comment stating the reason the why the polling is required.

Added the comment to explain why the TTL of the IP addresses was changed to 5 seconds.

@alebedev87
Copy link
Contributor

Thanks @arkadeepsen for the updates! Let's move on with the implementation.

/lgtm
/apptrove

@alebedev87
Copy link
Contributor

/hold

In case @Miciah wants to review too.

@openshift-ci openshift-ci bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Mar 22, 2024
@alebedev87
Copy link
Contributor

/unhold

As discussed with Micah.

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 22, 2024
@alebedev87
Copy link
Contributor

/approve

Copy link

openshift-ci bot commented Mar 22, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alebedev87

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@snarayan-redhat
Copy link

/label docs-approved

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label Mar 25, 2024
@CFields651
Copy link

/label px-approved

@openshift-ci openshift-ci bot added the px-approved Signifies that Product Support has signed off on this PR label Mar 25, 2024
@melvinjoseph86
Copy link

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Mar 26, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 26, 2024

@arkadeepsen: This pull request references CFE-851 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.16." or "openshift-4.16.", but it targets "openshift-4.15" instead.

In response to this:

This PR adds the new external plugin ocp_dnsnameresolver as per the enhancement proposal openshift/enhancements#1335

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@arkadeepsen
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 26, 2024

@arkadeepsen: This pull request references CFE-851 which is a valid jira issue.

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-bot openshift-merge-bot bot merged commit fc0f617 into openshift:main Mar 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants