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

GH-551 check traversability of generated endpoints #613

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

maksymvavilov
Copy link
Contributor

Adding a new helper function that checks if endpoints on the DNSRecord are traversable or not. And using that function in existing integration suie

Copy link

codecov bot commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.38%. Comparing base (ece13e8) to head (bd7353f).
Report is 110 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #613      +/-   ##
==========================================
+ Coverage   80.20%   83.38%   +3.17%     
==========================================
  Files          64       72       +8     
  Lines        4492     5704    +1212     
==========================================
+ Hits         3603     4756    +1153     
- Misses        600      628      +28     
- Partials      289      320      +31     
Flag Coverage Δ
bare-k8s-integration 4.45% <ø> (?)
controllers-integration 72.83% <ø> (?)
gatewayapi-integration 11.20% <ø> (?)
integration ?
istio-integration 56.45% <ø> (?)
unit 32.76% <ø> (+2.73%) ⬆️

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

Components Coverage Δ
api/v1beta1 (u) 71.42% <ø> (ø)
api/v1beta2 (u) 93.58% <100.00%> (+2.16%) ⬆️
pkg/common (u) 88.13% <ø> (-0.70%) ⬇️
pkg/istio (u) 75.09% <ø> (+1.17%) ⬆️
pkg/log (u) 94.73% <ø> (ø)
pkg/reconcilers (u) ∅ <ø> (∅)
pkg/rlptools (u) 79.84% <ø> (+0.39%) ⬆️
controllers (i) 82.56% <79.96%> (+5.76%) ⬆️

see 32 files with indirect coverage changes

@maksymvavilov maksymvavilov changed the title [WIP] GH-551 check traversability of generated endpoints GH-551 check traversability of generated endpoints May 7, 2024
@maksymvavilov maksymvavilov marked this pull request as ready for review May 7, 2024 16:51
@maksymvavilov maksymvavilov requested a review from a team as a code owner May 7, 2024 16:51
@@ -538,6 +540,52 @@ func testBuildManagedZone(name, ns, domainName string) *kuadrantdnsv1alpha1.Mana
}
}

// testEndpointsTraversable consumes an array of endpoints and returns a boolean
// indicating presence of that path from host to all IPs
func testEndpointsTraversable(endpoints []*endpoint.Endpoint, host string, ips []string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func testEndpointsTraversable(endpoints []*endpoint.Endpoint, host string, ips []string) bool {
func testEndpointsTraversable(endpoints []*endpoint.Endpoint, host string, targets []string) bool {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

those are always an array of IP addresses 🤔 why rename?

Copy link
Member

Choose a reason for hiding this comment

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

Why does it have to be limited to checking for ip targets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right now it is "I am looking for IPs. Havent found them but still have where to look / found them so succeed / haven't found them and novhere to look so fail". If I will allow it to look for targets there will be two paths: "I looking for a CNAME. Found it so look for it's target / didn't found it - fail" and "I'm looking for an IPs" one. The difference would be an extra if statement that will decide if to say it is traversable or use the current target as a new host (the later is done now by just recurring). And this will, actually, lead to more calls (more expecive to run) if I'm not mistaken.

}
}
// at least one endpoint that matches host targeted IP
return allTargetsFound
Copy link
Member

Choose a reason for hiding this comment

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

Does this not return on the first found target?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it returns "at least one emdpoint has IP" after we went though the list of all endpoints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mikenairn are you ok with the changes made?

@mikenairn
Copy link
Member

This doesn't really do what was asked for in #551, and you have gone a different route of checking the eventual target IP(s) are reachable. This may or may not be useful, but we probably want to consider why #551 was created in the first place.

There were a number of PRs being opened that were changing the tests to suit the results they were seeing, in particular when it came to generated hashes in the dns names, and even though our current tests do check all endpoints in most cases, the verbosity of those tests makes it very difficult to be sure that things weren't changing that shouldn't be unless you really looked for it in reviews. To make this less likely to happen we created #551 to add validation to make sure one dns name could always be reached from another i.e. test.example.com -> clusterHash-gwHash.klb.test.example.com, and it was to be a generic enough function that would allow us to use it wherever it was needed, so could be used to check the geo dns names were still connected for example i.e. test.example.com -> geo1.klb.test.example.com. This would allow the addition of explicit steps to assert the structure of the endpoints where it is important to do so.

The solution given here is to make sure that all the IPs given are reachable from a given host, but it doesn't really check how they come to be accessible, you could make that test pass and still have an endpoints list that we don't really desire. We already check the endpoint target values explicitly, what advantage are we gaining by doing this? It doesn't really tell me that my geo target is still accessible from the root host, just that the IP is a target somewhere somehow.

This also highlights that we have no tests checking for CNAME targets. It is the case that an endpoint list can be created that has no IPs, but rather it creates a CNAME record pointing to a loadbalancer dns name. The current solution of checking the ip's only wouldn't allow for a test that is checking for a known CNAME target, if we want to check targets it should at least allow this.

@maksymvavilov
Copy link
Contributor Author

The last comment was discussed in the call.

It was decided to keep this test checking for targets on the endpoint but not restrain it to A records only. Now it can consume an array of targets (destinations) to reach
Note that it cannot guarantee the presence of the endpoint but only the presence of the target on the endpoint

// testEndpointsTraversable consumes an array of endpoints and returns a boolean
// indicating presence of that path from host to all destinations
// this function DOES NOT report a presence of an endpoint with one of destinations DNSNames
func testEndpointsTraversable(endpoints []*endpoint.Endpoint, host string, destinations []string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

You really don't want to call this targets 🤷‍♂️

Since you want this to take a host and a list of expected endpoint "target" values it should be able to reach, using a completely different name for the concept seems odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will create confusion since we have endpoint.targets and a list of targets we are trying to reach. They were called targets and endpointTargets for a while but this does not help. But yes, i really want to avoid calling them targets as much as I can: the function is awkward to read as is and creating similar names won't help.

@maksymvavilov maksymvavilov merged commit dc597d9 into main Jun 12, 2024
81 of 82 checks passed
@maksymvavilov maksymvavilov deleted the GH-551 branch June 12, 2024 08:52
dlaw4608 pushed a commit to dlaw4608/kuadrant-operator that referenced this pull request Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

DNSPolicy: Update all integration tests to validate the structure of the produced DNSrecord endpoints
2 participants