diff --git a/software/scripts/deploy-precheck b/software/scripts/deploy-precheck index fb6ecf24..c28a1838 100644 --- a/software/scripts/deploy-precheck +++ b/software/scripts/deploy-precheck @@ -34,6 +34,9 @@ SUPPORTED_K8S_VERSIONS = [ "v1.28.4", ] +RC_SUCCESS = 0 +RC_UNHEALTHY = 3 + class HealthCheck(object): """This class represents a general health check object @@ -327,8 +330,9 @@ def main(argv=None): # print health check output and exit print(output) if health_ok: - return 0 - return 1 + return RC_SUCCESS + else: + return RC_UNHEALTHY if __name__ == "__main__": diff --git a/software/software/constants.py b/software/software/constants.py index 8b8d6a3b..a7859563 100644 --- a/software/software/constants.py +++ b/software/software/constants.py @@ -27,6 +27,10 @@ SYSTEM_CONTROLLER_REGION = 'SystemController' SOFTWARE_STORAGE_DIR = "/opt/software" SOFTWARE_CONFIG_FILE_LOCAL = "/etc/software/software.conf" +# Deploy precheck return codes +RC_SUCCESS = 0 +RC_UNHEALTHY = 3 + DEPLOY_PRECHECK_SCRIPT = "deploy-precheck" DEPLOY_START_SCRIPT = "software-deploy-start" diff --git a/software/software/software_controller.py b/software/software/software_controller.py index c1d4da70..26f21ffb 100644 --- a/software/software/software_controller.py +++ b/software/software/software_controller.py @@ -2249,12 +2249,14 @@ class PatchController(PatchService): check=False, text=True, ) - if precheck_return.returncode != 0: - msg_error += precheck_return.stdout - else: + system_healthy = None + if precheck_return.returncode in [constants.RC_SUCCESS, constants.RC_UNHEALTHY]: + system_healthy = precheck_return.returncode == constants.RC_SUCCESS msg_info += precheck_return.stdout + else: + msg_error += precheck_return.stdout - return dict(info=msg_info, warning=msg_warning, error=msg_error) + return dict(info=msg_info, warning=msg_warning, error=msg_error, system_healthy=system_healthy) def software_deploy_precheck_api(self, deployment: str, force: bool = False, **kwargs) -> dict: """ @@ -2339,11 +2341,14 @@ class PatchController(PatchService): patch_release = False to_release = release["sw_version"] ret = self._deploy_precheck(to_release, force, patch=patch_release) - if ret["error"]: - ret["error"] = "The following issues have been detected which prevent " \ - "deploying %s\n" % deployment + \ + if ret["system_healthy"] is None: + ret["error"] = "Fail to perform deploy precheck. Internal error has occurred.\n" + \ ret["error"] - ret["error"] += "Please fix above issues then retry the deploy.\n" + return ret + elif not ret["system_healthy"]: + ret["info"] = "The following issues have been detected, which prevent " \ + "deploying %s\n" % deployment + ret["info"] + \ + "Please fix above issues then retry the deploy.\n" return ret if self._deploy_upgrade_start(to_release):