Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action] [PR:19583] [Static DNS] Optimize DNS configuration update during interface-config service restart (#19583) #19985

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading