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

[release-4.16] OCPBUGS-48283: Do not run resolv-prepender from NM dispatcher #4784

Open
wants to merge 1 commit into
base: release-4.16
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ contents:
mkdir -p /run/resolv-prepender
echo "IP4_DOMAINS=$IP4_DOMAINS" > /run/resolv-prepender/env.new
echo "IP6_DOMAINS=$IP6_DOMAINS" >> /run/resolv-prepender/env.new
# If we changed the environment, we should restart the service to pick up the
# new values. However, if the image hasn't been pulled successfully yet we can't
# restart the service or we may interrupt the pull and end up with a corrupt image.
# We're better off with incorrect search domains for a while than wedging the
# system with a bad image.
if ! diff -q /run/resolv-prepender/env /run/resolv-prepender/env.new && /usr/bin/podman image exists "{{ .Images.baremetalRuntimeCfgImage }}"; then
>&2 echo "NM resolv-prepender: Environment variable(s) changed. Restarting service."
systemctl is-active on-prem-resolv-prepender && systemctl kill on-prem-resolv-prepender

if ! diff -q /run/resolv-prepender/env /run/resolv-prepender/env.new; then
>&2 echo "NM resolv-prepender: Environment variable(s) changed. Systemd path unit will pick the change."
mv -f /run/resolv-prepender/env.new /run/resolv-prepender/env
fi
mv -f /run/resolv-prepender/env.new /run/resolv-prepender/env
systemctl start --no-block on-prem-resolv-prepender
}

export IP4_DOMAINS IP6_DOMAINS
Expand All @@ -34,7 +28,8 @@ contents:
# subsequent up&co. events as undesired.
#
# Given an overall Network Manager dispatcher timeout of 90 seconds, we are enforcing a slightly shorter
# timeout for the observed events.
# timeout for the observed events. It is not really required because all we do in this function is to write a file.
# We could get rid of this timeout completely, but it also does not cost much to keep it.
case "$STATUS" in
dns-change)
>&2 echo "NM resolv-prepender triggered by ${IFACE} ${STATUS}."
Expand All @@ -46,6 +41,7 @@ contents:
exit 1
fi
;;

up|dhcp4-change|dhcp6-change|reapply)
if [ ! -f "/run/networkmanager-dns-event-detected" ]; then
>&2 echo "NM resolv-prepender triggered by ${IFACE} ${STATUS}."
Expand All @@ -54,6 +50,7 @@ contents:
exit 1
fi
fi

# If $DHCP6_FQDN_FQDN is not empty and is not localhost.localdomain and static hostname was not already set
if [[ -n "$DHCP6_FQDN_FQDN" && "$DHCP6_FQDN_FQDN" != "localhost.localdomain" && "$DHCP6_FQDN_FQDN" =~ "." ]] ; then
STATIC_HOSTNAME="$(test ! -e /etc/hostname && echo -n || cat /etc/hostname | xargs)"
Expand All @@ -64,6 +61,7 @@ contents:
hostnamectl set-hostname --static --transient $DHCP6_FQDN_FQDN
fi
fi

if [[ "$STATUS" == "up" ]] && [[ $IFACE == "br-ex" ]]; then
touch /run/nodeip-configuration/br-ex-up
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contents: |
Description=Watches for changes in /var/run/NetworkManager/resolv.conf according to on-prem IPI needs
[Path]
PathModified=/var/run/NetworkManager/resolv.conf
PathModified=/run/resolv-prepender/env
Unit=on-prem-resolv-prepender.service
[Install]
WantedBy=multi-user.target