Skip to content

Commit

Permalink
[Static DNS] Optimize DNS configuration update during interface-confi…
Browse files Browse the repository at this point in the history
…g service restart
  • Loading branch information
oleksandrivantsiv committed Jul 15, 2024
1 parent e2b30cc commit 14ddf45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
21 changes: 21 additions & 0 deletions files/image_config/interfaces/interfaces-config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
resolvconf_updates=true

function wait_networking_service_done() {
local -i _WDOG_CNT="1"
Expand All @@ -23,6 +24,24 @@ function wait_networking_service_done() {
systemctl kill networking 2>&1
}

function resolvconf_updates_disable() {
resolvconf --updates-are-enabled
if [[ $? -ne 0 ]]; then
resolvconf_updates=false
fi
resolvconf --disable-updates
}

function resolvconf_updates_restore() {
if [[ $resolvconf_updates == true ]]; then
resolvconf --enable-updates
fi
}

# Do not run DNS configuration update during the shutdowning of the management interface.
# This operation is redundant as there will be an update after the start of the interface.
resolvconf_updates_disable

if [[ $(ifquery --running eth0) ]]; then
wait_networking_service_done
ifdown --force eth0
Expand Down Expand Up @@ -61,6 +80,8 @@ for intf_pid in $(ls -1 /var/run/dhclient*.Ethernet*.pid 2> /dev/null); do
done

/usr/bin/resolv-config.sh cleanup
# Restore DNS configuration update to the previous state.
resolvconf_updates_restore

# Read sysctl conf files again
sysctl -p /etc/sysctl.d/90-dhcp6-systcl.conf
Expand Down
7 changes: 6 additions & 1 deletion files/image_config/resolv-config/update-containers
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash

for container in $(docker ps -a --format=" {{ .ID }}"); do
networking_status=$(systemctl is-active networking.service 2>/dev/null)
if [[ $networking_status != "active" ]]; then
exit 0
fi

for container in $(docker ps -q); do
docker cp -L /etc/resolv.conf ${container}:/_resolv.conf
docker exec -t ${container} bash -c "cat /_resolv.conf > /etc/resolv.conf"
docker exec -t ${container} bash -c "rm /_resolv.conf"
Expand Down

0 comments on commit 14ddf45

Please sign in to comment.