Support for deploy scripts in RR patches

If a patch is reboot required, before reboot, it sets a flag:
agent_running_after_reboot_flag

When the host restarts, during the startup of the software agent, it
checks if this flag exists. If yes, it runs the post-install scripts.

TestPlan:
PASS: Deploy a RR patch with deploy scripts
PASS: Check in software.log if the scripts were executed

Story: 2010676
Task: 50591

Change-Id: Ie88d84849eda5f6c69779d99647c9836a7c9231b
Signed-off-by: Lindley Vieira <lindley.vieira@windriver.com>
This commit is contained in:
Lindley Vieira
2024-06-25 18:32:18 -03:00
parent cd36deda0e
commit 6eabc7312a

View File

@@ -34,6 +34,8 @@ from tsconfig.tsconfig import SW_VERSION
pidfile_path = "/var/run/software_agent.pid"
agent_running_after_reboot_flag = \
"/var/run/software_agent_running_after_reboot"
run_postinstallscript_after_reboot_flag = \
"/var/run/run_postinstallscript_after_reboot_flag"
node_is_patched_file = "/var/run/node_is_patched"
node_is_software_updated_rr_file = "/var/run/node_is_software_updated_rr"
patch_installing_file = "/var/run/patch_installing"
@@ -92,6 +94,17 @@ def pull_install_scripts_from_controller():
raise
def run_post_install_script():
LOG.info("Running post-install patch-scripts")
try:
subprocess.check_output([run_install_software_scripts_cmd, "postinstall"],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
LOG.exception("Failed to execute post-install scripts.")
LOG.error("Command output: %s", e.output)
def check_install_uuid():
controller_install_uuid_url = "http://controller:%s/feed/rel-%s/install_uuid" % (http_port_real, SW_VERSION)
try:
@@ -653,6 +666,7 @@ class PatchAgent(PatchService):
if os.path.exists(node_is_software_updated_rr_file):
LOG.info("Reboot is required. Skipping patch-scripts")
setflag(run_postinstallscript_after_reboot_flag)
elif disallow_insvc_patch:
LOG.info("Disallowing patch-scripts. Treating as reboot-required")
setflag(node_is_software_updated_rr_file)
@@ -899,6 +913,10 @@ def main():
setflag(agent_running_after_reboot_flag)
delete_older_deployments_flag = True
if os.path.exists(run_postinstallscript_after_reboot_flag):
run_post_install_script()
clearflag(run_postinstallscript_after_reboot_flag)
if len(sys.argv) <= 1:
pa.run()
elif sys.argv[1] == "--install":