Skip to content

Conversation

@hanwen-cluster
Copy link
Contributor

@hanwen-cluster hanwen-cluster commented Mar 20, 2025

The conditional statement avoids cleaning if the /etc/resolv.conf is a symbolic link. It is a symbolic link when it is managed by other systems.

Cleaning the /etc/resolv.conf speeds up instance launch because it wouldn't try to use name server from the AMI creation environment. The delay was shown in /var/log/cloud-init.log:

2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://169.254.169.254 took 40.099 seconds
2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://[fd00:ec2::254] took 0.000 seconds
2025-03-19 16:00:17,731 - util.py[DEBUG]: Resolving URL: http://instance-data.:8773 took 10.010 seconds

Example content of /etc/resolv.conf:

cat /etc/resolv.conf
# Generated by NetworkManager
search ec2.internal
nameserver 192.168.0.2

Tests

  • Manually made change to the AMI. Cluster creation time with static compute nodes on RHEL 9 was 19:00. Now it is 16:00

Checklist

  • Make sure you are pointing to the right branch.
  • If you're creating a patch for a branch other than develop add the branch name as prefix in the PR title (e.g. [release-3.6]).
  • Check all commits' messages are clear, describing what and why vs how.
  • Make sure to have added unit tests or integration tests to cover the new/modified code.
  • Check if documentation is impacted by this change.

Please review the guidelines for contributing and Pull Request Instructions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The conditional statement avoids cleaning if the `/etc/resolv.conf` is a symbolic link. It is a symbolic link when it is managed by other systems.

Cleaning the `/etc/resolv.conf` speed up instance launch because it wouldn't try to use name server from the AMI creation environment. The delay was shown in `/var/log/cloud-init.log`:
```
2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://169.254.169.254 took 40.099 seconds
2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://[fd00:ec2::254] took 0.000 seconds
2025-03-19 16:00:17,731 - util.py[DEBUG]: Resolving URL: http://instance-data.:8773 took 10.010 seconds
```

Example content of `/etc/resolv.conf`:
```
cat /etc/resolv.conf
# Generated by NetworkManager
search ec2.internal
nameserver 192.168.0.2
```

Signed-off-by: Hanwen <hanwenli@amazon.com>
@hanwen-cluster hanwen-cluster requested review from a team as code owners March 20, 2025 19:54
@hanwen-cluster hanwen-cluster changed the title Clean resolv.conf if it's not managed by system at the end of AMI build Clean resolv.conf at the end of AMI build Mar 20, 2025
The conditional statement avoids cleaning if the `/etc/resolv.conf` is a symbolic link. It is a symbolic link when it is managed by other systems.

Cleaning the `/etc/resolv.conf` speeds up instance launch because it wouldn't try to use name server from the AMI creation environment. The delay was shown in `/var/log/cloud-init.log`:
```
2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://169.254.169.254 took 40.099 seconds
2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://[fd00:ec2::254] took 0.000 seconds
2025-03-19 16:00:17,731 - util.py[DEBUG]: Resolving URL: http://instance-data.:8773 took 10.010 seconds
```

Example content of `/etc/resolv.conf`:
```
cat /etc/resolv.conf
# Generated by NetworkManager
search ec2.internal
nameserver 192.168.0.2
```

Signed-off-by: Hanwen <hanwenli@amazon.com>
@hanwen-cluster hanwen-cluster merged commit 17a93ba into aws:release-3.13 Mar 20, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants