Example #1
0
    def _get_psql_version(self):
        """Poll PgSql for the version number.

        Return value is a string representing the version number.
        """
        LOG.debug("{guest_id}: Polling for postgresql version.".format(guest_id=CONF.guest_id))
        out, err = pgutil.execute("psql", "--version", timeout=30)
        pattern = re.compile("\d\.\d")
        return pattern.search(out).group(0)
Example #2
0
    def _get_psql_version(self):
        """Poll PgSql for the version number.

        Return value is a string representing the version number.
        """
        LOG.debug("{guest_id}: Polling for postgresql version.".format(
            guest_id=CONF.guest_id, ))
        out, err = pgutil.execute('psql', '--version', timeout=30)
        pattern = re.compile('\d\.\d')
        return pattern.search(out).group(0)
Example #3
0
    def _get_actual_db_status(self):
        """Checks the acutal PgSql process to determine status.

        Status will be one of the following:

            -   RUNNING

                The process is running and responsive.

            -   BLOCKED

                The process is running but unresponsive.

            -   CRASHED

                The process is not running, but should be or the process
                is running and should not be.

            -   SHUTDOWN

                The process was gracefully shut down.
        """

        # Run a simple scalar query to make sure the process is responsive.
        try:
            pgutil.execute('psql', '-c', 'SELECT 1')
        except utils.Timeout:
            return instance.ServiceStatuses.BLOCKED
        except exception.ProcessExecutionError:
            try:
                utils.execute_with_timeout(
                    "/bin/ps", "-C", "postgres", "h"
                )
            except exception.ProcessExecutionError:
                if os.path.exists(PGSQL_PID):
                    return instance.ServiceStatuses.CRASHED
                return instance.ServiceStatuses.SHUTDOWN
            else:
                return instance.ServiceStatuses.BLOCKED
        else:
            return instance.ServiceStatuses.RUNNING
Example #4
0
    def _get_actual_db_status(self):
        """Checks the acutal PgSql process to determine status.

        Status will be one of the following:

            -   RUNNING

                The process is running and responsive.

            -   BLOCKED

                The process is running but unresponsive.

            -   CRASHED

                The process is not running, but should be or the process
                is running and should not be.

            -   SHUTDOWN

                The process was gracefully shut down.
        """

        # Run a simple scalar query to make sure the process is responsive.
        try:
            pgutil.execute('psql', '-c', 'SELECT 1')
        except utils.Timeout:
            return instance.ServiceStatuses.BLOCKED
        except exception.ProcessExecutionError:
            try:
                utils.execute_with_timeout("/bin/ps", "-C", "postgres", "h")
            except exception.ProcessExecutionError:
                if os.path.exists(PGSQL_PID):
                    return instance.ServiceStatuses.CRASHED
                return instance.ServiceStatuses.SHUTDOWN
            else:
                return instance.ServiceStatuses.BLOCKED
        else:
            return instance.ServiceStatuses.RUNNING