instance snapshot fails with "AttributeError: size" when using glance v1
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
High
|
Matt Riedemann | ||
Bug Description
This is on a newton server deployed on 7/25 from master (newton).
I set use_glance_v1=True in nova.conf on the compute node.
I created a server from this image:
+------
| Property | Value |
+------
| checksum | ee1eca47dc88f48
| container_format | bare |
| created_at | 2016-07-
| disk_format | qcow2 |
| id | aac0314e-
| locations | [{"url": "file:/
| | "metadata": {}}] |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | None |
| protected | False |
| size | 13287936 |
| status | active |
| tags | [] |
| updated_at | 2016-07-
| virtual_size | None |
| visibility | public |
+------
I tried to snapshot the instance and it failed with this:
http://
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
2016-07-26 21:25:34.563 51383 ERROR nova.compute.
Looking at that code, it looks like it assumes the 'size' attribute will be on the image, which it's not. Nova creates this image from the compute API:
The extra_properties in this case come from the REST API, and I'm not passing any in in my snapshot request.
The other properties come from the instance's system_metadata, of which image_size isn't set:
mysql> select * from nova.instance_
+------
| created_at | updated_at | deleted_at | id | instance_uuid | key | value | deleted |
+------
| 2016-07-26 20:54:08 | NULL | NULL | 92 | 85bcc918-
| 2016-07-26 20:54:08 | NULL | NULL | 93 | 85bcc918-
| 2016-07-26 20:54:08 | NULL | NULL | 94 | 85bcc918-
| 2016-07-26 20:54:08 | NULL | NULL | 95 | 85bcc918-
| 2016-07-26 20:54:08 | NULL | NULL | 96 | 85bcc918-
+------
So it looks like we shouldn't rely on image.size being set when using glance v1 and taking a snapshot.
tags: | added: mitaka-backport-potential |
If you change this line:
https:/ /github. com/openstack/ nova/blob/ 9326c1ed403477d 627fa1b94e6937c 99deed9ecd/ nova/image/ glance. py#L968
To this:
output[attr] = getattr(image, attr, 0) or 0
It works like a charm.