Skip to content

Commit

Permalink
NAS-131186 / 24.10.0 / Add stop-alua to scst_util.sh and call before …
Browse files Browse the repository at this point in the history
…stopping middlewared (by bmeagherix) (#14536) (#14570)

* Add stop-alua to scst_util.sh and call before stopping middlewared

(cherry picked from commit 600a709)

* Increase fenced_start_loop max_retries to 4

This will help avoid fenced startup issues when a reboot is slow,
for example if a large number of iSCSI targets are present.

(cherry picked from commit 2b70882)

---------

Co-authored-by: Brian M <brian.meagher@ixsystems.com>
(cherry picked from commit 778e910)
  • Loading branch information
bugclerk committed Sep 24, 2024
1 parent b82cecf commit 3005d14
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
16 changes: 16 additions & 0 deletions debian/debian/ix-reboot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Exec TrueNAS reboot tasks

After=network.target middlewared.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=true
ExecStop=/usr/local/bin/scst_util.sh stop-alua
StandardOutput=null
StandardError=null
TimeoutStopSec=0

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions debian/debian/ix-shutdown.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ After=network.target middlewared.service
Type=oneshot
RemainAfterExit=yes
ExecStart=true
ExecStop=/usr/local/bin/scst_util.sh stop-alua
ExecStop=midclt call core.event_send system.shutdown ADDED
ExecStop=midclt call -job initshutdownscript.execute_init_tasks SHUTDOWN
StandardOutput=null
Expand Down
1 change: 1 addition & 0 deletions debian/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ override_dh_installsystemd:
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-netif
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-postinit
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-preinit
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-reboot
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-shutdown
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-ssh-keys
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-syncdisks
Expand Down
21 changes: 20 additions & 1 deletion src/freenas/usr/local/bin/scst_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,32 @@ force_close() {
wait
}

stop_alua() {
shopt -s nullglob

# Disable iSCSI
if [ -f /sys/kernel/scst_tgt/targets/iscsi/enabled ]; then
echo 0 > /sys/kernel/scst_tgt/targets/iscsi/enabled
fi

# Turn off any cluster_mode in parallel
for cm in /sys/kernel/scst_tgt/devices/*/cluster_mode ; do
echo 0 > "$cm" &
done
wait
}

case "$1" in
force-close)
force_close
rc=$?
;;
stop-alua)
stop_alua
rc=$?
;;
*)
echo "Usage: $0 {force-close}"
echo "Usage: $0 {force-close|stop-alua}"
exit 2
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/failover_/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _event(self, ifname, event):
elif event == 'BACKUP':
return self.run_call('failover.events.vrrp_backup', fobj, ifname, event)

def fenced_start_loop(self, max_retries=3):
def fenced_start_loop(self, max_retries=4):
# When active node is rebooted administratively from shell, the
# fenced process will continue running on the node until systemd
# finishes terminating services and actually reboots. Hence, we may
Expand Down

0 comments on commit 3005d14

Please sign in to comment.