From f3ab009fd387bc253ece30ca68e457297b123a7b Mon Sep 17 00:00:00 2001 From: sshathee Date: Thu, 22 Aug 2024 12:17:53 -0400 Subject: [PATCH] deploy precheck circular dependency This commit helps remove circular dependency of usm->sysinv->usm. Hosts patch current check is done in deploy precheck script so that callback to usm can be avoided. Depends-On: https://review.opendev.org/c/starlingx/config/+/927046 TestPlan: PASS: check deploy precheck is not getting timed out PASS: verify extra param in url query does not affect on old config code PASS: verify deploy precheck works for major release upgrade PASS: verify deploy precheck works for patch release upgrade Story: 2010676 Task: 50897 Change-Id: Ic32335798e850d3e7060ad817f8427da289d895b Signed-off-by: sshathee --- software/scripts/deploy-precheck | 19 +++++++++++++++++++ software/software/software_controller.py | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/software/scripts/deploy-precheck b/software/scripts/deploy-precheck index 3dabcb65..07ce7ed5 100644 --- a/software/scripts/deploy-precheck +++ b/software/scripts/deploy-precheck @@ -126,6 +126,22 @@ class HealthCheck(object): method = 'GET' output = upgrade_utils.call_api(self._sysinv_token, method, api_cmd) + # check hosts are patch current + deploy_in_progress = self._config.get("deploy_in_progress", "{}") + deploy_in_progress = json.loads(deploy_in_progress) + if deploy_in_progress: + success = False + from_load = deploy_in_progress["from_release"] + to_load = deploy_in_progress["to_release"] + output += ('All hosts are patch current: [%s]\n') \ + % (HealthCheck.FAIL_MSG) + output += ('Deployment in progress: %s to %s\n' % (from_load, to_load)) + else: + success = True + output += ('All hosts are patch current: [%s]\n') \ + % (HealthCheck.SUCCESS_MSG) + health_ok = health_ok and success + if HealthCheck.FAIL_MSG in output: success = False health_ok = health_ok and success @@ -365,6 +381,9 @@ def parse_config(args=None): parser.add_argument("--releases", help="Releases", default="[]") + parser.add_argument("--deploy_in_progress", + help="check hosts are patch current", + default="{}") # if args was not passed will use sys.argv by default parsed_args = parser.parse_args(args) diff --git a/software/software/software_controller.py b/software/software/software_controller.py index c28e1b0a..2d7208b7 100644 --- a/software/software/software_controller.py +++ b/software/software/software_controller.py @@ -2355,6 +2355,8 @@ class PatchController(PatchService): "Use --force option to execute deploy precheck script.\n" return dict(info=msg_info, warning=msg_warning, error=msg_error, system_healthy=True) + deploy_in_progress = self._get_software_upgrade() + # parse local config file to pass parameters to precheck script try: cp = configparser.ConfigParser() @@ -2396,7 +2398,8 @@ class PatchController(PatchService): "--user_domain_name=%s" % user_domain_name, "--project_domain_name=%s" % project_domain_name, "--region_name=%s" % region_name, - "--releases=%s" % json.dumps(releases)] + "--releases=%s" % json.dumps(releases), + "--deploy_in_progress=%s" % json.dumps(deploy_in_progress)] if force: cmd.append("--force") if patch: