Add systemd support to unified maintenance mode.
Was performed: * Unify main code and move system depended code into umm_svc.local * Modify packaging procedure Closes-Bug: #1525269 Change-Id: I04602b26f2a0b9b6d5ed3cd23f175bd54d1f2808
This commit is contained in:
parent
07abee63a7
commit
a51e6da7d1
|
@ -1 +0,0 @@
|
||||||
var/lib/umm/
|
|
|
@ -1,11 +1,3 @@
|
||||||
files/fuel-umm/issue.mm /etc/
|
files/fuel-umm/root/* /
|
||||||
files/fuel-umm/umm.conf /etc/
|
files/fuel-umm/ub14/* /usr/lib/umm/
|
||||||
files/fuel-umm/umm.sh /etc/profile.d/
|
files/fuel-umm/upstart/* /etc/init/
|
||||||
files/fuel-umm/umm /usr/bin/
|
|
||||||
files/fuel-umm/umm_svc /usr/lib/umm/
|
|
||||||
files/fuel-umm/umm_svc.u1404 /usr/lib/umm/
|
|
||||||
files/fuel-umm/umm_vars /usr/lib/umm/
|
|
||||||
files/fuel-umm/umm-br.conf /etc/init/
|
|
||||||
files/fuel-umm/umm-console.conf /etc/init/
|
|
||||||
files/fuel-umm/umm-run.conf /etc/init/
|
|
||||||
files/fuel-umm/umm-tr.conf /etc/init/
|
|
||||||
|
|
|
@ -1,36 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
/usr/lib/umm/umm-install
|
||||||
cat >/etc/init/rc-sysinit.override <<"EOF"
|
|
||||||
start on umm
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat >/etc/init/failsafe.override <<"EOF"
|
|
||||||
stop on static-network-up or starting rc-sysinit or starting umm
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat >/etc/init/umm.conf <<"EOF"
|
|
||||||
# umm - Openstak maiteenace mode.
|
|
||||||
#
|
|
||||||
|
|
||||||
description "Openstack maintenance mode"
|
|
||||||
author "pzhurba@mirantis.com"
|
|
||||||
|
|
||||||
start on (filesystem and static-network-up) or failsafe-boot
|
|
||||||
|
|
||||||
emits umm
|
|
||||||
|
|
||||||
script
|
|
||||||
[ -f /usr/lib/umm/umm_svc ] && /usr/lib/umm/umm_svc
|
|
||||||
initctl emit umm
|
|
||||||
end script
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat >/etc/grub.d/55_umm << "EOF"
|
|
||||||
if [ -f /etc/grub.d/10_linux ] ; then
|
|
||||||
/etc/grub.d/10_linux | sed -n -e '/menuentry.*{/,/}/p' | sed -e "s/menuentry\s*'[^']*' /menuentry 'Unified maintenance mode (UMM)' /" -e 's/\(^\s*linux\s.*\)/\1 umm/' -e '/}/,$d'; echo '}'
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x /etc/grub.d/55_umm
|
|
||||||
|
|
||||||
update-grub
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
rm -f /etc/init/rc-sysinit.override
|
rm -f /etc/init/rc-sysinit.override
|
||||||
rm -f /etc/init/failsafe.override
|
rm -f /etc/init/failsafe.override
|
||||||
rm -f /etc/init/umm.conf
|
rm -f /etc/init/umm.conf
|
||||||
rm -f /etc/grub.d/55_umm
|
rm -f /etc/grub.d/55_umm
|
||||||
update-grub
|
update-grub
|
|
@ -13,5 +13,4 @@ override_dh_install:
|
||||||
mv debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq-server-upstream
|
mv debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq-server-upstream
|
||||||
mv debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq-fuel debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq-server
|
mv debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq-fuel debian/fuel-ha-utils/usr/lib/ocf/resource.d/fuel/rabbitmq-server
|
||||||
mv debian/fuel-misc/usr/bin/logrotate debian/fuel-misc/usr/bin/fuel-logrotate
|
mv debian/fuel-misc/usr/bin/logrotate debian/fuel-misc/usr/bin/fuel-logrotate
|
||||||
mv debian/fuel-umm/usr/lib/umm/umm_svc.u1404 debian/fuel-umm/usr/lib/umm/umm_svc.local
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ "$1" == "add" ]] ; then
|
||||||
|
|
||||||
|
systemctl enable umm-br.service
|
||||||
|
systemctl enable umm-run.service
|
||||||
|
systemctl enable umm.service
|
||||||
|
systemctl enable umm-tr.service
|
||||||
|
|
||||||
|
cat >/etc/grub.d/55_umm << "EOF"
|
||||||
|
if [ -f /etc/grub.d/10_linux ] ; then
|
||||||
|
/etc/grub.d/10_linux | sed -n -e '/menuentry.*{/,/}/p' | sed -e "s/menuentry\s*'[^']*' /menuentry 'Unified maintenance mode (UMM)' /" -e 's/\(^\s*linux\s.*\)/\1 umm/' -e '/}/,$d'; echo '}'
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
chmod +x /etc/grub.d/55_umm
|
||||||
|
else
|
||||||
|
systemctl disable umm-br.service
|
||||||
|
systemctl disable umm-run.service
|
||||||
|
systemctl disable umm.service
|
||||||
|
systemctl disable umm-tr.service
|
||||||
|
rm -f /etc/grub.d/55_umm
|
||||||
|
fi
|
||||||
|
grub2-mkconfig >/boot/grub2/grub.cfg
|
|
@ -0,0 +1,42 @@
|
||||||
|
allowed_list="basic.target
|
||||||
|
firewalld.service
|
||||||
|
microcode.service
|
||||||
|
umm.service
|
||||||
|
umm-tr.service
|
||||||
|
umm-run.service
|
||||||
|
network.target
|
||||||
|
NetworkManager.service
|
||||||
|
sshd.service
|
||||||
|
sshd-keygen.service
|
||||||
|
systemd-readahead-done.timer
|
||||||
|
systemd-update-utmp-runlevel.service
|
||||||
|
dbus.service
|
||||||
|
network.service
|
||||||
|
"
|
||||||
|
|
||||||
|
cancel_job(){
|
||||||
|
|
||||||
|
if ! echo "$allowed_list" | grep -q "$2" ; then
|
||||||
|
if [[ "$1" != "No" ]] ; then
|
||||||
|
systemctl cancel $1 || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
umm-run(){
|
||||||
|
# systemctl list-jobs >/var/log/umm.log
|
||||||
|
[ -x /bin/plymouth quit] && /bin/plymouth quit || true
|
||||||
|
sleep 10
|
||||||
|
systemctl list-jobs | while read JI ; do
|
||||||
|
cancel_job $JI
|
||||||
|
done
|
||||||
|
systemctl start --no-block getty@tty2.service
|
||||||
|
}
|
||||||
|
|
||||||
|
umm-off(){
|
||||||
|
systemctl isolate default.target
|
||||||
|
}
|
||||||
|
|
||||||
|
umm-skip(){
|
||||||
|
return 0
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
if [ "z`umm status`" == "zumm" ] ; then
|
||||||
|
cat /etc/issue.mm
|
||||||
|
[ "$#" != "0" ] && echo "$@"
|
||||||
|
fi
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
. /usr/lib/umm/umm_vars
|
. /usr/lib/umm/umm_vars
|
||||||
|
. /usr/lib/umm/umm_svc.local
|
||||||
|
|
||||||
Usage(){
|
Usage(){
|
||||||
echo "Usage
|
echo "Usage
|
||||||
|
@ -63,6 +64,8 @@ else
|
||||||
rm $UMM_DATA/UMM_DRC.var
|
rm $UMM_DATA/UMM_DRC.var
|
||||||
sleep 1
|
sleep 1
|
||||||
reboot
|
reboot
|
||||||
|
else
|
||||||
|
umm-off
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
|
@ -0,0 +1,59 @@
|
||||||
|
#!/bin/bash
|
||||||
|
. /usr/lib/umm/umm_vars
|
||||||
|
[[ -x ${0}.local ]] && source ${0}.local
|
||||||
|
|
||||||
|
|
||||||
|
set_umm(){
|
||||||
|
echo umm >$UMM_FLAG
|
||||||
|
}
|
||||||
|
|
||||||
|
# check if UMM enabled and sckip processing any services
|
||||||
|
[[ "$UMM" == "yes" ]] || exit 0
|
||||||
|
|
||||||
|
if [[ "$1" == "timer" ]] ; then
|
||||||
|
sleep $(($COUNTER_RESET_TIME*60))
|
||||||
|
rm -f $UMM_DATA/UMM_DRC.var
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# gracefull shutdown restart processing
|
||||||
|
if [[ "$1" == "down" ]] ; then
|
||||||
|
rm -f $UMM_DATA/UMM_DRC.var
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run sceduled programm in maintenace mode
|
||||||
|
if [[ "$1" == "run" ]] ; then
|
||||||
|
if [[ -f "$UMM_DATA/UMM_CMD" && -f "$UMM_FLAG" ]] ; then
|
||||||
|
cmd=$(cat $UMM_DATA/UMM_CMD)
|
||||||
|
rm $UMM_DATA/UMM_CMD
|
||||||
|
$cmd &> $UMM_DATA/UMM_CMD.out || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# clean previos state
|
||||||
|
[[ -f $UMM_FLAG ]] && rm $UMM_FLAG
|
||||||
|
|
||||||
|
# check if umm enforsed parameter is present
|
||||||
|
if [[ -f $UMM_DATA/UMM_ENFORCED ]] ; then
|
||||||
|
set_umm
|
||||||
|
rm $UMM_DATA/UMM_ENFORCED
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if umm kernel parameter is present
|
||||||
|
for t in $(cat /proc/cmdline); do
|
||||||
|
[[ "$t" == "umm" ]] && set_umm
|
||||||
|
done
|
||||||
|
|
||||||
|
# check if dirty rebout count is reached
|
||||||
|
UMM_DRC=$((UMM_DRC+1))
|
||||||
|
echo "UMM_DRC=$UMM_DRC">$UMM_DATA/UMM_DRC.var
|
||||||
|
|
||||||
|
[[ ${UMM_DRC} -gt ${REBOOT_COUNT} ]] && set_umm
|
||||||
|
|
||||||
|
if [[ -f $UMM_FLAG ]] ; then
|
||||||
|
umm-run
|
||||||
|
else
|
||||||
|
umm-skip
|
||||||
|
fi
|
|
@ -0,0 +1,17 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Unified maintenance mode reset timer
|
||||||
|
After=umm.service
|
||||||
|
Requires=umm.service
|
||||||
|
Before=shutdown.target
|
||||||
|
Conflicts=shutdown.target
|
||||||
|
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/bin/true
|
||||||
|
ExecStop=/usr/lib/umm/umm_svc down
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Unified maintenance mode runner
|
||||||
|
After=umm.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/lib/umm/umm_svc run
|
||||||
|
Type=oneshot
|
||||||
|
TimeoutSec=0
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Unified maintenance mode reset timer
|
||||||
|
After=local-fs.target umm.service
|
||||||
|
Requires=local-fs.target umm.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/lib/umm/umm_svc timer
|
||||||
|
Type=oneshot
|
||||||
|
TimeoutSec=0
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Unified maintenance mode service
|
||||||
|
DefaultDependencies=no
|
||||||
|
Before=basic.target shutdown.target
|
||||||
|
After=local-fs.target sysinit.target sockets.target
|
||||||
|
Requires=local-fs.target sysinit.target sockets.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/lib/umm/umm_svc svc
|
||||||
|
ExecStartPost=-/bin/sh -c '/etc/profile.d/umm.sh "Console started on tty2"'
|
||||||
|
Type=oneshot
|
||||||
|
TimeoutSec=0
|
||||||
|
StandardInput=tty
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
|
@ -20,8 +20,7 @@ start on (filesystem and static-network-up) or failsafe-boot
|
||||||
emits umm
|
emits umm
|
||||||
|
|
||||||
script
|
script
|
||||||
[ -f /usr/lib/umm/umm_svc ] && /usr/lib/umm/umm_svc
|
[ -f /usr/lib/umm/umm_svc ] && /usr/lib/umm/umm_svc wait
|
||||||
initctl emit umm
|
|
||||||
end script
|
end script
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
umm-run(){
|
||||||
|
/sbin/initctl start ssh || true
|
||||||
|
cp /etc/issue.mm /dev/console
|
||||||
|
/sbin/initctl start umm-console
|
||||||
|
if /bin/plymouth --ping; then
|
||||||
|
/bin/plymouth hide-splash || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
umm-off(){
|
||||||
|
/sbin/initctl emit umm
|
||||||
|
}
|
||||||
|
|
||||||
|
umm-skip(){
|
||||||
|
/sbin/initctl emit umm
|
||||||
|
return 0
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
[ "z`umm status`" == "zumm" ] && cat /etc/issue.mm
|
|
|
@ -1,37 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
. /usr/lib/umm/umm_vars
|
|
||||||
|
|
||||||
# clean previos state
|
|
||||||
[ -f $UMM_FLAG ] && rm $UMM_FLAG
|
|
||||||
|
|
||||||
# check if UMM enabled
|
|
||||||
[ "$UMM" == "yes" ] || exit 0
|
|
||||||
|
|
||||||
|
|
||||||
if [ -f $UMM_DATA/UMM_ENFORCED ] ; then
|
|
||||||
echo umm >$UMM_FLAG
|
|
||||||
rm $UMM_DATA/UMM_ENFORCED
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check if umm kernel parameter is present
|
|
||||||
for t in $(cat /proc/cmdline); do
|
|
||||||
[ "$t" == "umm" ] && echo umm >$UMM_FLAG
|
|
||||||
done
|
|
||||||
|
|
||||||
# check if dirty rebout count is reached
|
|
||||||
UMM_DRC=$((UMM_DRC+1))
|
|
||||||
echo "UMM_DRC=$UMM_DRC">$UMM_DATA/UMM_DRC.var
|
|
||||||
[ ${UMM_DRC} -gt ${REBOOT_COUNT} ] && echo umm >$UMM_FLAG
|
|
||||||
|
|
||||||
initctl start umm-tr || true
|
|
||||||
|
|
||||||
|
|
||||||
if [ -f $UMM_FLAG ] ; then
|
|
||||||
[ -x ${0}.local ] && ${0}.local
|
|
||||||
initctl start umm-run || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
while [ -f $UMM_FLAG ] ; do sleep 1 ; done;
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
/sbin/initctl start ssh || true
|
|
||||||
cp /etc/issue.mm /dev/console
|
|
||||||
/sbin/initctl start umm-console
|
|
|
@ -128,23 +128,10 @@ install -m 0755 %{files_source}/fuel-migrate/fuel-migrate %{buildroot}/usr/bin/f
|
||||||
install -m 0644 %{files_source}/fuel-migrate/umm-mg.service %{buildroot}/etc/systemd/system/umm-mg.service
|
install -m 0644 %{files_source}/fuel-migrate/umm-mg.service %{buildroot}/etc/systemd/system/umm-mg.service
|
||||||
install -m 0644 %{files_source}/fuel-migrate/umm-mg.target %{buildroot}/etc/systemd/system/umm-mg.target
|
install -m 0644 %{files_source}/fuel-migrate/umm-mg.target %{buildroot}/etc/systemd/system/umm-mg.target
|
||||||
#UMM
|
#UMM
|
||||||
mkdir -p %{buildroot}/etc/init
|
mkdir -p %{buildroot}/usr/lib/systemd/system/
|
||||||
mkdir -p %{buildroot}/etc/profile.d/
|
cp -r %{files_source}/fuel-umm/root/* %{buildroot}/
|
||||||
mkdir -p %{buildroot}/usr/bin
|
cp -r %{files_source}/fuel-umm/systemd/* %{buildroot}/usr/lib/systemd/system/
|
||||||
mkdir -p %{buildroot}/usr/lib/umm
|
cp -r %{files_source}/fuel-umm/rh7/* %{buildroot}/usr/lib/umm/
|
||||||
mkdir -p %{buildroot}/var/lib/umm
|
|
||||||
install -m 0644 %{files_source}/fuel-umm/issue.mm %{buildroot}/etc/issue.mm
|
|
||||||
install -m 0644 %{files_source}/fuel-umm/umm.conf %{buildroot}/etc/umm.conf
|
|
||||||
install -m 0755 %{files_source}/fuel-umm/umm.sh %{buildroot}/etc/profile.d/umm.sh
|
|
||||||
install -m 0755 %{files_source}/fuel-umm/umm %{buildroot}/usr/bin/umm
|
|
||||||
install -m 0755 %{files_source}/fuel-umm/umm_svc %{buildroot}/usr/lib/umm/umm_svc
|
|
||||||
install -m 0755 %{files_source}/fuel-umm/umm_svc.rh6 %{buildroot}/usr/lib/umm/umm_svc.local
|
|
||||||
install -m 0755 %{files_source}/fuel-umm/umm_vars %{buildroot}/usr/lib/umm/umm_vars
|
|
||||||
install -m 0755 %{files_source}/fuel-umm/umm-install.rh6 %{buildroot}/usr/lib/umm/umm-install.rh6
|
|
||||||
install -m 0644 %{files_source}/fuel-umm/umm-br.conf %{buildroot}/etc/init/umm-br.conf
|
|
||||||
install -m 0644 %{files_source}/fuel-umm/umm-console.conf %{buildroot}/etc/init/umm-console.conf
|
|
||||||
install -m 0644 %{files_source}/fuel-umm/umm-run.conf %{buildroot}/etc/init/umm-run.conf
|
|
||||||
install -m 0644 %{files_source}/fuel-umm/umm-tr.conf %{buildroot}/etc/init/umm-tr.conf
|
|
||||||
|
|
||||||
|
|
||||||
%post -p /bin/bash
|
%post -p /bin/bash
|
||||||
|
@ -312,18 +299,19 @@ operations. Also node in MM state is reachable with ssh from network.
|
||||||
For further information go to:
|
For further information go to:
|
||||||
https://www.mirantis.com/products/mirantis-openstack-software/documentation/
|
https://www.mirantis.com/products/mirantis-openstack-software/documentation/
|
||||||
|
|
||||||
# %post -n fuel-umm
|
%post -n fuel-umm
|
||||||
# /usr/lib/umm/umm-install.rh6 add
|
/usr/lib/umm/umm-install add
|
||||||
# %preun -n fuel-umm
|
%preun -n fuel-umm
|
||||||
# /usr/lib/umm/umm-install.rh6 del
|
/usr/lib/umm/umm-install del
|
||||||
|
|
||||||
%files -n fuel-umm
|
%files -n fuel-umm
|
||||||
/etc/issue.mm
|
/etc/issue.mm
|
||||||
/etc/profile.d/umm.sh
|
/etc/profile.d/umm.sh
|
||||||
/etc/init/umm-*
|
#/etc/init/umm-*
|
||||||
|
/usr/lib/systemd/system/umm*
|
||||||
/usr/lib/umm/*
|
/usr/lib/umm/*
|
||||||
/usr/bin/umm
|
/usr/bin/umm
|
||||||
%dir /var/lib/umm
|
/var/lib/umm/.gitkeep
|
||||||
%config(noreplace) /etc/umm.conf
|
%config(noreplace) /etc/umm.conf
|
||||||
|
|
||||||
%package -n fuel-notify
|
%package -n fuel-notify
|
||||||
|
|
Loading…
Reference in New Issue