From 528e5610487fe6168c78c1ff05644e17fc29a419 Mon Sep 17 00:00:00 2001 From: Yoann Congal Date: Fri, 13 Dec 2024 17:22:50 +0100 Subject: [PATCH] debian_hypervisor: synchronize team0_x port state with OVS On hypervisor shutdown, OVS is stopped a long time before the team0_x ports are shutdown as well. In the meantime: * The switching done by OVS is stopped * The corosync totem stops circulating and nodes are disconnected from the pacemake cluster which leads to resources being stopped. * After a while, RTSP detects this and change ports configuration to avoid the shutdown node and corosync/pacemaker start back with the left nodes. To avoid this, use systemd services to shutdown team0_x ports as soon as OVS is stopped to signal RTSP to change the configuration "instantly" and thus, avoid the corosync totem timeout. Signed-off-by: Yoann Congal --- .../debian_hypervisor/files/team0_x@.service | 20 +++++++++++++++++++ roles/debian_hypervisor/tasks/main.yml | 10 +++++++++- .../templates/ovs-vswitchd_override.conf.j2 | 4 ++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 roles/debian_hypervisor/files/team0_x@.service diff --git a/roles/debian_hypervisor/files/team0_x@.service b/roles/debian_hypervisor/files/team0_x@.service new file mode 100644 index 000000000..fb8fceed6 --- /dev/null +++ b/roles/debian_hypervisor/files/team0_x@.service @@ -0,0 +1,20 @@ +# Systemd unit wrapping around team0_* ports. +# This can be used to synchronize ports link state with the service that use +# them. + +[Unit] +After=network.target +DefaultDependencies=false +Conflicts=shutdown.target +Before=shutdown.target +StopWhenUnneeded=true + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=networkctl up %i +ExecStop=networkctl down %i + +[Install] +# empty: This unit must be activated via Wants/Requires of other units that need +# it diff --git a/roles/debian_hypervisor/tasks/main.yml b/roles/debian_hypervisor/tasks/main.yml index 5c1d2f202..4a3a499c1 100644 --- a/roles/debian_hypervisor/tasks/main.yml +++ b/roles/debian_hypervisor/tasks/main.yml @@ -210,9 +210,17 @@ group: root mode: 0644 register: ovsvswitchd +- name: Copy team0_x@.service file + ansible.builtin.copy: + src: team0_x@.service + dest: /etc/systemd/system/team0_x@.service + owner: root + group: root + mode: 0644 + register: team0_x_service - name: Restart ovs-vswitchd ansible.builtin.systemd: state: restarted daemon_reload: yes name: ovs-vswitchd - when: ovsvswitchd.changed + when: ovsvswitchd.changed or team0_x_service.changed diff --git a/roles/debian_hypervisor/templates/ovs-vswitchd_override.conf.j2 b/roles/debian_hypervisor/templates/ovs-vswitchd_override.conf.j2 index 11fdc19e3..bf480c5e0 100644 --- a/roles/debian_hypervisor/templates/ovs-vswitchd_override.conf.j2 +++ b/roles/debian_hypervisor/templates/ovs-vswitchd_override.conf.j2 @@ -1,2 +1,6 @@ [Service] Slice=ovs.slice + +[Unit] +Requires=team0_x@{{team0_0}}.service +Requires=team0_x@{{team0_1}}.service