-
Notifications
You must be signed in to change notification settings - Fork 883
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(azure): Avoid non-primary nics from having routes to DNS CPC-4224 #5180
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import datetime | ||
|
||
import pytest | ||
import yaml | ||
from pycloudlib.azure.util import AzureCreateParams, AzureParams | ||
from pycloudlib.cloud import ImageType | ||
|
||
from tests.integration_tests.clouds import IntegrationCloud | ||
from tests.integration_tests.conftest import get_validated_source | ||
from tests.integration_tests.instances import IntegrationInstance | ||
from tests.integration_tests.integration_settings import PLATFORM | ||
from tests.integration_tests.releases import CURRENT_RELEASE | ||
from tests.integration_tests.releases import BIONIC, CURRENT_RELEASE | ||
|
||
|
||
def _check_for_eject_errors( | ||
|
@@ -45,3 +49,42 @@ def test_azure_eject(session_cloud: IntegrationCloud): | |
session_cloud.cloud_instance.delete_image(snapshot_id) | ||
else: | ||
_check_for_eject_errors(instance) | ||
|
||
|
||
@pytest.mark.skipif(PLATFORM != "azure", reason="Test is Azure specific") | ||
@pytest.mark.skipif( | ||
CURRENT_RELEASE < BIONIC, reason="Easier to test on Bionic+" | ||
) | ||
def test_azure_multi_nic_setup( | ||
setup_image, session_cloud: IntegrationCloud | ||
) -> None: | ||
"""Integration test for https://warthogs.atlassian.net/browse/CPC-3999. | ||
Azure should have the primary NIC only route to DNS. | ||
Ensure other NICs do not have route to DNS. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not believe this test exercises the behaviour of concern. As described in https://warthogs.atlassian.net/browse/CPC-3999 , there is no route to the DHCP/DNS server through the secondary NIC on Mantic hosts (per There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Let me see how parse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bionic does not have |
||
""" | ||
us = datetime.datetime.now().strftime("%f") | ||
rg_params = AzureParams(f"ci-test-multi-nic-setup-{us}", None) | ||
nic_one = AzureCreateParams(f"ci-nic1-test-{us}", rg_params.name, None) | ||
nic_two = AzureCreateParams(f"ci-nic2-test-{us}", rg_params.name, None) | ||
with session_cloud.launch( | ||
launch_kwargs={ | ||
"resource_group_params": rg_params, | ||
"network_interfaces_params": [nic_one, nic_two], | ||
} | ||
) as snapshot_instance: | ||
_check_for_eject_errors(snapshot_instance) | ||
if CURRENT_RELEASE.series == "bionic": | ||
aciba90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ret = snapshot_instance.execute("systemd-resolve --status") | ||
assert ret.ok, ret.stderr | ||
assert ret.stdout.count("Current Scopes: DNS") == 1 | ||
else: | ||
ret = snapshot_instance.execute("resolvectl dns") | ||
assert ret.ok, ret.stderr | ||
routes = yaml.safe_load(ret.stdout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per RESOLVECTL(1) the output of this command is not yaml, the Not sure if the tests are going to hit this problem, but if we would like to be 100% safe here we should split by the first occurrence of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I would try coming up with a logic to parse the output. I think I saw the output was something similar to
Thus I thought yaml parsing will be easier. |
||
routes_devices = list(routes.keys()) | ||
eth1_dev = [dev for dev in routes_devices if "(eth1)" in dev][0] | ||
assert routes[eth1_dev] is None | ||
aciba90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# check the instance can resolve something | ||
res = snapshot_instance.execute("resolvectl query google.com") | ||
assert res.ok, res.stderr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this config only applied to NICs with
hv_netvsc
as driver?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source: https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-how-it-works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that:
hv_netvsc
driver.Could please add a breadcrumb pointing to this, as a comment and/or in the commit message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your proposed solution only matches against
eth*
names, should we also match againstenP\<n\>
ones? Or is there a reason I do not see to restrict this toeth*
?