From be26e892fd19e0c542cc3007e2e609ad5bae6c20 Mon Sep 17 00:00:00 2001 From: Arron Norwell Date: Mon, 23 Feb 2026 17:01:02 +0000 Subject: [PATCH] Fix EFS_FQDN_RE to support ADC DNS suffixes with hyphens The dns_name_suffix capture group in EFS_FQDN_RE used [a-z0-9.] which does not match hyphens. ADC regions like NCL use DNS suffix 'cloud.adc-e.uk' which contains a hyphen, causing mount.efs to reject the FQDN with 'did not resolve to a valid DNS name for an EFS mount target'. Add hyphen to the character class: [a-z0-9.-] --- src/mount_efs/__init__.py | 2 +- test/mount_efs_test/test_match_device.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/mount_efs/__init__.py b/src/mount_efs/__init__.py index faba243a..9b5fe51b 100755 --- a/src/mount_efs/__init__.py +++ b/src/mount_efs/__init__.py @@ -190,7 +190,7 @@ FS_ID_RE = re.compile("^(?Pfs-[0-9a-f]+)$") EFS_FQDN_RE = re.compile( r"^((?P[a-z0-9-]+)\.)?(?Pfs-[0-9a-f]+)\.(?:[a-z-]+\.)+" - r"(?P[a-z0-9-]+)\.(?P[a-z0-9.]+)$" + r"(?P[a-z0-9-]+)\.(?P[a-z0-9.-]+)$" ) AP_ID_RE = re.compile("^fsap-[0-9a-f]{17}$") diff --git a/test/mount_efs_test/test_match_device.py b/test/mount_efs_test/test_match_device.py index 9eccea4f..af06baf4 100644 --- a/test/mount_efs_test/test_match_device.py +++ b/test/mount_efs_test/test_match_device.py @@ -118,6 +118,26 @@ def test_match_device_correct_descriptors_cname_dns_suffix_override_region(mocke utils.assert_called(gethostbyname_ex_mock) +def test_match_device_correct_descriptors_cname_dns_adc_suffix(mocker): + """ADC regions use DNS suffixes with hyphens (e.g. cloud.adc-e.uk)""" + adc_dns_name = "fs-deadbeef.efs.eu-isoe-west-1.cloud.adc-e.uk" + get_dns_name_mock = mocker.patch( + "mount_efs.get_dns_name_and_fallback_mount_target_ip_address", + return_value=(adc_dns_name, None), + ) + gethostbyname_ex_mock = mocker.patch( + "socket.gethostbyname_ex", + return_value=(adc_dns_name, [], None), + ) + config = _get_mock_config(dns_name_suffix="cloud.adc-e.uk") + for device, (fs_id, path, az) in CORRECT_DEVICE_DESCRIPTORS_CNAME_DNS: + assert (fs_id, path, az) == mount_efs.match_device( + config, device, DEFAULT_NFS_OPTIONS + ) + utils.assert_called(get_dns_name_mock) + utils.assert_called(gethostbyname_ex_mock) + + def test_match_device_correct_descriptors_cname_dns_primary(mocker): get_dns_name_mock = mocker.patch( "mount_efs.get_dns_name_and_fallback_mount_target_ip_address",