From 44f2b63262d5d2d5eb83080bc1ceacba545b62f7 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Tue, 14 Apr 2020 13:18:05 +0200 Subject: [PATCH] F #196: Force recontextualization on NIC detach --- src/lib/udev/rules.d/65-context.rules##apk.one | 11 ++++++++++- src/lib/udev/rules.d/65-context.rules##deb.one | 12 +++++++++++- .../udev/rules.d/65-context.rules##rpm.systemd.one | 11 ++++++++++- src/lib/udev/rules.d/65-context.rules##rpm.sysv.one | 11 ++++++++++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/lib/udev/rules.d/65-context.rules##apk.one b/src/lib/udev/rules.d/65-context.rules##apk.one index 6da454a..4aae048 100644 --- a/src/lib/udev/rules.d/65-context.rules##apk.one +++ b/src/lib/udev/rules.d/65-context.rules##apk.one @@ -1,7 +1,16 @@ -# On NIC hogplug the delayed reconfiguration is triggered. +# NIC detach workaround for recontextualization on OpenNebula < 5.10.3 +# https://github.com/OpenNebula/one/issues/4130 +# https://github.com/OpenNebula/one/issues/4194 +SUBSYSTEM=="net", ACTION=="remove", \ + RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" + +# On NIC hotplug the delayed reconfiguration is triggered. SUBSYSTEM=="net", ACTION=="add", \ RUN+="/sbin/service one-context-reconfigure-delayed restart" +SUBSYSTEM=="net", ACTION=="remove", \ + RUN+="/sbin/service one-context-reconfigure-delayed restart" + # On CONTEXT CD-ROM change the immediate reconfiguration is triggered. SUBSYSTEM=="block", ACTION=="change", \ ENV{ID_CDROM}=="1", \ diff --git a/src/lib/udev/rules.d/65-context.rules##deb.one b/src/lib/udev/rules.d/65-context.rules##deb.one index 52c6f8e..603f945 100644 --- a/src/lib/udev/rules.d/65-context.rules##deb.one +++ b/src/lib/udev/rules.d/65-context.rules##deb.one @@ -1,8 +1,18 @@ -# On NIC hogplug the delayed reconfiguration is triggered. +# NIC detach workaround for recontextualization on OpenNebula < 5.10.3 +# https://github.com/OpenNebula/one/issues/4130 +# https://github.com/OpenNebula/one/issues/4194 +SUBSYSTEM=="net", ACTION=="remove", \ + RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" + +# On NIC hotplug the delayed reconfiguration is triggered. SUBSYSTEM=="net", ACTION=="add", \ TAG+="systemd", ENV{SYSTEMD_WANTS}+="one-context-reconfigure-delayed.service", \ RUN+="/usr/bin/timeout 5 /usr/sbin/service one-context-reconfigure-delayed start" +SUBSYSTEM=="net", ACTION=="remove", \ + TAG+="systemd", ENV{SYSTEMD_WANTS}+="one-context-reconfigure-delayed.service", \ + RUN+="/usr/bin/timeout 5 /usr/sbin/service one-context-reconfigure-delayed start" + # When CONTEXT CD-ROM is changed, it generates 2 events. This rule takes # every second event and triggers systemd service one-context-reconfigure. # This service also stops any existing delayed reconfiguration. diff --git a/src/lib/udev/rules.d/65-context.rules##rpm.systemd.one b/src/lib/udev/rules.d/65-context.rules##rpm.systemd.one index 76f3aea..90698e0 100644 --- a/src/lib/udev/rules.d/65-context.rules##rpm.systemd.one +++ b/src/lib/udev/rules.d/65-context.rules##rpm.systemd.one @@ -1,7 +1,16 @@ -# On NIC hogplug the delayed reconfiguration is triggered. +# NIC detach workaround for recontextualization on OpenNebula < 5.10.3 +# https://github.com/OpenNebula/one/issues/4130 +# https://github.com/OpenNebula/one/issues/4194 +SUBSYSTEM=="net", ACTION=="remove", \ + RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" + +# On NIC hotplug the delayed reconfiguration is triggered. SUBSYSTEM=="net", ACTION=="add", \ TAG+="systemd", ENV{SYSTEMD_WANTS}+="one-context-reconfigure-delayed.service" +SUBSYSTEM=="net", ACTION=="remove", \ + RUN+="/bin/systemctl --no-block start one-context-reconfigure-delayed.service" + # When CONTEXT CD-ROM is changed, it generates 2 events. This rule takes # every second event and triggers systemd service one-context-reconfigure. # This service also stops any existing delayed reconfiguration. diff --git a/src/lib/udev/rules.d/65-context.rules##rpm.sysv.one b/src/lib/udev/rules.d/65-context.rules##rpm.sysv.one index fae9e08..b8eeefe 100644 --- a/src/lib/udev/rules.d/65-context.rules##rpm.sysv.one +++ b/src/lib/udev/rules.d/65-context.rules##rpm.sysv.one @@ -1,7 +1,16 @@ -# On NIC hogplug the delayed reconfiguration is triggered. +# NIC detach workaround for recontextualization on OpenNebula < 5.10.3 +# https://github.com/OpenNebula/one/issues/4130 +# https://github.com/OpenNebula/one/issues/4194 +SUBSYSTEM=="net", ACTION=="remove", \ + RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" + +# On NIC hotplug the delayed reconfiguration is triggered. SUBSYSTEM=="net", ACTION=="add", \ RUN+="/sbin/service one-context-reconfigure-delayed start" +SUBSYSTEM=="net", ACTION=="remove", \ + RUN+="/sbin/service one-context-reconfigure-delayed start" + # Handle disk resize SUBSYSTEM=="block", ACTION=="change", \ ENV{RESIZE}=="1", \