Eric MacDonald 4074c6c25d Move the mtce /etc/mtc/tmp/.node_locked flag file out of /etc
When the mtcAgent locks a node, it commands the mtcClient to create a
persistent .node_locked flag file at /etc/mtc/tmp/.node_locked.
Conversely, when the node is unlocked, the mtcAgent commands the
mtcClient to remove this flag file.

However, an issue arises where an unlocked node may still have the
.node_locked file present after an upgrade-rollback or patch-removal
operation.

The issue occurs because the OSTree upgrade deployment process runs
while the node is locked. During this process, OSTree takes a snapshot
of the /etc directory, which includes the .node_locked file.

Even if the file is later removed by maintenance actions, after deploy
but before reboot, OSTree restores it from the snapshot resulting in
the reinstatement of the .node_locked file on an unlocked node.

To eliminate this file management conflict, this update moves the
persistent .node_locked flag file to a location outside of OSTree's
management, specifically to /var/persist/mtc/.node_locked.

The directory name 'persist' was chosen to clearly indicate that the
files in this directory are intended to persist across reboots.

This update also fixed a post install script logging error trying
to rename the hwclock.sh.<init>.bak file with one already present.

Test Plan:

PASS: Verify the creation of the new /var/persist/mtc directory.
PASS: Verify any files under this directory persist over reboot.
PASS: Verify proper management of the node locked file over upgrade
      and rollback.
PASS: Install a AIO DX and verify the node locked file management.
PASS: Verify AIO DX upgrade from MR2PLUS to 24.09 master.
PASS: Install a Standard DX System with 1 worker and 2 storage and
      verify the node locked file management over and following an
      upgrade from MR2PLUS to 24.09 master.
PASS: Verify obsoleted /etc/mtc/tmp/.node_locked file is auto removed
      by both package install and over a mtcClient startup/restart.
PASS: Verify /etc/mtc/tmp dir remains.
PASS: Verify mtce debian package installs without error or warning.

Closes-Bug: 2095212
Change-Id: I3431abfef74c678fbeaa149bf6ac29ee254be111
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
2025-02-06 16:54:33 +00:00

174 lines
7.6 KiB
Makefile

#!/usr/bin/make -f
# export DH_VERBOSE = 1
export ROOT = debian/tmp
export BINDIR = $(ROOT)/usr/local/bin
export LIBDIR = $(ROOT)/usr/lib
export MTCESHAREDIR = $(ROOT)/usr/share/mtce
export OCFPLATFORMDIR = $(ROOT)/usr/lib/ocf/resource.d/platform
export SBINDIR = $(ROOT)/usr/sbin
export LOCAL_SBINDIR = $(ROOT)/usr/local/sbin
export UNITDIR = $(ROOT)/lib/systemd/system
export PMONDIR = $(ROOT)/usr/share/starlingx/pmon.d
export SYSCONFDIR = $(ROOT)/etc
export BMCCONFDIR = $(SYSCONFDIR)/bmc/server_profiles.d
export COLLECTDIR = $(SYSCONFDIR)/collect.d
export INITDIR =$(SYSCONFDIR)/init.d
export LOGDIR = $(SYSCONFDIR)/logrotate.d
export SERVICESDIR = $(SYSCONFDIR)/services.d
export TMPFILESDIR = $(ROOT)/usr/lib/tmpfiles.d
export PERSISTDIR = $(ROOT)/var/persist
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export MAJOR = $(shell echo $(DEB_VERSION) | cut -d. -f1)
export MINOR = $(shell echo $(shell echo $(DEB_VERSION) | cut -d. -f2) | cut -d- -f1)
%:
dh $@
override_dh_auto_install:
# Resource agent files
install -m 755 -d $(SYSCONFDIR)
install -m 755 -d $(SYSCONFDIR)/mtc/tmp
install -m 755 -d $(PERSISTDIR)/mtc
install -m 755 -d $(OCFPLATFORMDIR)
install -m 755 -p -D scripts/mtcAgent $(OCFPLATFORMDIR)/mtcAgent
install -m 755 -p -D hwmon/scripts/ocf/hwmon $(OCFPLATFORMDIR)/hwmon
# Configuration files
install -m 600 -p -D scripts/mtc.ini $(SYSCONFDIR)/mtc.ini
install -m 600 -p -D scripts/crash-dump-manager_envfile $(SYSCONFDIR)/default/crash-dump-manager
install -m 600 -p -D scripts/mtc.conf $(SYSCONFDIR)/mtc.conf
install -m 600 -p -D fsmon/scripts/fsmond.conf $(SYSCONFDIR)/mtc/fsmond.conf
install -m 600 -p -D hwmon/scripts/hwmond.conf $(SYSCONFDIR)/mtc/hwmond.conf
install -m 600 -p -D pmon/scripts/pmond.conf $(SYSCONFDIR)/mtc/pmond.conf
install -m 600 -p -D lmon/scripts/lmond.conf $(SYSCONFDIR)/mtc/lmond.conf
install -m 600 -p -D hostw/scripts/hostwd.conf $(SYSCONFDIR)/mtc/hostwd.conf
install -m 600 -p -D scripts/tmpfiles.conf $(TMPFILESDIR)/mtc.conf
install -m 755 -d $(BMCCONFDIR)
install -m 644 -p -D scripts/sensor_hp360_v1_ilo_v4.profile $(BMCCONFDIR)/sensor_hp360_v1_ilo_v4.profile
install -m 644 -p -D scripts/sensor_hp380_v1_ilo_v4.profile $(BMCCONFDIR)/sensor_hp380_v1_ilo_v4.profile
install -m 644 -p -D scripts/sensor_quanta_v1_ilo_v4.profile $(BMCCONFDIR)/sensor_quanta_v1_ilo_v4.profile
# Binaries
install -m 755 -d $(BINDIR)
install -m 700 -p -D maintenance/mtcAgent $(BINDIR)/mtcAgent
install -m 700 -p -D maintenance/mtcClient $(BINDIR)/mtcClient
install -m 700 -p -D heartbeat/hbsAgent $(BINDIR)/hbsAgent
install -m 700 -p -D heartbeat/hbsClient $(BINDIR)/hbsClient
install -m 700 -p -D pmon/pmond $(BINDIR)/pmond
install -m 700 -p -D lmon/lmond $(BINDIR)/lmond
install -m 700 -p -D hostw/hostwd $(BINDIR)/hostwd
install -m 700 -p -D fsmon/fsmond $(BINDIR)/fsmond
install -m 700 -p -D hwmon/hwmond $(BINDIR)/hwmond
install -m 700 -p -D mtclog/mtclogd $(BINDIR)/mtclogd
install -m 700 -p -D alarm/mtcalarmd $(BINDIR)/mtcalarmd
install -m 700 -p -D scripts/wipedisk $(BINDIR)/wipedisk
install -m 755 -d $(SBINDIR)
install -m 700 -p -D fsync/fsync $(SBINDIR)/fsync
install -m 755 -d $(SBINDIR)
install -m 755 -p -D scripts/crash-dump-manager $(SBINDIR)/crash-dump-manager
install -m 700 -p -D pmon/scripts/pmon-restart $(LOCAL_SBINDIR)/pmon-restart
install -m 700 -p -D pmon/scripts/pmon-start $(LOCAL_SBINDIR)/pmon-start
install -m 700 -p -D pmon/scripts/pmon-stop $(LOCAL_SBINDIR)/pmon-stop
# init script files
install -m 755 -d $(INITDIR)
install -m 700 -p -D scripts/mtcClient $(INITDIR)/mtcClient
install -m 700 -p -D scripts/hbsClient $(INITDIR)/hbsClient
install -m 700 -p -D hwmon/scripts/lsb/hwmon $(INITDIR)/hwmon
install -m 700 -p -D fsmon/scripts/fsmon $(INITDIR)/fsmon
install -m 700 -p -D scripts/mtclog $(INITDIR)/mtclog
install -m 700 -p -D pmon/scripts/pmon $(INITDIR)/pmon
install -m 700 -p -D lmon/scripts/lmon $(INITDIR)/lmon
install -m 700 -p -D hostw/scripts/hostw $(INITDIR)/hostw
install -m 700 -p -D alarm/scripts/mtcalarm.init $(INITDIR)/mtcalarm
# Some files already exist in the system.
# We need to copy them to a generic location here and update them during
# a post install step.
install -m 755 -d $(MTCESHAREDIR)
install -m 755 -p -D scripts/hwclock.sh $(MTCESHAREDIR)/hwclock.sh
install -m 644 -p -D scripts/hwclock.service $(MTCESHAREDIR)/hwclock.service
# go enabled script
install -m 755 -p -D scripts/goenabled $(INITDIR)/goenabled
# Start/stop services test script
install -m 755 -d $(SERVICESDIR)
install -m 755 -d $(SERVICESDIR)/controller
install -m 755 -p -D scripts/mtcTest $(SERVICESDIR)/controller
install -m 755 -d $(SERVICESDIR)/storage
install -m 755 -p -D scripts/mtcTest $(SERVICESDIR)/storage
install -m 755 -d $(SERVICESDIR)/worker
install -m 755 -p -D scripts/mtcTest $(SERVICESDIR)/worker
install -m 755 -p -D scripts/runservices $(INITDIR)/runservices
# Test tools
install -m 755 -p -D scripts/dmemchk.sh $(SBINDIR)
# Process monitor config files
install -m 755 -d $(PMONDIR)
install -m 644 -p -D scripts/mtcClient.conf $(PMONDIR)/mtcClient.conf
install -m 644 -p -D scripts/hbsClient.conf $(PMONDIR)/hbsClient.conf
install -m 644 -p -D pmon/scripts/acpid.conf $(PMONDIR)/acpid.conf
install -m 644 -p -D pmon/scripts/sshd.conf $(PMONDIR)/sshd.conf
install -m 644 -p -D pmon/scripts/syslog-ng.conf $(PMONDIR)/syslog-ng.conf
install -m 644 -p -D pmon/scripts/sssd.conf $(PMONDIR)/sssd.conf
install -m 644 -p -D fsmon/scripts/fsmon.conf $(PMONDIR)/fsmon.conf
install -m 644 -p -D scripts/mtclogd.conf $(PMONDIR)/mtclogd.conf
install -m 644 -p -D alarm/scripts/mtcalarm.pmon.conf $(PMONDIR)/mtcalarm.conf
install -m 644 -p -D lmon/scripts/lmon.pmon.conf $(PMONDIR)/lmon.conf
# Log rotation
install -m 755 -d $(LOGDIR)
install -m 644 -p -D scripts/crashdump.logrotate $(LOGDIR)/crashdump.logrotate
install -m 644 -p -D scripts/mtce.logrotate $(LOGDIR)/mtce.logrotate
install -m 644 -p -D hostw/scripts/hostw.logrotate $(LOGDIR)/hostw.logrotate
install -m 644 -p -D pmon/scripts/pmon.logrotate $(LOGDIR)/pmon.logrotate
install -m 644 -p -D lmon/scripts/lmon.logrotate $(LOGDIR)/lmon.logrotate
install -m 644 -p -D fsmon/scripts/fsmon.logrotate $(LOGDIR)/fsmon.logrotate
install -m 644 -p -D hwmon/scripts/hwmon.logrotate $(LOGDIR)/hwmon.logrotate
install -m 644 -p -D alarm/scripts/mtcalarm.logrotate $(LOGDIR)/mtcalarm.logrotate
# Collect scripts
install -m 755 -d $(COLLECTDIR)
install -m 755 -p -D scripts/collect_bmc.sh $(COLLECTDIR)/collect_bmc
# syslog configuration
install -m 644 -p -D scripts/mtce.syslog $(SYSCONFDIR)/syslog-ng/conf.d/mtce.conf
# Software development files
install -m 644 -p -D heartbeat/mtceHbsCluster.h $(ROOT)/usr/include/mtceHbsCluster.h
install -m 755 -d $(LIBDIR)
install -m 755 -p -D public/libamon.so.$(MAJOR) $(LIBDIR)/libamon.so.$(MAJOR)
cd $(LIBDIR) ; ln -s libamon.so.$(MAJOR) libamon.so.$(MAJOR).$(MINOR)
cd $(LIBDIR) ; ln -s libamon.so.$(MAJOR) libamon.so
# Volatile directories
install -m 755 -d $(ROOT)/var
install -m 755 -d $(ROOT)/var/run
# Presets
install -d $(SYSCONFDIR)/systemd/system-preset
install -m 544 scripts/55-crash-dump-manager.preset $(SYSCONFDIR)/systemd/system-preset
override_dh_installsystemd:
dh_installsystemd --name crash-dump-manager
dh_installsystemd --name fsmon
dh_installsystemd --name goenabled
dh_installsystemd --name hbsClient
dh_installsystemd --name hostw
dh_installsystemd --name hwclock
dh_installsystemd --name hwmon
dh_installsystemd --name lmon
dh_installsystemd --name mtcalarm
dh_installsystemd --name mtcClient
dh_installsystemd --name mtclog
dh_installsystemd --name pmon
dh_installsystemd --name runservices
override_dh_usrlocal:
echo "SKIPPING DH USRLOCAL"