os-hosts not show all the volume host info

Bug #1852708 reported by yenai
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
In Progress
Undecided
yenai

Bug Description

Use os-hosts API to get usage for the specified host:

Host: localhost.localdomain@lvmdriver-1, result is right.
$ curl -g -i -X GET http://192.168.153.129/volume/v3/d01ec9caf63a4211a7ab47bea3e489e7/os-hosts/localhost.localdomain@lvmdriver-1 -H "Accept: application/json" -H "User-Agent: python-cinderclient" -H "X-Auth-Token: $yenai"
HTTP/1.1 200 OK
Date: Sun, 15 Sep 2019 02:13:48 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5
x-compute-request-id: req-a939cde3-3ba3-40bf-91a9-2e0f5ecab237
Content-Type: application/json
Content-Length: 391
OpenStack-API-Version: volume 3.0
Vary: OpenStack-API-Version
x-openstack-request-id: req-a939cde3-3ba3-40bf-91a9-2e0f5ecab237
Connection: close

{"host": [{"resource": {"volume_count": "1", "total_volume_gb": "10", "total_snapshot_gb": "0", "project": "(total)", "host": "localhost.localdomain@lvmdriver-1", "snapshot_count": "0"}}, {"resource": {"volume_count": "1", "total_volume_gb": "10", "total_snapshot_gb": "0", "project": "5ba12d15b6894997bd74993e024df02a", "host": "localhost.localdomain@lvmdriver-1", "snapshot_count": "0"}}]}

Host: localhost.localdomain@yenai-lvm, result is right.
$ curl -g -i -X GET http://192.168.153.129/volume/v3/d01ec9caf63a4211a7ab47bea3e489e7/os-hosts/localhost.localdomain@yenai-lvm -H "Accept: application/json" -H "User-Agent: python-cinderclient" -H "X-Auth-Token: $yenai"
HTTP/1.1 200 OK
Date: Sun, 15 Sep 2019 02:14:10 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5
x-compute-request-id: req-cd66f6e4-5db1-4826-94ab-0ef5c3c20565
Content-Type: application/json
Content-Length: 585
OpenStack-API-Version: volume 3.0
Vary: OpenStack-API-Version
x-openstack-request-id: req-cd66f6e4-5db1-4826-94ab-0ef5c3c20565
Connection: close

{"host": [{"resource": {"volume_count": "9", "total_volume_gb": "9", "total_snapshot_gb": "1", "project": "(total)", "host": "localhost.localdomain@yenai-lvm", "snapshot_count": "1"}}, {"resource": {"volume_count": "6", "total_volume_gb": "6", "total_snapshot_gb": "1", "project": "5ba12d15b6894997bd74993e024df02a", "host": "localhost.localdomain@yenai-lvm", "snapshot_count": "1"}}, {"resource": {"volume_count": "3", "total_volume_gb": "3", "total_snapshot_gb": "0", "project": "d01ec9caf63a4211a7ab47bea3e489e7", "host": "localhost.localdomain@yenai-lvm", "snapshot_count": "0"}}]}

Host: localhost.localdomain, result is wrong. ★★★★★
$ curl -g -i -X GET http://192.168.153.129/volume/v3/d01ec9caf63a4211a7ab47bea3e489e7/os-hosts/localhost.localdomain -H "Accept: application/json" -H "User-Agent: python-cinderclient" -H "X-Auth-Token: $yenai"
HTTP/1.1 200 OK
Date: Sun, 15 Sep 2019 02:14:30 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5
x-compute-request-id: req-525f04e8-dcec-4cb2-adb4-a148c27b85a4
Content-Type: application/json
Content-Length: 367
OpenStack-API-Version: volume 3.0
Vary: OpenStack-API-Version
x-openstack-request-id: req-525f04e8-dcec-4cb2-adb4-a148c27b85a4
Connection: close

{"host": [{"resource": {"volume_count": "1", "total_volume_gb": "10", "total_snapshot_gb": "0", "project": "(total)", "host": "localhost.localdomain", "snapshot_count": "0"}}, {"resource": {"volume_count": "1", "total_volume_gb": "10", "total_snapshot_gb": "0", "project": "5ba12d15b6894997bd74993e024df02a", "host": "localhost.localdomain", "snapshot_count": "0"}}]}

Reason:
cinder/api/contrib/hosts.py
        # Not found exception will be handled at the wsgi level
        host_ref = objects.Service.get_by_host_and_topic(
            context, host, constants.VOLUME_TOPIC) ★★★★★ will return the first host(in this case is just localhost.localdomain@lvmdriver-1)!

Even if you get it, the exist methods volume_get_all_by_host and volume_data_get_for_host also can not deal with it! The filter conditions just miss the host level.

yenai (yenai2008)
Changed in cinder:
assignee: nobody → yenai (yenai2008)
Changed in cinder:
status: New → In Progress
yenai (yenai2008)
description: updated
yenai (yenai2008)
description: updated
description: updated
yenai (yenai2008)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.