Incorrect Shelved_offloaded instance metrics on openstack usage show output
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
env: bionic-ussuri and bionic-wallaby (devstack)
When running "openstack usage show --project <project>", having only shelved_offloaded instances in the project, it continues to track metrics as if the instance was running, even though it is not. See output below:
$ openstack server list
+------
| ID | Name | Status | Networks | Image | Flavor |
+------
| a8d3fbb6-
+------
$ openstack usage show --project admin
Usage from 2020-12-31 to 2021-01-29 on project 1bfc9c13d7da4a4
+------
| Field | Value |
+------
| CPU Hours | 0.04 |
| Disk GB-Hours | 0.04 |
| RAM MB-Hours | 9.43 |
| Servers | 1 |
+------
$ openstack server show ins1
+------
| Field | Value |
+------
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-STS:vm_state | shelved_offloaded |
| OS-SRV-
| OS-SRV-
| accessIPv4 | |
| accessIPv6 | |
| addresses | private=10.0.0.30, fd6b:5cf:
| config_drive | |
| created | 2021-01-
| flavor | cirros256 (c1) |
| hostId | |
| id | a8d3fbb6-
| image | cirros-
| key_name | None |
| name | ins1 |
| project_id | 1bfc9c13d7da4a4
| properties | |
| security_groups | name='default' |
| status | SHELVED_OFFLOADED |
| updated | 2021-01-
| user_id | 1330bb68cfe147a
| volumes_attached | |
+------
The reason it happens is because of the logic in [0], where it relies on the terminated_at field to make stop tracking the metrics. As can be seen in the "openstack server show" output, shelving the instance doesn't fill in the terminated_at field.
Steps to reproduce:
1) create an instance
2) shelve it, wait for shelved_offloaded state
3) run "openstack usage show --project <project>" multiple times and notice the metrics increasing
Expected result: Metrics for the shelved_offloaded instances shouldn't be accounted for while it is in that state.
tags: | added: sts |
Changed in nova: | |
assignee: | nobody → Rodrigo Barbieri (rodrigo-barbieri2010) |
status: | New → In Progress |
Changed in nova: | |
status: | In Progress → Won't Fix |
Changed in nova: | |
assignee: | Rodrigo Barbieri (rodrigo-barbieri2010) → nobody |
This behavior is expected/ intentional, but it has been like this for many years and it's possible we may want to revisit the logic.
Historically, shelved offloaded instances have counted toward usage and quota. However, as you noted in #openstack-nova today, when [quota] /count_ usage_from_ placement = True shelved offloaded instances will *not* be counted against quota [1]:
"Behavior will be different for servers in SHELVED_OFFLOADED state. A server in SHELVED_OFFLOADED state will not have placement allocations, so it will not consume quota usage for cores and ram. Note that because of this, it will be possible for a request to unshelve a server to be rejected if the user does not have enough quota available to support the cores and ram needed by the server to be unshelved."
[1] https:/ /docs.openstack .org/nova/ latest/ admin/quotas. html#id2