Skip to content

Commit

Permalink
CP-51870: Refresh toolstack services (#6060)
Browse files Browse the repository at this point in the history
- varstored-guard Before: xenopsd.servcie->xenopsd-xc.service
- Remove unnecessary xenopsd services
  * xenopsd
  * xenopsd-xenlight
  * xenopsd-simulator
  * xenopsd-libvirt
- Reorder services to stop/start
  * forkexecd: does not depends on others, move to last
  * xenopsd-xc After xcp-rrdd. so it needs after xcp-rrdd-*

Note: the for loop reverse the TO_RESTART order
  • Loading branch information
robhoes authored Oct 30, 2024
2 parents 864ecdd + d157db0 commit a767100
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 19 deletions.
1 change: 1 addition & 0 deletions python3/perfmon/perfmon.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=Performance monitoring/alarm generation daemon
After=xapi.service
Wants=xapi.service
PartOf=toolstack.target

[Service]
EnvironmentFile=-/etc/sysconfig/perfmon
Expand Down
3 changes: 3 additions & 0 deletions scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,6 @@ install:
$(IDATA) mail-languages/ja-JP.json $(DESTDIR)/etc/xapi.d/mail-languages
# uefi
mkdir -p $(DESTDIR)/etc/xapi.d/efi-clone

# toolstack.target to manage toolstack services as a group
$(IDATA) toolstack.target $(DESTDIR)/usr/lib/systemd/system/toolstack.target
27 changes: 27 additions & 0 deletions scripts/toolstack.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[Unit]
Description=toolstack Target to manage toolstack service restart
# wants to start following services when run `systemctl start toolstack.target`
# Note: `Wants` is used here instead of `Requires`, `Requires` will stop/restart
# whole toolstack.target on any service stop/restart
Wants=xapi.service
Wants=message-switch.service
Wants=forkexecd.service
Wants=perfmon.service
Wants=v6d.service
Wants=xcp-rrdd-iostat.service
Wants=xcp-rrdd-squeezed.service
Wants=xcp-rrdd-netdev.service
Wants=xcp-rrdd-dcmi.service
Wants=xcp-rrdd-cpu.service
Wants=xcp-rrdd-xenpm.service
Wants=xcp-rrdd-gpumon.service
Wants=xcp-rrdd.service
Wants=xcp-networkd.service
Wants=xenopsd-xc.service
Wants=squeezed.service
Wants=xapi-storage-script.service
Wants=xapi-clusterd.service
Wants=varstored-guard.service

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion scripts/varstored-guard.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Description=Varstored XAPI socket deprivileging daemon
Documentation=man:varstored-guard(1)
After=message-switch.service syslog.target
Before=xapi-domains.service xenopsd.service
Before=xapi-domains.service xenopsd-xc.service
Wants=message-switch.service syslog.target
PartOf=toolstack.target

[Service]
Type=simple
Expand Down
1 change: 1 addition & 0 deletions scripts/xapi.service
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ After=xcp-rrdd.service
After=xenopsd-xc.service
After=xenstored.service
After[email protected]
PartOf=toolstack.target

Conflicts=shutdown.target

Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-networkd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Description=XCP networking daemon
Documentation=man:xcp-networkd(1)
After=forkexecd.service message-switch.service syslog.target
Wants=forkexecd.service message-switch.service syslog.target
PartOf=toolstack.target

[Service]
Type=notify
Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-rrdd-cpu.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=XCP RRD daemon CPU plugin
After=xcp-rrdd.service
Requires=xcp-rrdd.service
PartOf=toolstack.target

[Service]
ExecStart=/opt/xensource/libexec/xcp-rrdd-plugins/xcp-rrdd-cpu
Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-rrdd-dcmi.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=XCP RRD daemon IPMI DCMI power plugin
After=xcp-rrdd.service
Requires=xcp-rrdd.service
PartOf=toolstack.target

[Service]
ExecStart=/opt/xensource/libexec/xcp-rrdd-plugins/xcp-rrdd-dcmi
Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-rrdd-iostat.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=XCP RRD daemon iostat plugin
After=xcp-rrdd.service
Requires=xcp-rrdd.service
PartOf=toolstack.target

[Service]
ExecStart=/opt/xensource/libexec/xcp-rrdd-plugins/xcp-rrdd-iostat
Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-rrdd-netdev.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=XCP RRD daemon network plugin
After=xcp-rrdd.service
Requires=xcp-rrdd.service
PartOf=toolstack.target

[Service]
ExecStart=/opt/xensource/libexec/xcp-rrdd-plugins/xcp-rrdd-netdev
Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-rrdd-squeezed.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=XCP RRD daemon squeezed plugin
After=xcp-rrdd.service
Requires=xcp-rrdd.service
PartOf=toolstack.target

[Service]
ExecStart=/opt/xensource/libexec/xcp-rrdd-plugins/xcp-rrdd-squeezed
Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-rrdd-xenpm.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=XCP RRD daemon xenpm plugin
After=xcp-rrdd.service
Requires=xcp-rrdd.service
PartOf=toolstack.target

[Service]
ExecStart=/opt/xensource/libexec/xcp-rrdd-plugins/xcp-rrdd-xenpm
Expand Down
1 change: 1 addition & 0 deletions scripts/xcp-rrdd.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description=XCP RRD daemon
After=forkexecd.service xenstored.service message-switch.service syslog.target
Wants=forkexecd.service xenstored.service message-switch.service syslog.target
PartOf=toolstack.target

[Service]
Type=notify
Expand Down
32 changes: 14 additions & 18 deletions scripts/xe-toolstack-restart
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ echo "Executing $FILENAME"

POOLCONF=`cat @ETCXENDIR@/pool.conf`
if [ $POOLCONF == "master" ]; then MPATHALERT="mpathalert"; else MPATHALERT=""; fi
SERVICES="message-switch perfmon v6d xenopsd xenopsd-xc xenopsd-xenlight
xenopsd-simulator xenopsd-libvirt xcp-rrdd-iostat xcp-rrdd-squeezed
xcp-rrdd-netdev xcp-rrdd-cpu
xcp-rrdd-xenpm xcp-rrdd-gpumon xcp-rrdd xcp-networkd squeezed forkexecd
$MPATHALERT xapi-storage-script xapi-clusterd varstored-guard"

tmp_file=$(mktemp --suffix="xe-toolstack-restart")
systemctl stop stunnel@xapi > $tmp_file 2>&1
Expand All @@ -43,22 +38,23 @@ if [[ $kill_stunnel_exit_code != 0 ]]; then
fi
rm -f $tmp_file

TO_RESTART=""
for svc in $SERVICES ; do
# restart services only if systemd said they were enabled
systemctl is-enabled $svc >/dev/null 2>&1
set -e

if [ $? -eq 0 ] ; then
TO_RESTART="$svc $TO_RESTART"
fi
done
systemctl stop xapi
systemctl stop ${TO_RESTART}
systemctl restart $MPATHALERT toolstack.target

set -e
# Check the status of toolstack services
for service in $(systemctl list-dependencies --plain --no-pager toolstack.target); do
# During system bootup, xcp-rrdd-dcmi.service often fail as
# `ipmitool dcmi discover` discover nothing, just ignore it for now
if [ "$service" == "xcp-rrdd-dcmi.service" ]; then
continue
fi

systemctl start ${TO_RESTART}
systemctl start xapi
if ! systemctl is-active --quiet "$service"; then
echo "$service failed to restart, $(systemctl status $service)"
exit 1
fi
done

rm -f $LOCKFILE
echo "done."
Expand Down

0 comments on commit a767100

Please sign in to comment.