-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DNS name retrieval on Multi NICs instance
Fix the DNS name retrieval on Multi NICs instance, where the PrivateDnsName is the DNS name of the network interface with NetworkCardIndex 0 and DeviceIndex 0. The problem was showing up when using `SlurmSettings/Dns/UseEc2Hostnames` equals to `True`. Signed-off-by: Luca Carrogu <carrogu@amazon.com>
- Loading branch information
1 parent
0ad03a1
commit 6adb559
Showing
5 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. | ||
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. | ||
# See the License for the specific language governing permissions and limitations under the License. | ||
import pytest | ||
from assertpy import assert_that | ||
from common.ec2_utils import get_private_ip_address_and_dns_name | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"instance_info, expected_private_ip, expected_private_dns_name", | ||
[ | ||
( | ||
{ | ||
"InstanceId": "i-12345", | ||
"InstanceType": "c5.xlarge", | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
"NetworkInterfaces": [ | ||
{ | ||
"Attachment": { | ||
"DeviceIndex": 0, | ||
"NetworkCardIndex": 0, | ||
}, | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
}, | ||
], | ||
}, | ||
"ip.1.0.0.1", | ||
"ip-1-0-0-1", | ||
), | ||
( | ||
{ | ||
"InstanceId": "i-12345", | ||
"InstanceType": "c5.xlarge", | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
"NetworkInterfaces": [ | ||
{ | ||
"Attachment": { | ||
"DeviceIndex": 0, | ||
"NetworkCardIndex": 0, | ||
}, | ||
}, | ||
], | ||
}, | ||
"ip.1.0.0.1", | ||
"ip-1-0-0-1", | ||
), | ||
( | ||
{ | ||
"InstanceId": "i-12345", | ||
"InstanceType": "c5.xlarge", | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
"NetworkInterfaces": [ | ||
{ | ||
"Attachment": {}, | ||
}, | ||
], | ||
}, | ||
"ip.1.0.0.1", | ||
"ip-1-0-0-1", | ||
), | ||
( | ||
{ | ||
"InstanceId": "i-12345", | ||
"InstanceType": "c5.xlarge", | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
"NetworkInterfaces": [ | ||
{ | ||
"Attachment": { | ||
"DeviceIndex": 0, | ||
"NetworkCardIndex": 1, | ||
}, | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
}, | ||
{ | ||
"Attachment": { | ||
"DeviceIndex": 0, | ||
"NetworkCardIndex": 0, | ||
}, | ||
"PrivateIpAddress": "ip.1.0.0.2", | ||
"PrivateDnsName": "ip-1-0-0-2", | ||
}, | ||
], | ||
}, | ||
"ip.1.0.0.2", | ||
"ip-1-0-0-2", | ||
), | ||
( | ||
{ | ||
"InstanceId": "i-12345", | ||
"InstanceType": "c5.xlarge", | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
"NetworkInterfaces": [ | ||
{ | ||
"Attachment": { | ||
"DeviceIndex": 0, | ||
"NetworkCardIndex": 0, | ||
}, | ||
"PrivateIpAddress": "ip.1.0.0.1", | ||
"PrivateDnsName": "ip-1-0-0-1", | ||
}, | ||
{ | ||
"Attachment": { | ||
"DeviceIndex": 0, | ||
"NetworkCardIndex": 1, | ||
}, | ||
"PrivateIpAddress": "ip.1.0.0.2", | ||
"PrivateDnsName": "ip-1-0-0-2", | ||
}, | ||
], | ||
}, | ||
"ip.1.0.0.1", | ||
"ip-1-0-0-1", | ||
), | ||
], | ||
) | ||
def test_get_private_ip_address_and_dns_name(mocker, instance_info, expected_private_ip, expected_private_dns_name): | ||
actual_private_ip, actual_private_dns_name = get_private_ip_address_and_dns_name(instance_info) | ||
assert_that(actual_private_ip).is_equal_to(expected_private_ip) | ||
assert_that(actual_private_dns_name).is_equal_to(expected_private_dns_name) |