Skip to content

Commit d6e6d24

Browse files
Clean resolv.conf if it's not managed by system at the end of AMI build
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 <[email protected]>
1 parent c1007d8 commit d6e6d24

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cookbooks/aws-parallelcluster-platform/files/ami_cleanup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ if [ "${ID}${VERSION_ID}" == "centos7" ]; then
2020
rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
2121
fi
2222

23+
# Clean resolv.conf if it's not managed by system
24+
if [ ! -L "/etc/resolv.conf" ]; then
25+
echo -n > /etc/resolv.conf
26+
fi
27+
2328
find /var/log -type f -exec /bin/rm -v {} \;
2429
touch /var/log/lastlog

0 commit comments

Comments
 (0)