Fix invalid patch alarm on unlocked AIO-SX

When an AIO-SX is unlocked, the patching and unified
software management systems were sharing a flag file
to indicate if the system had encountered a patch failure.

The flag was being incorrectly set by the unified software
management system.

This fixes the code that was setting of the flag, and also
renames the flag in the unified software management system.

Test Plan:
  PASS: Tox
  PASS: build component
  PASS: Boostrap/Unlock AIO-SX (no alarms)
  
Story: 2010676
Task: 48024
Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I681a641f563e851d3f4dc4d5a63b74526dd77892
This commit is contained in:
Al Bailey 2023-05-16 14:07:12 +00:00 committed by Al Bailey
parent e14546dbcc
commit a58c23ca01
2 changed files with 37 additions and 36 deletions

View File

@ -24,8 +24,9 @@ NAME=$(basename $0)
. /etc/platform/platform.conf . /etc/platform/platform.conf
logfile=/var/log/software.log logfile=/var/log/software.log
patch_failed_file=/var/run/patch_install_failed software_install_failed_file=/var/run/software_install_failed
patched_during_init=/etc/software/.patched_during_init software_updated_during_init_file=/etc/software/.software_updated_during_init
node_is_software_updated_rr_file=/var/run/node_is_software_updated_rr
# if the system has never been bootstrapped, system_mode is not set # if the system has never been bootstrapped, system_mode is not set
# treat a non bootstrapped system like it is simplex # treat a non bootstrapped system like it is simplex
@ -38,26 +39,26 @@ function LOG_TO_FILE {
echo "`date "+%FT%T.%3N"`: $NAME: $*" >> $logfile echo "`date "+%FT%T.%3N"`: $NAME: $*" >> $logfile
} }
function check_for_rr_patch { function check_for_rr_software_update {
if [ -f /var/run/node_is_patched_rr ]; then if [ -f ${node_is_software_updated_rr_file} ]; then
if [ ! -f ${patched_during_init} ]; then if [ ! -f ${software_updated_during_init_file} ]; then
echo echo
echo "Node has been patched and requires an immediate reboot." echo "Node has had its software updated and requires an immediate reboot."
echo echo
LOG_TO_FILE "Node has been patched, with reboot-required flag set. Rebooting" LOG_TO_FILE "Node has had its software updated, with reboot-required flag set. Rebooting"
touch ${patched_during_init} touch ${software_updated_during_init_file}
/sbin/reboot /sbin/reboot
else else
echo echo
echo "Node has been patched during init a second consecutive time. Skipping reboot due to possible error" echo "Node has had its software updated during init a second consecutive time. Skipping reboot due to possible error"
echo echo
LOG_TO_FILE "Node has been patched during init a second consecutive time. Skipping reboot due to possible error" LOG_TO_FILE "Node has had its software updated during init a second consecutive time. Skipping reboot due to possible error"
touch ${patch_failed_file} touch ${software_install_failed_file}
rm -f ${patched_during_init} rm -f ${software_updated_during_init_file}
exit 1 exit 1
fi fi
else else
rm -f ${patched_during_init} rm -f ${software_updated_during_init_file}
fi fi
} }
@ -95,7 +96,7 @@ fi
# For AIO-SX, abort if config is not yet applied and this is running in init # For AIO-SX, abort if config is not yet applied and this is running in init
if [ "${system_mode}" = "simplex" -a ! -f ${INITIAL_CONTROLLER_CONFIG_COMPLETE} -a "$1" = "start" ]; then if [ "${system_mode}" = "simplex" -a ! -f ${INITIAL_CONTROLLER_CONFIG_COMPLETE} -a "$1" = "start" ]; then
LOG_TO_FILE "Config is not yet applied. Skipping init patching" LOG_TO_FILE "Config is not yet applied. Skipping init software"
exit 0 exit 0
fi fi
@ -127,17 +128,17 @@ case "$1" in
start) start)
if [ "${system_mode}" = "simplex" ]; then if [ "${system_mode}" = "simplex" ]; then
# On a simplex CPE, we need to launch the http server first, # On a simplex CPE, we need to launch the http server first,
# before we can do the patch installation # before we can do the software installation
LOG_TO_FILE "***** Launching lighttpd *****" LOG_TO_FILE "***** Launching lighttpd *****"
/etc/init.d/lighttpd start /etc/init.d/lighttpd start
LOG_TO_FILE "***** Starting patch operation *****" LOG_TO_FILE "***** Starting software operation *****"
/usr/sbin/software-agent --install 2>>$logfile /usr/bin/software-agent --install 2>>$logfile
if [ -f ${patch_failed_file} ]; then if [ -f ${software_install_failed_file} ]; then
RC=1 RC=1
LOG_TO_FILE "***** Patch operation failed *****" LOG_TO_FILE "***** Software operation failed *****"
fi fi
LOG_TO_FILE "***** Finished patch operation *****" LOG_TO_FILE "***** Finished software operation *****"
LOG_TO_FILE "***** Shutting down lighttpd *****" LOG_TO_FILE "***** Shutting down lighttpd *****"
/etc/init.d/lighttpd stop /etc/init.d/lighttpd stop
@ -148,28 +149,28 @@ case "$1" in
exit 1 exit 1
fi fi
LOG_TO_FILE "***** Starting patch operation *****" LOG_TO_FILE "***** Starting software operation *****"
/usr/sbin/software-agent --install 2>>$logfile /usr/bin/software-agent --install 2>>$logfile
if [ -f ${patch_failed_file} ]; then if [ -f ${software_install_failed_file} ]; then
RC=1 RC=1
LOG_TO_FILE "***** Patch operation failed *****" LOG_TO_FILE "***** Software operation failed *****"
fi fi
LOG_TO_FILE "***** Finished patch operation *****" LOG_TO_FILE "***** Finished software operation *****"
fi fi
check_for_rr_patch check_for_rr_software_update
;; ;;
stop) stop)
# Nothing to do here # Nothing to do here
;; ;;
restart) restart)
LOG_TO_FILE "***** Starting patch operation *****" LOG_TO_FILE "***** Starting software operation *****"
/usr/sbin/software-agent --install 2>>$logfile /usr/bin/software-agent --install 2>>$logfile
if [ -f ${patch_failed_file} ]; then if [ -f ${software_install_failed_file} ]; then
RC=1 RC=1
LOG_TO_FILE "***** Patch operation failed *****" LOG_TO_FILE "***** Software operation failed *****"
fi fi
LOG_TO_FILE "***** Finished patch operation *****" LOG_TO_FILE "***** Finished software operation *****"
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|restart}"

View File

@ -34,9 +34,9 @@ pidfile_path = "/var/run/software_agent.pid"
agent_running_after_reboot_flag = \ agent_running_after_reboot_flag = \
"/var/run/software_agent_running_after_reboot" "/var/run/software_agent_running_after_reboot"
node_is_patched_file = "/var/run/node_is_patched" node_is_patched_file = "/var/run/node_is_patched"
node_is_patched_rr_file = "/var/run/node_is_patched_rr" node_is_software_updated_rr_file = "/var/run/node_is_software_updated_rr"
patch_installing_file = "/var/run/patch_installing" patch_installing_file = "/var/run/patch_installing"
patch_failed_file = "/var/run/patch_install_failed" patch_failed_file = "/var/run/software_install_failed"
node_is_locked_file = "/var/run/.node_locked" node_is_locked_file = "/var/run/.node_locked"
ostree_pull_completed_deployment_pending_file = \ ostree_pull_completed_deployment_pending_file = \
"/var/run/ostree_pull_completed_deployment_pending" "/var/run/ostree_pull_completed_deployment_pending"
@ -258,7 +258,7 @@ class PatchMessageAgentInstallReq(messages.PatchMessage):
resp = PatchMessageAgentInstallResp() resp = PatchMessageAgentInstallResp()
if not self.force: if not self.force:
setflag(node_is_patched_rr_file) setflag(node_is_software_updated_rr_file)
if not os.path.exists(node_is_locked_file): if not os.path.exists(node_is_locked_file):
if self.force: if self.force:
@ -489,11 +489,11 @@ class PatchAgent(PatchService):
if verbose_to_stdout: if verbose_to_stdout:
print("This node has been patched.") print("This node has been patched.")
if os.path.exists(node_is_patched_rr_file): if os.path.exists(node_is_software_updated_rr_file):
LOG.info("Reboot is required. Skipping patch-scripts") LOG.info("Reboot is required. Skipping patch-scripts")
elif disallow_insvc_patch: elif disallow_insvc_patch:
LOG.info("Disallowing patch-scripts. Treating as reboot-required") LOG.info("Disallowing patch-scripts. Treating as reboot-required")
setflag(node_is_patched_rr_file) setflag(node_is_software_updated_rr_file)
else: else:
LOG.info("Mounting the new deployment") LOG.info("Mounting the new deployment")
try: try: