Support instance operating_status

Added a new field ``operating_status`` for the instance to show the actual
operational status of user's database.

Change-Id: I7c52cff0ec48289fe1a260e99e02a506d4f8ddec
This commit is contained in:
Lingxian Kong 2020-12-02 14:36:39 +13:00
parent 9ea87ccf43
commit ca04c94ef6
19 changed files with 318 additions and 274 deletions

View File

@ -160,6 +160,7 @@ Response Parameters
- id: instanceId1 - id: instanceId1
- name: instanceName1 - name: instanceName1
- status: instance_status - status: instance_status
- operating_status: operating_status
- links: instance_links - links: instance_links
- links.href: instance_link_href - links.href: instance_link_href
- links.rel: instance_link_rel - links.rel: instance_link_rel
@ -226,6 +227,7 @@ Response Parameters
- id: instanceId1 - id: instanceId1
- name: instanceName1 - name: instanceName1
- status: instance_status - status: instance_status
- operating_status: operating_status
- links: instance_links - links: instance_links
- links.href: instance_link_href - links.href: instance_link_href
- links.rel: instance_link_rel - links.rel: instance_link_rel

View File

@ -717,6 +717,12 @@ nics:
in: body in: body
required: false required: false
type: array type: array
operating_status:
description: |
The operating status of the database service inside the Trove instance.
in: body
required: true
type: string
project_uuid: project_uuid:
description: | description: |
The project ID of the resource. The project ID of the resource.

View File

@ -1,14 +1,27 @@
{ {
"instance": { "instance": {
"created": "2019-12-23T20:53:38", "id": "b76a6a76-748b-4064-adec-4c9e6c9abd68",
"name": "test",
"status": "BUILD",
"operating_status": "",
"datastore": { "datastore": {
"type": "mysql", "type": "mysql",
"version": "5.7" "version": "5.7.29",
"version_number": "5.7.29"
}, },
"flavor": { "flavor": {
"id": "6" "id": "3ca76fe7-8dc1-4059-b728-de725835abcb",
"links": [
{
"href": "https://192.168.206.8:87 79/v1.0/c37341d7d1934ebc949c9d6b5c9f818c/flavors/3ca76fe7-8dc1-4059-b728-de725835abcb",
"rel": "self"
},
{
"href": "https://192.168.206.8:8779/flavors/3ca76fe7-8dc1-4059-b728-de725835abcb",
"rel": "bookmark"
}
]
}, },
"id": "b76a6a76-748b-4064-adec-4c9e6c9abd68",
"links": [ "links": [
{ {
"href": "https://127.0.0.1:8779/v1.0/9f8dd5eacb074c9f87d2d822c9092aa5/instances/b76a6a76-748b-4064-adec-4c9e6c9abd68", "href": "https://127.0.0.1:8779/v1.0/9f8dd5eacb074c9f87d2d822c9092aa5/instances/b76a6a76-748b-4064-adec-4c9e6c9abd68",
@ -19,13 +32,15 @@
"rel": "bookmark" "rel": "bookmark"
} }
], ],
"name": "test",
"region": "RegionOne", "region": "RegionOne",
"service_status_updated": "2019-12-23T20:53:38", "access": {
"status": "BUILD", "is_public": false
"updated": "2019-12-23T20:53:38", },
"volume": { "volume": {
"size": 1 "size": 1
} },
"created": "2019-12-23T20:53:38",
"updated": "2019-12-23T20:53:38",
"service_status_updated": "2019-12-23T20:53:38"
} }
} }

View File

@ -35,9 +35,10 @@
} }
], ],
"name": "test", "name": "test",
"operating_status": "HEALTHY",
"region": "RegionOne", "region": "RegionOne",
"service_status_updated": "2019-12-23T21:01:11", "service_status_updated": "2019-12-23T21:01:11",
"status": "HEALTHY", "status": "ACTIVE",
"updated": "2019-12-23T20:58:45", "updated": "2019-12-23T20:58:45",
"volume": { "volume": {
"size": 1 "size": 1
@ -69,6 +70,7 @@
} }
], ],
"name": "test", "name": "test",
"operating_status": "",
"region": "RegionOne", "region": "RegionOne",
"service_status_updated": "2019-12-23T20:53:38", "service_status_updated": "2019-12-23T20:53:38",
"status": "ERROR", "status": "ERROR",

View File

@ -24,6 +24,7 @@
} }
], ],
"name": "test", "name": "test",
"operating_status": "HEALTHY",
"region": "RegionOne", "region": "RegionOne",
"status": "ACTIVE", "status": "ACTIVE",
"volume": { "volume": {

View File

@ -37,6 +37,7 @@
} }
], ],
"name": "test", "name": "test",
"operating_status": "HEALTHY",
"region": "RegionOne", "region": "RegionOne",
"server": { "server": {
"host": "bdfe3275004d2a98d38d494fd7adfcd0c6d5d5198e86fa0d6ec5d588", "host": "bdfe3275004d2a98d38d494fd7adfcd0c6d5d5198e86fa0d6ec5d588",
@ -48,7 +49,7 @@
"server_id": "710a84e5-6adf-4a4c-9167-8bade67a5a1c", "server_id": "710a84e5-6adf-4a4c-9167-8bade67a5a1c",
"service_status": "HEALTHY", "service_status": "HEALTHY",
"service_status_updated": "2019-12-24T00:02:55", "service_status_updated": "2019-12-24T00:02:55",
"status": "HEALTHY", "status": "ACTIVE",
"task_description": "No tasks for the instance.", "task_description": "No tasks for the instance.",
"tenant_id": "9f8dd5eacb074c9f87d2d822c9092aa5", "tenant_id": "9f8dd5eacb074c9f87d2d822c9092aa5",
"updated": "2019-12-23T23:53:46", "updated": "2019-12-23T23:53:46",
@ -86,6 +87,7 @@
} }
], ],
"name": "test", "name": "test",
"operating_status": "",
"region": "RegionOne", "region": "RegionOne",
"server": null, "server": null,
"server_id": null, "server_id": null,

View File

@ -40,6 +40,7 @@
} }
], ],
"name": "test", "name": "test",
"operating_status": "HEALTHY",
"region": "RegionOne", "region": "RegionOne",
"server": { "server": {
"addresses": { "addresses": {
@ -75,7 +76,7 @@
"server_id": "710a84e5-6adf-4a4c-9167-8bade67a5a1c", "server_id": "710a84e5-6adf-4a4c-9167-8bade67a5a1c",
"service_status": "HEALTHY", "service_status": "HEALTHY",
"service_status_updated": "2019-12-24T00:08:55", "service_status_updated": "2019-12-24T00:08:55",
"status": "HEALTHY", "status": "ACTIVE",
"task_description": "No tasks for the instance.", "task_description": "No tasks for the instance.",
"tenant_id": "9f8dd5eacb074c9f87d2d822c9092aa5", "tenant_id": "9f8dd5eacb074c9f87d2d822c9092aa5",
"updated": "2019-12-23T23:53:46", "updated": "2019-12-23T23:53:46",

View File

@ -34,9 +34,10 @@
} }
], ],
"name": "test", "name": "test",
"operating_status": "HEALTHY",
"region": "RegionOne", "region": "RegionOne",
"service_status_updated": "2019-12-23T22:15:11", "service_status_updated": "2019-12-23T22:15:11",
"status": "HEALTHY", "status": "ACTIVE",
"updated": "2019-12-23T20:58:45", "updated": "2019-12-23T20:58:45",
"volume": { "volume": {
"size": 1, "size": 1,

View File

@ -7,82 +7,32 @@ Assume that you have installed the Database service and populated your
data store with images for the type and versions of databases that you data store with images for the type and versions of databases that you
want, and that you can create and access a database instance. want, and that you can create and access a database instance.
This example shows you how to create and access a MySQL 5.7 database. This example shows you how to create and access a MySQL 5.7.29 database.
Create and access a database instance Create and access a database instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#. **Determine which flavor to use for your database** #. **Before creating the instance**
When you create a database instance, you must specify a nova flavor. * Choose the flavor. A flavor defines RAM and root volume size for the instance. Trove OpenStack CLI provides a command to get a flavor list that are supported to create trove instance.
The flavor indicates various characteristics of the instance, such as
RAM and root volume size. You will need to create or
obtain new nova flavors that work for databases.
The first step is to list flavors by using the .. code-block:: console
:command:`openstack flavor list` command.
.. code-block:: console $ openstack database flavor list
$ openstack flavor list .. note::
Now take a look at the minimum requirements for various database If creating instance as a replica for the replication cluster, flavor is not needed as it's the same with the replication primary.
instances:
+--------------------+--------------------+--------------------+--------------------+ * Choose a neutron network that the instance is allocated IP address from. You can either specify the network ID or the subnet ID, you can even specify the IP address (must be available).
| Database | RAM (MB) | Disk (GB) | VCPUs | * Choose the volume size. The cinder volume is used as data storage for the database.
+====================+====================+====================+====================+ * Choose datastore version.
| MySQL | 512 | 5 | 1 |
+--------------------+--------------------+--------------------+--------------------+
| Cassandra | 2048 | 5 | 1 |
+--------------------+--------------------+--------------------+--------------------+
| MongoDB | 1024 | 5 | 1 |
+--------------------+--------------------+--------------------+--------------------+
| Redis | 512 | 5 | 1 |
+--------------------+--------------------+--------------------+--------------------+
- If you have a custom flavor that meets the needs of the database .. note::
that you want to create, proceed to
:ref:`Step 2 <create-database-instance>` and use that flavor.
- If your environment does not have a suitable flavor, an If creating instance as a replica for the replication cluster, datastore is not needed as it's the same with the replication primary.
administrative user must create a custom flavor by using the
:command:`openstack flavor create` command.
**MySQL example.** This example creates a flavor that you can use * (Optional) Choose the data source. You can create a new instance by restoring a backup using ``--backup <BACKUP_ID>``, or create a replica instance for a replication cluster using ``--replica-of <PRIMARY_INSTANCE_ID>``
with a MySQL database. This example has the following attributes:
- Flavor name: ``mysql_minimum``
- Flavor ID: You must use an ID that is not already in use. In this
example, IDs 1 through 5 are in use, so use ID ``6``.
- RAM: ``512``
- Root volume size in GB: ``5``
- Virtual CPUs: ``1``
.. code-block:: console
$ openstack flavor create mysql-minimum --id 6 --ram 512 --disk 5 --vcpus 1
+----------------------------+---------------+
| Field | Value |
+----------------------------+---------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 5 |
| id | 6 |
| name | mysql-minimum |
| os-flavor-access:is_public | True |
| properties | |
| ram | 512 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+---------------+
.. _create-database-instance:
#. **Create a database instance** #. **Create a database instance**
@ -90,19 +40,18 @@ Create and access a database instance
parameters: parameters:
- Name of the instance: ``mysql_instance_1`` - Name of the instance: ``mysql_instance_1``
- Database flavor: ``6`` - Database flavor: ``1fb05bb0-4605-48b6-81e6-3d4622e4a330``
- A volume size of ``5`` (5 GB) - A volume size of ``5`` (5 GB)
- A database named ``test`` - A database named ``test``
- The database is based on the ``mysql`` data store and the - The database is based on the ``mysql`` data store and the
``5.7`` datastore version ``5.7.29`` datastore version
- The ``userA`` user with the ``password`` password. - The ``userA`` user with the ``password`` password.
- A Neutron network ``8799cf10-01ef-40e2-b04e-06da7cfa5668`` to allocate - A Neutron network ``8799cf10-01ef-40e2-b04e-06da7cfa5668`` to allocate
the database IP address (for internal access). the database IP address (for internal access).
- Expose the instance to the public via ``--is-public`` (for external - Expose the instance to the public via ``--is-public`` (for external
access). Ignore this parameter if you don't want to expose database access).
service to the public internet.
- Only the IP addresses coming from ``202.37.199.1/24`` or ``10.1.0.1/24`` - Only the IP addresses coming from ``202.37.199.1/24`` or ``10.1.0.1/24``
are allowed to access the database service. are allowed to access the database.
.. code-block:: console .. code-block:: console
@ -111,54 +60,65 @@ Create and access a database instance
--size 5 \ --size 5 \
--nic net-id=8799cf10-01ef-40e2-b04e-06da7cfa5668 \ --nic net-id=8799cf10-01ef-40e2-b04e-06da7cfa5668 \
--databases test --users userA:password \ --databases test --users userA:password \
--datastore mysql --datastore-version 5.7 \ --datastore mysql --datastore-version 5.7.29 \
--is-public \ --is-public \
--allowed-cidr 10.1.0.1/24 \ --allowed-cidr 10.1.0.1/24 \
--allowed-cidr 202.37.199.1/24 --allowed-cidr 202.37.199.1/24
+-------------------+--------------------------------------+ +--------------------------+--------------------------------------+
| Field | Value | | Field | Value |
+-------------------+--------------------------------------+ +--------------------------+--------------------------------------+
| created | 2019-09-11T09:19:18 | | allowed_cidrs | [10.1.0.1/24, 202.37.199.1/24] |
| datastore | mysql | | created | 2020-12-08T21:00:19 |
| datastore_version | 5.7 | | datastore | mysql |
| flavor | 6 | | datastore_version | 5.7.29 |
| id | 4bca2f27-f986-419e-ab4a-df1db399d590 | | datastore_version_number | 5.7.29 |
| name | mysql_instance_1 | | flavor | 1fb05bb0-4605-48b6-81e6-3d4622e4a330 |
| region | RegionOne | | id | ad40cf6c-6532-4a22-a3f3-7364f0f04a0f |
| status | BUILD | | name | mysql_instance_1 |
| updated | 2019-09-11T09:19:18 | | operating_status | |
| volume | 5 | | public | True |
+-------------------+--------------------------------------+ | region | RegionOne |
| service_status_updated | 2020-12-08T21:00:19 |
| status | BUILD |
| updated | 2020-12-08T21:00:19 |
| volume | 5 |
+--------------------------+--------------------------------------+
#. **Get the IP address of the database instance** #. **Get the IP address of the database instance**
Both internal and external IP addresses can be shown by running: Wait until the instance ``operating_status`` changes to HEALTHY before getting IP address to access the database:
.. code-block:: console .. code-block:: console
$ openstack database instance show 4bca2f27-f986-419e-ab4a-df1db399d590 $ openstack database instance show ad40cf6c-6532-4a22-a3f3-7364f0f04a0f
+-------------------+--------------------------------------+ +--------------------------+----------------------------------------------------------------------------------------------+
| Field | Value | | Field | Value |
+-------------------+--------------------------------------+ +--------------------------+----------------------------------------------------------------------------------------------+
| created | 2019-09-11T07:14:37 | | addresses | [{'address': '10.0.0.59', 'type': 'private'}, {'address': '172.24.4.242', 'type': 'public'}] |
| datastore | mysql | | allowed_cidrs | [] |
| datastore_version | 5.7 | | created | 2020-12-08T21:00:20 |
| flavor | 6 | | datastore | mysql |
| id | 4bca2f27-f986-419e-ab4a-df1db399d590 | | datastore_version | 5.7.29 |
| ip | 10.1.0.14, 172.24.5.15 | | datastore_version_number | 5.7.29 |
| name | mysql_instance_1 | | flavor | 1fb05bb0-4605-48b6-81e6-3d4622e4a330 |
| region | RegionOne | | id | ad40cf6c-6532-4a22-a3f3-7364f0f04a0f |
| status | ACTIVE | | ip | 10.0.0.59, 172.24.4.242 |
| updated | 2019-09-11T07:14:47 | | name | mysql_instance_1 |
| volume | 5 | | operating_status | HEALTHY |
| volume_used | 0.12 | | public | True |
+-------------------+--------------------------------------+ | region | RegionOne |
| service_status_updated | 2020-12-08T21:05:51 |
| status | ACTIVE |
| updated | 2020-12-08T21:04:39 |
| volume | 5 |
| volume_used | 0.2 |
+--------------------------+----------------------------------------------------------------------------------------------+
#. **Access the new database** #. **Access the new database**
You can now access the new database you just created by using You can now access the new database you just created by using
typical database access commands. In this MySQL example, replace typical database access commands. In this MySQL example, replace
``IP_ADDRESS`` with either 10.1.0.14 or 172.24.5.15 according to where the ``IP_ADDRESS`` with either 10.0.0.59 or 172.24.4.242 according to where the
command is running. Make sure your IP address is in the allowed CIDRs command is running. Make sure your IP address is in the allowed CIDRs
specified in the above command. specified in the above command.

View File

@ -2,40 +2,46 @@
Database instance status Database instance status
======================== ========================
HEALTHY Trove is maintaining two types of status, named ``status`` and ``operating_status``.
The database service is functional, e.g. table is accessible.
RUNNING ``status`` is reflecting the trove instance VM status and instance task status, e.g. after successfully creating a trove instance, the ``status`` is ``ACTIVE``, when doing backup, the ``status`` is ``BACKUP``, etc.
The database service is alive, but maybe not functional yet.
SHUTDOWN ``operating_status`` is the actual database status inside the trove instance, trove guest agent is actively monitoring the database status and reporting back to trove, e.g. when MySQL service is up and running, the ``operating_status`` should be ``HEALTHY``, if MySQL service is not running for some reason, the ``operating_status`` is ``SHUTDOWN``.
The database service is stopped.
The possible values for ``status`` are:
NEW NEW
The database service creation request is just received by Trove. The database instance creation request is just received by Trove.
BUILD BUILD
The database service is being installed. The database instance is being installed.
BLOCKED ACTIVE
The database service process exists but service is not accessible for some The database instance is up and running.
reason.
PROMOTE REBOOT
Trove is replicating data between a replication group in order to promote a The database instance is rebooting.
new master instance.
EJECT RESIZE
The master election is happening within a replication group. The database instance is being resized.
UPGRADE
The database instance is upgrading its datastore, e.g. from mysql 5.7.29 to mysql 5.7.30
RESTART_REQUIRED RESTART_REQUIRED
The database service needs to restart, e.g. due to the configuration change. The database service needs to restart, e.g. due to the configuration change.
FAILED PROMOTE
The database service is failed to spawn. A replica instance in the replication cluster is being promoted to the primary.
ERROR EJECT
There are some errors in a running database service. The current primary instance in a replication cluster is being ejected, one of the replicas is going to be elected as the new primary.
DELETED DETACH
The database service is deleted. One of the replicas in a replication cluster is being detached and will become a standalone instance.
SHUTDOWN
The database instance is being shutdown during deletion.
BACKUP
The database instance is being backed up.

View File

@ -48,12 +48,12 @@ Set up replication
.. code-block:: console .. code-block:: console
$ openstack database instance list $ openstack database instance list
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+---------+------------------+------------------------------------------------+-----------+------+-----------+---------+
| ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role | | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+---------+------------------+------------------------------------------------+-----------+------+-----------+---------+
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica | | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary | | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+---------+------------------+-----------------------------+-----------+------+-----------+---------+
#. Verify replication status. #. Verify replication status.
@ -120,13 +120,13 @@ couple minutes.
.. code-block:: console .. code-block:: console
$ openstack database instance list $ openstack database instance list
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
| ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role | | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica | | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
| a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica | | a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary | | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+-----------------------------+-----------+------+-----------+---------+
#. Failover(promote) "test-mysql-replica-1" to primary. #. Failover(promote) "test-mysql-replica-1" to primary.
@ -139,13 +139,13 @@ couple minutes.
.. code-block:: console .. code-block:: console
$ openstack database instance list $ openstack database instance list
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
| ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role | | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | primary | | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
| a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica | | a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | replica | | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
#. Point your application to the (former) replica. #. Point your application to the (former) replica.

View File

@ -35,12 +35,12 @@ Upgrading datastore
| 50bed39d-6788-4a0d-8d74-321012bb6b55 | mysql | | 50bed39d-6788-4a0d-8d74-321012bb6b55 | mysql |
+--------------------------------------+-------+ +--------------------------------------+-------+
$ openstack datastore version list mysql $ openstack datastore version list mysql
+--------------------------------------+--------+ +--------------------------------------+--------+---------+
| ID | Name | | ID | Name | Version |
+--------------------------------------+--------+ +--------------------------------------+--------+---------+
| 70c68d0a-27e1-4fbd-bd3b-f29d42ce1a7d | 5.7.29 | | 70c68d0a-27e1-4fbd-bd3b-f29d42ce1a7d | 5.7.29 | 5.7.29 |
| cf91aa9a-2192-4ec4-b7ce-5cac3b1e7dbe | 5.7.30 | | cf91aa9a-2192-4ec4-b7ce-5cac3b1e7dbe | 5.7.30 | 5.7.30 |
+--------------------------------------+--------+ +--------------------------------------+--------+---------+
#. **Create a new instance with datastore version 5.7.29** #. **Create a new instance with datastore version 5.7.29**
@ -55,11 +55,11 @@ Upgrading datastore
--datastore mysql --datastore-version 5.7.29 \ --datastore mysql --datastore-version 5.7.29 \
--databases testdb --users user:password --databases testdb --users user:password
$ openstack database instance list $ openstack database instance list
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
| ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role | | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.29 | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | | | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
Check the MySQL version by connecting with the database: Check the MySQL version by connecting with the database:
@ -91,17 +91,17 @@ Upgrading datastore
.. code-block:: console .. code-block:: console
$ openstack database instance list $ openstack database instance list
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
| ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role | | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | UPGRADE | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | | | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | UPGRADE | | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
$ openstack database instance list $ openstack database instance list
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
| ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role | | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | | | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | ACTIVE | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
+--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
Check the MySQL version again: Check the MySQL version again:

View File

@ -0,0 +1,9 @@
---
features:
- Added a new field ``operating_status`` for the instance to show the actual
operational status of user's database. See
https://docs.openstack.org/trove/latest/user/instance-status.html for more
information.
upgrade:
- Any 3rd party clients that are talking with Trove API to wait for
``status`` should be notified to use ``operating_status`` instead.

View File

@ -330,8 +330,27 @@ class SimpleInstance(object):
datastore_status.__class__.__name__) datastore_status.__class__.__name__)
self.__datastore_status = datastore_status self.__datastore_status = datastore_status
@property
def operating_status(self):
"""operating_status is the database service status."""
task_status = self.db_info.task_status
server_status = self.db_info.server_status
ds_status = self.datastore_status.status
if (task_status != InstanceTasks.NONE or server_status != 'ACTIVE'):
return ""
return repr(ds_status)
@property @property
def status(self): def status(self):
"""The server status of the database instance.
- The task action is considered first.
- If it's performing backup or not.
- Then server status
- Otherwise, unknown
"""
LOG.info(f"Getting instance status for {self.id}, " LOG.info(f"Getting instance status for {self.id}, "
f"task status: {self.db_info.task_status}, " f"task status: {self.db_info.task_status}, "
f"datastore status: {self.datastore_status.status}, " f"datastore status: {self.datastore_status.status}, "
@ -339,19 +358,12 @@ class SimpleInstance(object):
task_status = self.db_info.task_status task_status = self.db_info.task_status
server_status = self.db_info.server_status server_status = self.db_info.server_status
ds_status = self.datastore_status.status
# Check for taskmanager errors. # Check for taskmanager errors.
if task_status.is_error: if task_status.is_error:
return InstanceStatus.ERROR return InstanceStatus.ERROR
action = task_status.action action = task_status.action
# Check if we are resetting status or force deleting
if (srvstatus.ServiceStatuses.UNKNOWN == ds_status
and action == InstanceTasks.DELETING.action):
return InstanceStatus.SHUTDOWN
# Check for taskmanager status. # Check for taskmanager status.
if InstanceTasks.BUILDING.action == action: if InstanceTasks.BUILDING.action == action:
if 'ERROR' == server_status: if 'ERROR' == server_status:
@ -373,23 +385,9 @@ class SimpleInstance(object):
return InstanceStatus.LOGGING return InstanceStatus.LOGGING
if InstanceTasks.DETACHING.action == action: if InstanceTasks.DETACHING.action == action:
return InstanceStatus.DETACH return InstanceStatus.DETACH
# Check for server status.
if server_status in ["BUILD", "ERROR", "REBOOT", "RESIZE"]:
return server_status
# As far as Trove is concerned, Nova instances in VERIFY_RESIZE should
# still appear as though they are in RESIZE.
if server_status in ["VERIFY_RESIZE"]:
return InstanceStatus.RESIZE
# Check if there is a backup running for this instance
if Backup.running(self.id):
return InstanceStatus.BACKUP
# Report as Shutdown while deleting, unless there's an error. # Report as Shutdown while deleting, unless there's an error.
if 'DELETING' == action: if InstanceTasks.DELETING.action == action:
if server_status in ["ACTIVE", "SHUTDOWN", "DELETED", "HEALTHY"]: if server_status in ["ACTIVE", "SHUTDOWN", "DELETED"]:
return InstanceStatus.SHUTDOWN return InstanceStatus.SHUTDOWN
else: else:
LOG.error("While shutting down instance (%(instance)s): " LOG.error("While shutting down instance (%(instance)s): "
@ -397,17 +395,21 @@ class SimpleInstance(object):
{'instance': self.id, 'status': server_status}) {'instance': self.id, 'status': server_status})
return InstanceStatus.ERROR return InstanceStatus.ERROR
# Check against the service status. # Check if there is a backup running for this instance
# The service is only paused during a reboot. if Backup.running(self.id):
if ds_status == srvstatus.ServiceStatuses.PAUSED: return InstanceStatus.BACKUP
return InstanceStatus.REBOOT
elif ds_status == srvstatus.ServiceStatuses.NEW:
return InstanceStatus.BUILD
elif ds_status == srvstatus.ServiceStatuses.UNKNOWN:
return InstanceStatus.ERROR
# For everything else we can look at the service status mapping. # Check for server status.
return self.datastore_status.status.api_status if server_status in ["BUILD", "ERROR", "REBOOT", "RESIZE", "ACTIVE",
"SHUTDOWN"]:
return server_status
# As far as Trove is concerned, Nova instances in VERIFY_RESIZE should
# still appear as though they are in RESIZE.
if server_status in ["VERIFY_RESIZE"]:
return InstanceStatus.RESIZE
return "UNKNOWN"
@property @property
def updated(self): def updated(self):
@ -607,7 +609,6 @@ def load_instance(cls, context, id, needs_server=False,
def load_instance_with_info(cls, context, id, cluster_id=None): def load_instance_with_info(cls, context, id, cluster_id=None):
db_info = get_db_info(context, id, cluster_id) db_info = get_db_info(context, id, cluster_id)
LOG.debug('Task status for instance %s: %s', id, db_info.task_status)
service_status = InstanceServiceStatus.find_by(instance_id=id) service_status = InstanceServiceStatus.find_by(instance_id=id)
if (db_info.task_status == InstanceTasks.NONE and if (db_info.task_status == InstanceTasks.NONE and

View File

@ -35,6 +35,7 @@ class InstanceView(object):
"id": self.instance.id, "id": self.instance.id,
"name": self.instance.name, "name": self.instance.name,
"status": self.instance.status, "status": self.instance.status,
"operating_status": self.instance.operating_status,
"links": self._build_links(), "links": self._build_links(),
"flavor": self._build_flavor_info(), "flavor": self._build_flavor_info(),
"datastore": {"type": None, "version": None}, "datastore": {"type": None, "version": None},

View File

@ -622,7 +622,7 @@ class CreateInstanceFail(object):
'server_state_description', 'status', 'updated', 'server_state_description', 'status', 'updated',
'users', 'volume', 'root_enabled_at', 'users', 'volume', 'root_enabled_at',
'root_enabled_by', 'fault', 'root_enabled_by', 'fault',
'service_status_updated'] 'service_status_updated', 'operating_status']
with CheckInstance(result._info) as check: with CheckInstance(result._info) as check:
check.contains_allowed_attrs( check.contains_allowed_attrs(
result._info, allowed_attrs, result._info, allowed_attrs,
@ -785,7 +785,8 @@ class CreateInstance(object):
# Check these attrs only are returned in create response # Check these attrs only are returned in create response
allowed_attrs = ['created', 'flavor', 'addresses', 'id', 'links', allowed_attrs = ['created', 'flavor', 'addresses', 'id', 'links',
'name', 'status', 'updated', 'datastore', 'fault', 'name', 'status', 'updated', 'datastore', 'fault',
'region', 'service_status_updated', 'access'] 'region', 'service_status_updated', 'access',
'operating_status']
if ROOT_ON_CREATE: if ROOT_ON_CREATE:
allowed_attrs.append('password') allowed_attrs.append('password')
if VOLUME_SUPPORT: if VOLUME_SUPPORT:
@ -928,7 +929,7 @@ class TestGetInstances(object):
def test_index_list(self): def test_index_list(self):
allowed_attrs = ['id', 'links', 'name', 'status', 'flavor', allowed_attrs = ['id', 'links', 'name', 'status', 'flavor',
'datastore', 'ip', 'hostname', 'replica_of', 'datastore', 'ip', 'hostname', 'replica_of',
'region', 'addresses', 'access'] 'region', 'addresses', 'access', 'operating_status']
if VOLUME_SUPPORT: if VOLUME_SUPPORT:
allowed_attrs.append('volume') allowed_attrs.append('volume')
instances = dbaas.instances.list() instances = dbaas.instances.list()
@ -950,7 +951,8 @@ class TestGetInstances(object):
allowed_attrs = ['created', 'databases', 'flavor', 'hostname', 'id', allowed_attrs = ['created', 'databases', 'flavor', 'hostname', 'id',
'links', 'name', 'status', 'updated', 'ip', 'links', 'name', 'status', 'updated', 'ip',
'datastore', 'fault', 'region', 'datastore', 'fault', 'region',
'service_status_updated', 'addresses', 'access'] 'service_status_updated', 'addresses', 'access',
'operating_status']
if VOLUME_SUPPORT: if VOLUME_SUPPORT:
allowed_attrs.append('volume') allowed_attrs.append('volume')
instances = dbaas.instances.list(detailed=True) instances = dbaas.instances.list(detailed=True)
@ -970,7 +972,8 @@ class TestGetInstances(object):
allowed_attrs = ['created', 'databases', 'flavor', 'hostname', 'id', allowed_attrs = ['created', 'databases', 'flavor', 'hostname', 'id',
'links', 'name', 'status', 'updated', 'ip', 'links', 'name', 'status', 'updated', 'ip',
'datastore', 'fault', 'region', 'datastore', 'fault', 'region',
'service_status_updated', 'addresses', 'access'] 'service_status_updated', 'addresses', 'access',
'operating_status']
if VOLUME_SUPPORT: if VOLUME_SUPPORT:
allowed_attrs.append('volume') allowed_attrs.append('volume')
else: else:
@ -1050,7 +1053,7 @@ class TestGetInstances(object):
'name', 'root_enabled_at', 'root_enabled_by', 'name', 'root_enabled_at', 'root_enabled_by',
'server_state_description', 'status', 'datastore', 'server_state_description', 'status', 'datastore',
'updated', 'users', 'volume', 'fault', 'region', 'updated', 'users', 'volume', 'fault', 'region',
'access'] 'access', 'operating_status']
with CheckInstance(result._info) as check: with CheckInstance(result._info) as check:
check.contains_allowed_attrs( check.contains_allowed_attrs(
result._info, allowed_attrs, result._info, allowed_attrs,

View File

@ -276,6 +276,15 @@ class RebootTestBase(ActionTestBase):
poll_until(is_status, time_out=timeout, sleep_time=sleep_time) poll_until(is_status, time_out=timeout, sleep_time=sleep_time)
def wait_for_operating_status(self, status, timeout=60, sleep_time=5):
def is_status():
instance = self.instance
if instance.operating_status in status:
return True
return False
poll_until(is_status, time_out=timeout, sleep_time=sleep_time)
@test(groups=[tests.DBAAS_API_INSTANCE_ACTIONS], @test(groups=[tests.DBAAS_API_INSTANCE_ACTIONS],
depends_on_groups=[tests.DBAAS_API_DATABASES], depends_on_groups=[tests.DBAAS_API_DATABASES],
@ -323,9 +332,7 @@ class StopTests(RebootTestBase):
def test_stop_mysql(self): def test_stop_mysql(self):
"""Stops MySQL by admin.""" """Stops MySQL by admin."""
instance_info.dbaas_admin.management.stop(self.instance_id) instance_info.dbaas_admin.management.stop(self.instance_id)
self.wait_for_operating_status(['SHUTDOWN'], timeout=90, sleep_time=10)
# The instance status will only be updated by guest agent.
self.wait_for_status(['SHUTDOWN'], timeout=90, sleep_time=10)
@test(depends_on=[test_stop_mysql]) @test(depends_on=[test_stop_mysql])
def test_volume_info_while_mysql_is_down(self): def test_volume_info_while_mysql_is_down(self):

View File

@ -325,7 +325,7 @@ class TestRunner(object, metaclass=LogOnFail):
instance_info = InstanceTestInfo() instance_info = InstanceTestInfo()
report = CONFIG.get_report() report = CONFIG.get_report()
def __init__(self, sleep_time=10, timeout=1800): def __init__(self, sleep_time=10, timeout=900):
self.def_sleep_time = sleep_time self.def_sleep_time = sleep_time
self.def_timeout = timeout self.def_timeout = timeout
@ -604,6 +604,19 @@ class TestRunner(object, metaclass=LogOnFail):
self.assert_equal(expected_http_code, client.last_http_code, self.assert_equal(expected_http_code, client.last_http_code,
"Unexpected client status code") "Unexpected client status code")
def assert_instance_operating_status(self, instance_id, expected_status):
self.report.log(f"Waiting for expected_status ({expected_status}) "
f"for instances: {instance_id}")
def wait_for_operating_status():
instance = self.get_instance(instance_id, self.admin_client)
if instance.operating_status == expected_status:
return True
return False
poll_until(wait_for_operating_status, sleep_time=self.def_sleep_time,
time_out=self.def_timeout)
def assert_all_instance_states(self, instance_ids, expected_states, def assert_all_instance_states(self, instance_ids, expected_states,
fast_fail_status=None, fast_fail_status=None,
require_all_states=False): require_all_states=False):
@ -647,6 +660,15 @@ class TestRunner(object, metaclass=LogOnFail):
self.report.log("Waiting for states (%s) for instance: %s" % self.report.log("Waiting for states (%s) for instance: %s" %
(expected_states, instance_id)) (expected_states, instance_id))
# Replace HEALTHY with ACTIVE. This is needed after operating_status
# is introduced in Trove.
wait_operating_status = False
if 'HEALTHY' in expected_states:
wait_operating_status = True
expected_states.remove('HEALTHY')
if 'ACTIVE' not in expected_states:
expected_states.append('ACTIVE')
if fast_fail_status is None: if fast_fail_status is None:
fast_fail_status = ['ERROR', 'FAILED'] fast_fail_status = ['ERROR', 'FAILED']
found = False found = False
@ -677,6 +699,9 @@ class TestRunner(object, metaclass=LogOnFail):
"Instance state was not '%s', moving to the next expected " "Instance state was not '%s', moving to the next expected "
"state." % status) "state." % status)
if found and wait_operating_status:
self.assert_instance_operating_status(instance_id, 'HEALTHY')
return found return found
def _time_since(self, start_time): def _time_since(self, start_time):
@ -992,7 +1017,7 @@ class CheckInstance(AttrCheck):
if 'datastore' not in self.instance: if 'datastore' not in self.instance:
self.fail("'datastore' not found in instance.") self.fail("'datastore' not found in instance.")
else: else:
allowed_attrs = ['type', 'version'] allowed_attrs = ['type', 'version', 'version_number']
self.contains_allowed_attrs( self.contains_allowed_attrs(
self.instance['datastore'], allowed_attrs, self.instance['datastore'], allowed_attrs,
msg="datastore") msg="datastore")

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
# #
from unittest import mock
import uuid import uuid
from trove.datastore import models from trove.datastore import models
@ -38,113 +39,114 @@ class FakeDBInstance(object):
self.id = str(uuid.uuid4()) self.id = str(uuid.uuid4())
self.deleted = False self.deleted = False
self.datastore_version_id = str(uuid.uuid4()) self.datastore_version_id = str(uuid.uuid4())
self.server_status = "HEALTHY" self.server_status = "ACTIVE"
self.task_status = FakeInstanceTask() self.task_status = FakeInstanceTask()
class BaseInstanceStatusTestCase(trove_testtools.TestCase): class BaseInstanceStatusTestCase(trove_testtools.TestCase):
@classmethod
def setUp(self): def setUpClass(cls):
util.init_db() util.init_db()
self.db_info = FakeDBInstance() cls.db_info = FakeDBInstance()
self.status = InstanceServiceStatus( cls.datastore = models.DBDatastore.create(
ServiceStatuses.RUNNING)
self.datastore = models.DBDatastore.create(
id=str(uuid.uuid4()), id=str(uuid.uuid4()),
name='mysql' + str(uuid.uuid4()), name='mysql' + str(uuid.uuid4()),
default_version_id=self.db_info.datastore_version_id default_version_id=cls.db_info.datastore_version_id
) )
self.version = models.DBDatastoreVersion.create( cls.version = models.DBDatastoreVersion.create(
id=self.db_info.datastore_version_id, id=cls.db_info.datastore_version_id,
datastore_id=self.datastore.id, datastore_id=cls.datastore.id,
name='5.7' + str(uuid.uuid4()), name='5.7' + str(uuid.uuid4()),
manager='mysql', manager='mysql',
image_id=str(uuid.uuid4()), image_id=str(uuid.uuid4()),
active=1, active=1,
packages="mysql-server-5.7" packages="mysql-server-5.7"
) )
super(BaseInstanceStatusTestCase, self).setUp() super(BaseInstanceStatusTestCase, cls).setUpClass()
def tearDown(self): @classmethod
self.datastore.delete() def tearDownClass(cls):
self.version.delete() util.cleanup_db()
super(BaseInstanceStatusTestCase, self).tearDown() super(BaseInstanceStatusTestCase, cls).tearDownClass()
class InstanceStatusTest(BaseInstanceStatusTestCase): class InstanceStatusTest(BaseInstanceStatusTestCase):
def setUp(self):
self.db_info.task_status = FakeInstanceTask()
self.db_info.server_status = "ACTIVE"
self.ds_status = InstanceServiceStatus(ServiceStatuses.HEALTHY)
super(InstanceStatusTest, self).setUp()
def test_task_status_error_reports_error(self): def test_task_status_error_reports_error(self):
self.db_info.task_status.is_error = True self.db_info.task_status.is_error = True
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.ERROR, instance.status) self.assertEqual(InstanceStatus.ERROR, instance.status)
def test_task_status_action_building_reports_build(self): def test_task_status_action_building_reports_build(self):
self.db_info.task_status.action = "BUILDING" self.db_info.task_status.action = "BUILDING"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.BUILD, instance.status) self.assertEqual(InstanceStatus.BUILD, instance.status)
def test_task_status_action_rebooting_reports_reboot(self): def test_task_status_action_rebooting_reports_reboot(self):
self.db_info.task_status.action = "REBOOTING" self.db_info.task_status.action = "REBOOTING"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.REBOOT, instance.status) self.assertEqual(InstanceStatus.REBOOT, instance.status)
def test_task_status_action_resizing_reports_resize(self): def test_task_status_action_resizing_reports_resize(self):
self.db_info.task_status.action = "RESIZING" self.db_info.task_status.action = "RESIZING"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.RESIZE, instance.status) self.assertEqual(InstanceStatus.RESIZE, instance.status)
def test_task_status_action_deleting_reports_shutdown(self): def test_task_deleting_server_active(self):
self.db_info.task_status.action = "DELETING" self.db_info.task_status.action = "DELETING"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.SHUTDOWN, instance.status) self.assertEqual(InstanceStatus.SHUTDOWN, instance.status)
def test_nova_server_build_reports_build(self): def test_nova_server_build_reports_build(self):
self.db_info.server_status = "BUILD" self.db_info.server_status = "BUILD"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.BUILD, instance.status) self.assertEqual(InstanceStatus.BUILD, instance.status)
def test_nova_server_error_reports_error(self): def test_nova_server_error_reports_error(self):
self.db_info.server_status = "ERROR" self.db_info.server_status = "ERROR"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.ERROR, instance.status) self.assertEqual(InstanceStatus.ERROR, instance.status)
def test_nova_server_reboot_reports_reboot(self): def test_nova_server_reboot_reports_reboot(self):
self.db_info.server_status = "REBOOT" self.db_info.server_status = "REBOOT"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.REBOOT, instance.status) self.assertEqual(InstanceStatus.REBOOT, instance.status)
def test_nova_server_resize_reports_resize(self): def test_nova_server_resize_reports_resize(self):
self.db_info.server_status = "RESIZE" self.db_info.server_status = "RESIZE"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.RESIZE, instance.status) self.assertEqual(InstanceStatus.RESIZE, instance.status)
def test_nova_server_verify_resize_reports_resize(self): def test_nova_server_verify_resize_reports_resize(self):
self.db_info.server_status = "VERIFY_RESIZE" self.db_info.server_status = "VERIFY_RESIZE"
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance('dummy context', self.db_info,
self.ds_status)
self.assertEqual(InstanceStatus.RESIZE, instance.status) self.assertEqual(InstanceStatus.RESIZE, instance.status)
def test_service_status_paused_reports_reboot(self): def test_operating_status_healthy(self):
self.status.set_status(ServiceStatuses.PAUSED) self.db_info.task_status = InstanceTasks.NONE
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance(mock.MagicMock(), self.db_info,
self.assertEqual(InstanceStatus.REBOOT, instance.status) self.ds_status)
self.assertEqual(repr(ServiceStatuses.HEALTHY),
instance.operating_status)
def test_service_status_new_reports_build(self): def test_operating_status_task_not_none(self):
self.status.set_status(ServiceStatuses.NEW) self.db_info.task_status = InstanceTasks.RESIZING
instance = SimpleInstance('dummy context', self.db_info, self.status) instance = SimpleInstance(mock.MagicMock(), self.db_info,
self.assertEqual(InstanceStatus.BUILD, instance.status) self.ds_status)
self.assertEqual("",
def test_service_status_running_reports_active(self): instance.operating_status)
self.status.set_status(ServiceStatuses.RUNNING)
instance = SimpleInstance('dummy context', self.db_info, self.status)
self.assertEqual(InstanceStatus.ACTIVE, instance.status)
def test_service_status_reset_status(self):
self.status.set_status(ServiceStatuses.UNKNOWN)
instance = SimpleInstance('dummy context', self.db_info, self.status)
self.assertEqual(InstanceStatus.ERROR, instance.status)
def test_service_status_force_deleteing(self):
self.status.set_status(ServiceStatuses.UNKNOWN)
self.db_info.task_status = InstanceTasks.DELETING
instance = SimpleInstance('dummy context', self.db_info, self.status)
self.assertEqual(InstanceStatus.SHUTDOWN, instance.status)