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>
This commit is contained in:
Eric MacDonald 2025-01-20 14:55:30 +00:00
parent 8d9a1384f2
commit 4074c6c25d
6 changed files with 29 additions and 5 deletions

View File

@ -106,7 +106,7 @@ void daemon_exit ( void );
#define CONFIG_PASS_FILE ((const char *)"/var/run/.config_pass")
#define CONFIG_FAIL_FILE ((const char *)"/var/run/.config_fail")
#define NODE_LOCKED_FILE ((const char *)"/var/run/.node_locked")
#define NODE_LOCKED_FILE_BACKUP ((const char *)"/etc/mtc/tmp/.node_locked")
#define NODE_LOCKED_FILE_BACKUP ((const char *)"/var/persist/mtc/.node_locked")
#define NODE_RESET_FILE ((const char *)"/var/run/.node_reset")
#define SMGMT_DEGRADED_FILE ((const char *)"/var/run/.sm_degraded")
#define SMGMT_UNHEALTHY_FILE ((const char *)"/var/run/.sm_node_unhealthy")

View File

@ -23,6 +23,7 @@ etc/services.d/storage/mtcTest
etc/services.d/worker/mtcTest
etc/syslog-ng/conf.d/mtce.conf
etc/systemd/system-preset/
usr/lib/tmpfiles.d/mtc.conf
usr/lib/ocf/resource.d/platform/mtcAgent
usr/local/bin/fsmond
usr/local/bin/hbsAgent

View File

@ -7,17 +7,24 @@ case "$1" in
configure)
# Replace the default hwclock.sh with our copy
if [ -e /etc/init.d/hwclock.sh ]; then
if [ -e /etc/init.d/hwclock.sh.dpkg-bak ]; then
rm -f /etc/init.d/hwclock.sh.dpkg-bak
fi
mv -f /etc/init.d/hwclock.sh /etc/init.d/hwclock.sh.dpkg-bak
fi
cp -a /usr/share/mtce/hwclock.sh /etc/init.d/hwclock.sh
# Replace the default hwclock.service with our copy
if [ -e /lib/systemd/system/hwclock.service ]; then
if [ -e /lib/systemd/system/hwclock.service.bak ]; then
rm -f /lib/systemd/system/hwclock.service.bak
fi
mv -f /lib/systemd/system/hwclock.service /lib/systemd/system/hwclock.service.bak
fi
cp -a /usr/share/mtce/hwclock.service /lib/systemd/system/hwclock.service
;;
*)
echo "mtce postinst called with an unknown argument \`$1'" >&2
echo "mtce postinst called with an unsupported argument \`$1'" >&2
exit 1
;;
esac

View File

@ -17,7 +17,8 @@ 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)
@ -28,8 +29,8 @@ export MINOR = $(shell echo $(shell echo $(DEB_VERSION) | cut -d. -f2) | cut -d-
override_dh_auto_install:
# Resource agent files
install -m 755 -d $(SYSCONFDIR)
install -m 755 -d $(SYSCONFDIR)/mtc
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
@ -43,7 +44,7 @@ override_dh_auto_install:
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

View File

@ -1439,6 +1439,17 @@ void daemon_service_run ( void )
}
}
/* Cleanup the old obsoleted persistent node locked file */
#define OBSOLETED_NODE_LOCKED_FILE_BACKUP ((const char *)"/etc/mtc/tmp/.node_locked")
if ( strcmp (NODE_LOCKED_FILE_BACKUP, OBSOLETED_NODE_LOCKED_FILE_BACKUP ) )
{
if ( daemon_is_file_present ( OBSOLETED_NODE_LOCKED_FILE_BACKUP ) )
{
ilog ("removing obsoleted %s file", OBSOLETED_NODE_LOCKED_FILE_BACKUP );
daemon_remove_file ( OBSOLETED_NODE_LOCKED_FILE_BACKUP );
}
}
/* If the mtcClient starts up and finds that its persistent node
* locked backup file is present then make sure the volatile one
* is also present. */

View File

@ -0,0 +1,4 @@
d /var/persist/mtc 755 root root
# For stx.11 only:
r /etc/mtc/tmp/.node_locked