Skip to content

tests: Add tests for internal load balancers and forwards#560

Merged
tomponline merged 1 commit intocanonical:mainfrom
nmezhenskyi:ovn-lb-internal
Aug 13, 2025
Merged

tests: Add tests for internal load balancers and forwards#560
tomponline merged 1 commit intocanonical:mainfrom
nmezhenskyi:ovn-lb-internal

Conversation

@nmezhenskyi
Copy link
Contributor

This PR adds tests to check that internal load balancers and forwards are reachable from inside of the OVN network, but are unreachable from outside.

Follow-up to canonical/lxd#16162.

This should be merged together with canonical/lxd#16179 (adds ovn_internal_load_balancer API extension for LXD).

Comment on lines +1184 to +1185
lxc network load-balancer port add ovn-virtual-network "${ip4AddressPrefix}.10" tcp 53 u1,u2
lxc network load-balancer port add ovn-virtual-network "${ip6AddressPrefix}::10" tcp 53 u1,u2
Copy link
Member

Choose a reason for hiding this comment

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

I'm not up to date on what LXD/OVN support so is this load-balancing taking into account the health of the targets? In other words, if we lxc stop u1, will u2 pick up the slack?

Copy link
Contributor Author

@nmezhenskyi nmezhenskyi Aug 12, 2025

Choose a reason for hiding this comment

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

is this load-balancing taking into account the health of the targets?

No, it does not. If we stop u1 and the request gets sent there, it will just hang and fail due to a timeout. We have a separate roadmap item for health checks that will prevent this, but it's not a part of this cycle AFAIK.

Copy link
Member

Choose a reason for hiding this comment

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

As additional tests, would there be value to remove say u1 from the LB pool and confirm that we always get the answers from u2 (127.0.0.2 and ::2)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this wouldn't hurt, I'll add this

Comment on lines 1195 to 1198
lxc exec u1 -- dig a +tcp "@${ip4AddressPrefix}.10" lxd.localdomain +short
lxc exec u1 -- dig aaaa +tcp "@${ip6AddressPrefix}::10" lxd.localdomain +short
lxc exec u2 -- dig a +tcp "@${ip4AddressPrefix}.10" lxd.localdomain +short
lxc exec u2 -- dig aaaa +tcp "@${ip6AddressPrefix}::10" lxd.localdomain +short
Copy link
Member

@simondeziel simondeziel Aug 12, 2025

Choose a reason for hiding this comment

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

Each of those lookups gets a ~50% chance of returning 127.0.0.1 (::1) or 127.0.0.2 (::2). Could we count each type of answer and at the end, require that each answer was seen at least once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, this should work

Comment on lines +1184 to +1185
lxc network load-balancer port add ovn-virtual-network "${ip4AddressPrefix}.10" tcp 53 u1,u2
lxc network load-balancer port add ovn-virtual-network "${ip6AddressPrefix}::10" tcp 53 u1,u2
Copy link
Member

Choose a reason for hiding this comment

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

As additional tests, would there be value to remove say u1 from the LB pool and confirm that we always get the answers from u2 (127.0.0.2 and ::2)?

@nmezhenskyi nmezhenskyi marked this pull request as draft August 12, 2025 18:04
Add tests to check that internal load balancers and forwards are
reachable from inside of the OVN network, but are unreachable from
outside.

Signed-off-by: Nikita Mezhenskyi <nikita.mezhenskyi@canonical.com>
@nmezhenskyi nmezhenskyi marked this pull request as ready for review August 12, 2025 22:02
Comment on lines +1201 to +1206
for _ in $(seq 5); do
[ "$(lxc exec u1 -- dig a +tcp "@${ip4AddressPrefix}.10" lxd.localdomain +short)" = "127.0.0.1" ] && u1_ip4_seen=$((u1_ip4_seen + 1))
[ "$(lxc exec u1 -- dig aaaa +tcp "@${ip6AddressPrefix}::10" lxd.localdomain +short)" = "::1" ] && u1_ip6_seen=$((u1_ip6_seen + 1))
[ "$(lxc exec u2 -- dig a +tcp "@${ip4AddressPrefix}.10" lxd.localdomain +short)" = "127.0.0.2" ] && u2_ip4_seen=$((u2_ip4_seen + 1))
[ "$(lxc exec u2 -- dig aaaa +tcp "@${ip6AddressPrefix}::10" lxd.localdomain +short)" = "::2" ] && u2_ip6_seen=$((u2_ip6_seen + 1))
done
Copy link
Member

Choose a reason for hiding this comment

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

I rarely resort to bash arrays but this might have been handy to count all the answers all the time.

$ dns_replies=()  # declares an array
$ answer="$(lxc exec u1 -- dig a +tcp "@${ip4AddressPrefix}.10" lxd.localdomain +short)"
$ dns_replies["${answer}"]="$((dns_replies["${answer}"] + 1))"

Then you could iterate over the expected answers and make sure they are >= 1 and also ensure the array's length (${#dns_replies[@]}) was exactly 4.

Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Thanks!

@tomponline tomponline merged commit 585680b into canonical:main Aug 13, 2025
188 checks passed
@nmezhenskyi nmezhenskyi deleted the ovn-lb-internal branch August 14, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants