Bug 1639267 - Gnocchi doesn't reflect the correct "launched_at" time for instance
Summary: Gnocchi doesn't reflect the correct "launched_at" time for instance
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-gnocchi
Version: 14.0 (Rocky)
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: ---
: ---
Assignee: Julien Danjou
QA Contact: Sasha Smolyak
URL:
Whiteboard:
Depends On:
Blocks: 1521176
TreeView+ depends on / blocked
 
Reported: 2018-10-15 12:35 UTC by Sasha Smolyak
Modified: 2018-10-18 08:19 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-17 14:47:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Sasha Smolyak 2018-10-15 12:35:39 UTC
Description of problem:
When creating and immediately shutting off the instance the timestamp "launched_at" is still put into metric properties. Thus, even if the instance is shut off, the timestamp shows that it's up and doesn't change when the instance is turned back on. 

Version-Release number of selected component (if applicable):
python2-gnocchiclient-7.0.4-0.20180823073245.64814b9.el7ost.noarch
puppet-gnocchi-13.3.1-0.20180901135430.edb2394.el7ost.noarch

How reproducible:
100%

Steps to Reproduce:
1. Launch a new instance: 
openstack server create --image centos-7-image --flavor m1.extra_tiny  MyNew
2. Try to shut it off:
openstack server stop 1e0b12d6-47b3-4549-9613-67947c2c3582
3. For the first several times get 
Cannot 'stop' instance 1e0b12d6-47b3-4549-9613-67947c2c3582 while it is in vm_state building (HTTP 409)
Then the server starts to shut off.
4. Observe in openstack server list that the server is SHUTOFF
5. Observe in openstack metric resource show --type instance:
both launched_at and started_at have timestamps, different in one second. 
6. Started the server: openstack server start.
7. Observe openstack metric resource show --type instance: the "launched_at" field stays the same

Actual results:
The launched_at field doesn't change when shutting off the instance and turning it back on

Expected results:
The field is supposed to show the correct "launched at" time.

Additional info:

Comment 1 Julien Danjou 2018-10-17 14:47:33 UTC
Nova does not update the launched_at itself, so there's no way Gnocchi is going to do it either.

(overcloud) [stack@undercloud-0 ~]$ date
Wed Oct 17 10:46:10 EDT 2018
(overcloud) [stack@undercloud-0 ~]$ openstack server stop 9afd9398-e53d-427e-a697-fe01b3ecb23c
(overcloud) [stack@undercloud-0 ~]$ gnocchi resource show 9afd9398-e53d-427e-a697-fe01b3ecb23c
+-----------------------+---------------------------------------------------------------------+
| Field                 | Value                                                               |
+-----------------------+---------------------------------------------------------------------+
| created_by_project_id | 7e313ceed1e84d3fb5c914e2d0018a10                                    |
| created_by_user_id    | 1bc0f5f0dd634ad589f20943e97c397d                                    |
| creator               | 1bc0f5f0dd634ad589f20943e97c397d:7e313ceed1e84d3fb5c914e2d0018a10   |
| ended_at              | None                                                                |
| id                    | 9afd9398-e53d-427e-a697-fe01b3ecb23c                                |
| metrics               | compute.instance.booting.time: a711190d-579f-49ba-979c-80da60011b26 |
|                       | cpu.delta: f741784e-1373-4750-8e29-0ddb0cde9710                     |
|                       | cpu: f01c9653-8eb5-4670-bbce-aa716eef4dd3                           |
|                       | cpu_util: e217d218-bd85-44c2-9681-0b2d1fe676ee                      |
|                       | disk.ephemeral.size: 7a21d222-43ac-4321-b19b-ff00e4c726e0           |
|                       | disk.root.size: d9ebb76f-d626-4e71-9bbe-41be31e269e9                |
|                       | memory.usage: 5b5901cd-fb36-464d-9dfa-adc90c6f6d93                  |
|                       | memory: 57cafa52-e89b-407a-8ac0-2c2d88665dd2                        |
|                       | vcpus: 8575904a-6aad-4cf3-8ceb-7bf45b4518f4                         |
| original_resource_id  | 9afd9398-e53d-427e-a697-fe01b3ecb23c                                |
| project_id            | 41313549f3e24b7e96e2be47d507841d                                    |
| revision_end          | None                                                                |
| revision_start        | 2018-10-17T14:44:10.553694+00:00                                    |
| started_at            | 2018-10-16T11:36:59.022279+00:00                                    |
| type                  | instance                                                            |
| user_id               | 6f9606aa117e46c5995f682aad88dc85                                    |
+-----------------------+---------------------------------------------------------------------+
(overcloud) [stack@undercloud-0 ~]$ gnocchi resource show 9afd9398-e53d-427e-a697-fe01b3ecb23c -t instance
+-----------------------+---------------------------------------------------------------------+
| Field                 | Value                                                               |
+-----------------------+---------------------------------------------------------------------+
| created_at            | 2018-10-16T11:36:22+00:00                                           |
| created_by_project_id | 7e313ceed1e84d3fb5c914e2d0018a10                                    |
| created_by_user_id    | 1bc0f5f0dd634ad589f20943e97c397d                                    |
| creator               | 1bc0f5f0dd634ad589f20943e97c397d:7e313ceed1e84d3fb5c914e2d0018a10   |
| deleted_at            | None                                                                |
| display_name          | InstanceGnocchiTest7043                                             |
| ended_at              | None                                                                |
| flavor_id             | 98acffd5-7a99-44d1-b059-a41c53d69f85                                |
| flavor_name           | m1.extra_tiny                                                       |
| host                  | compute-1.localdomain                                               |
| id                    | 9afd9398-e53d-427e-a697-fe01b3ecb23c                                |
| image_ref             | 319043f2-18fe-401e-8b5f-f2487b69896c                                |
| launched_at           | 2018-10-16T11:36:58+00:00                                           |
| metrics               | compute.instance.booting.time: a711190d-579f-49ba-979c-80da60011b26 |
|                       | cpu.delta: f741784e-1373-4750-8e29-0ddb0cde9710                     |
|                       | cpu: f01c9653-8eb5-4670-bbce-aa716eef4dd3                           |
|                       | cpu_util: e217d218-bd85-44c2-9681-0b2d1fe676ee                      |
|                       | disk.ephemeral.size: 7a21d222-43ac-4321-b19b-ff00e4c726e0           |
|                       | disk.root.size: d9ebb76f-d626-4e71-9bbe-41be31e269e9                |
|                       | memory.usage: 5b5901cd-fb36-464d-9dfa-adc90c6f6d93                  |
|                       | memory: 57cafa52-e89b-407a-8ac0-2c2d88665dd2                        |
|                       | vcpus: 8575904a-6aad-4cf3-8ceb-7bf45b4518f4                         |
| original_resource_id  | 9afd9398-e53d-427e-a697-fe01b3ecb23c                                |
| project_id            | 41313549f3e24b7e96e2be47d507841d                                    |
| revision_end          | None                                                                |
| revision_start        | 2018-10-17T14:44:10.553694+00:00                                    |
| server_group          | None                                                                |
| started_at            | 2018-10-16T11:36:59.022279+00:00                                    |
| type                  | instance                                                            |
| user_id               | 6f9606aa117e46c5995f682aad88dc85                                    |
+-----------------------+---------------------------------------------------------------------+
(overcloud) [stack@undercloud-0 ~]$ openstack server start 9afd9398-e53d-427e-a697-fe01b3ecb23c
(overcloud) [stack@undercloud-0 ~]$ openstack server show 9afd9398-e53d-427e-a697-fe01b3ecb23c
+-------------------------------------+----------------------------------------------------------+
| Field                               | Value                                                    |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                   |
| OS-EXT-AZ:availability_zone         | nova                                                     |
| OS-EXT-SRV-ATTR:host                | compute-1.localdomain                                    |
| OS-EXT-SRV-ATTR:hypervisor_hostname | compute-1.localdomain                                    |
| OS-EXT-SRV-ATTR:instance_name       | instance-00000002                                        |
| OS-EXT-STS:power_state              | Running                                                  |
| OS-EXT-STS:task_state               | None                                                     |
| OS-EXT-STS:vm_state                 | active                                                   |
| OS-SRV-USG:launched_at              | 2018-10-16T11:36:58.000000                               |
| OS-SRV-USG:terminated_at            | None                                                     |
| accessIPv4                          |                                                          |
| accessIPv6                          |                                                          |
| addresses                           | public=10.0.0.225                                        |
| config_drive                        |                                                          |
| created                             | 2018-10-16T11:36:22Z                                     |
| flavor                              | m1.extra_tiny (98acffd5-7a99-44d1-b059-a41c53d69f85)     |
| hostId                              | c0683acb36e34b5cb5dcba3077952128ebec89c52a6e5b529078d322 |
| id                                  | 9afd9398-e53d-427e-a697-fe01b3ecb23c                     |
| image                               | centos-7-image (319043f2-18fe-401e-8b5f-f2487b69896c)    |
| key_name                            | None                                                     |
| name                                | InstanceGnocchiTest7043                                  |
| progress                            | 0                                                        |
| project_id                          | 41313549f3e24b7e96e2be47d507841d                         |
| properties                          |                                                          |
| security_groups                     | name='default'                                           |
| status                              | ACTIVE                                                   |
| updated                             | 2018-10-17T14:45:05Z                                     |
| user_id                             | 6f9606aa117e46c5995f682aad88dc85                         |
| volumes_attached                    |                                                          |
+-------------------------------------+----------------------------------------------------------+
(overcloud) [stack@undercloud-0 ~]$ gnocchi resource show 9afd9398-e53d-427e-a697-fe01b3ecb23c -t instance
+-----------------------+---------------------------------------------------------------------+
| Field                 | Value                                                               |
+-----------------------+---------------------------------------------------------------------+
| created_at            | 2018-10-16T11:36:22+00:00                                           |
| created_by_project_id | 7e313ceed1e84d3fb5c914e2d0018a10                                    |
| created_by_user_id    | 1bc0f5f0dd634ad589f20943e97c397d                                    |
| creator               | 1bc0f5f0dd634ad589f20943e97c397d:7e313ceed1e84d3fb5c914e2d0018a10   |
| deleted_at            | None                                                                |
| display_name          | InstanceGnocchiTest7043                                             |
| ended_at              | None                                                                |
| flavor_id             | 98acffd5-7a99-44d1-b059-a41c53d69f85                                |
| flavor_name           | m1.extra_tiny                                                       |
| host                  | compute-1.localdomain                                               |
| id                    | 9afd9398-e53d-427e-a697-fe01b3ecb23c                                |
| image_ref             | 319043f2-18fe-401e-8b5f-f2487b69896c                                |
| launched_at           | 2018-10-16T11:36:58+00:00                                           |
| metrics               | compute.instance.booting.time: a711190d-579f-49ba-979c-80da60011b26 |
|                       | cpu.delta: f741784e-1373-4750-8e29-0ddb0cde9710                     |
|                       | cpu: f01c9653-8eb5-4670-bbce-aa716eef4dd3                           |
|                       | cpu_util: e217d218-bd85-44c2-9681-0b2d1fe676ee                      |
|                       | disk.ephemeral.size: 7a21d222-43ac-4321-b19b-ff00e4c726e0           |
|                       | disk.root.size: d9ebb76f-d626-4e71-9bbe-41be31e269e9                |
|                       | memory.usage: 5b5901cd-fb36-464d-9dfa-adc90c6f6d93                  |
|                       | memory: 57cafa52-e89b-407a-8ac0-2c2d88665dd2                        |
|                       | vcpus: 8575904a-6aad-4cf3-8ceb-7bf45b4518f4                         |
| original_resource_id  | 9afd9398-e53d-427e-a697-fe01b3ecb23c                                |
| project_id            | 41313549f3e24b7e96e2be47d507841d                                    |
| revision_end          | None                                                                |
| revision_start        | 2018-10-17T14:44:10.553694+00:00                                    |
| server_group          | None                                                                |
| started_at            | 2018-10-16T11:36:59.022279+00:00                                    |
| type                  | instance                                                            |
| user_id               | 6f9606aa117e46c5995f682aad88dc85                                    |
+-----------------------+---------------------------------------------------------------------+

So I've stopped/start the instance on Oct 17 and Nova does not say that the launch date is the 17th Oct. I guess it only stores the first launch.

Comment 2 Sasha Smolyak 2018-10-18 07:25:46 UTC
OK, What's a "started_at" in this case?

Comment 3 Sasha Smolyak 2018-10-18 07:28:09 UTC
We basically have started_at and launched at with a second difference, neither of them is changing when stopping the instance, what's the point of these two fields? And I don't see "started_at" in nova info, only created and updated

Comment 4 Julien Danjou 2018-10-18 08:19:40 UTC
Ceilometer's copying fields from Nova notifications information, so you should ask Nova about launched_at/created(_at) and why they are not updated (might be on purpose).

started_at/ended_at are Ceilometer specific fields that store when the resource was started/stopped. Not all services provide this, so it's computed by Ceilometer for every resources.


Note You need to log in before you can comment on or make changes to this bug.