~axino/mojo/devel

« back to all changes in this revision

Viewing changes to mojo/phase.py

  • Committer: mergebot at canonical
  • Author(s): "Tom Haddon"
  • Date: 2021-04-23 07:48:20 UTC
  • mfrom: (581.2.3 mojo)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20210423074820-mca12ty245k1y54z
If, post deploy, juju is in error state we should also log juju status

Reviewed-on: https://code.launchpad.net/~mthaddon/mojo/post-deploy-error-state/+merge/398200
Reviewed-by: Barry Price <barry.price@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
739
739
    def _get_command(self, series):
740
740
        return [get_dep_prog("juju-deployer")]
741
741
 
 
742
    def _post_deploy_check(
 
743
        self, logging, status_settle_wait, wait_flag, max_wait, status_timeout, juju_env, additional_ready_states
 
744
    ):
 
745
        """After the deployment has completed, run checks against Juju."""
 
746
        if status_settle_wait != 0:
 
747
            logging.info(
 
748
                "Allowing services to settle before checking status (status_settle_wait={})".format(status_settle_wait)
 
749
            )
 
750
            time.sleep(status_settle_wait)
 
751
        if wait_flag:
 
752
            logging.info("Checking Juju status (max_wait={})".format(max_wait))
 
753
        else:
 
754
            logging.info("Checking Juju status (timeout={})".format(status_timeout))
 
755
        juju_status = juju.Status(environment=juju_env, additional_ready_states=additional_ready_states)
 
756
        try:
 
757
            juju_status.check_and_wait(timeout=status_timeout, wait_for_steady=wait_flag, max_wait=max_wait)
 
758
        except (juju.JujuStatusError, juju.JujuWaitException):
 
759
            # Show juju status
 
760
            logging.error("Juju Status: {}".format(juju_status.status()))
 
761
            raise
 
762
 
742
763
    def show(self, project, workspace, stage, return_output=False):
743
764
        """
744
765
        Display rendered juju-deployer configuration files, optionally
875
896
            else:
876
897
                raise JujuDeployerException("Error found during deployment phase")
877
898
        else:
878
 
            if status_settle_wait != 0:
879
 
                logging.info(
880
 
                    "Allowing services to settle before checking status (status_settle_wait={})".format(
881
 
                        status_settle_wait
882
 
                    )
883
 
                )
884
 
                time.sleep(status_settle_wait)
885
 
            if wait_flag:
886
 
                logging.info("Checking Juju status (max_wait={})".format(max_wait))
887
 
            else:
888
 
                logging.info("Checking Juju status (timeout={})".format(status_timeout))
889
 
            juju_status = juju.Status(environment=juju_env, additional_ready_states=additional_ready_states)
890
 
            try:
891
 
                juju_status.check_and_wait(timeout=status_timeout, wait_for_steady=wait_flag, max_wait=max_wait)
892
 
            except juju.JujuWaitException:
893
 
                # Show juju status
894
 
                logging.error("Juju Status: {}".format(juju_status.status()))
895
 
                raise
 
899
            self._post_deploy_check(
 
900
                logging, status_settle_wait, wait_flag, max_wait, status_timeout, juju_env, additional_ready_states
 
901
            )
896
902
            if apply_config_changes:
897
903
                logging.info("Applying config changes, if any.")
898
904
                self.diff(