ec2api.metadata ERROR 'NoResultFound: No row was found for one()'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ec2-api |
Fix Released
|
Undecided
|
tikitavi |
Bug Description
Getting metadata from ec2-api-metadata using:
curl http://
sometimes error out with:
2017-02-01 07:05:34.734 1029 INFO ec2api.wsgi.server [req-1667a4a2-
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata [req-cd694338-
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata Traceback (most recent call last):
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata resp = self._get_
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata requester[
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata _get_ec2_
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata 'value': [instance_id]}])
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata max_results=
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata max_results=
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata max_results=
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata self.items = self.get_db_items()
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata self.groups_
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata for g in (security_
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata context, group_id, group_name, filter)
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata max_results=
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata item = self.auto_
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata self.get_
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata return db_api.
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata return IMPL.add_
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata return f(*args, **kwargs)
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata filter(
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata File "/usr/lib/
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata raise orm_exc.
2017-02-01 07:05:37.283 1029 ERROR ec2api.metadata NoResultFound: No row was found for one()
We have neutron proxying metadata to ec2-api-metadata, which further proxies to nova-api-metadata. Is this a correct configuration?
Changed in ec2-api: | |
assignee: | nobody → Jake Yip (waipengyip) |
Changed in ec2-api: | |
assignee: | Jake Yip (waipengyip) → tikitavi (rtikitavi) |
Found out a possible place where the bug is occurring.
In the items table, I found a row with the same os_id that the code is trying to update, but with a different project_id. The row looks like this
MariaDB [ec2api]> select * from items where os_id = 'e2e8e955- 71e2-402a- 9f65-a9d757844a 7c'; ------- +------ ------- ------- ------- ------- +------ --+---- ------- ------- ------- ------- ------+ ------+ ------- +------ ------- ------- ------- ------- +------ --+---- ------- ------- ------- ------- ------+ ------+ c9f23cb6318541f 02 | NULL | e2e8e955- 71e2-402a- 9f65-a9d757844a 7c | {} | ------- +------ ------- ------- ------- ------- +------ --+---- ------- ------- ------- ------- ------+ ------+
+------
| id | project_id | vpc_id | os_id | data |
+------
| sg-ae9770a4 | 911a5b6898a04da
+------
pdb shows the code trying to create a row with os_id = 'e2e8e955- 71e2-402a- 9f65-a9d757844a 7c' with project_id = '62997fe4cc8641 5799f5980f94513 e05' (different from what is in DB).
(Pdb) vars(item_ref) state': <sqlalchemy. orm.state. InstanceState object at 0x7f33cc774ed0>, 'os_id': 'e2e8e955- 71e2-402a- 9f65-a9d757844a 7c', 'vpc_id': None, 'project_id': '62997fe4cc8641 5799f5980f94513 e05', 'data': '{}', 'id': 'sg-84076db3'}
{'_sa_instance_
This throws the code into db_exception. DBDuplicateEntr y, but the subsequent code can't get an item_ref because the filters are too restrictive. I will submit a patch for consideration.
However, this raises some questions:
1) how did the row get created in the first place, and
2) is it safe to update project_id and id for a unique os_id ?