UniqueConstraint for Port address doesn't work for updates with sqlite
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ironic |
Fix Released
|
Medium
|
Yuriy Zveryanskyy |
Bug Description
The address column on Port is a UniqueConstraint:
ironic/
So, I created the following unittest on test_ports.py
def test_replace_
pdict1 = api_get_
pdict2 = api_get_
response = self.patch_
It creates two Ports with different addresses and then it updates the first port with the same address of the second one, it suppose to fail with an IntegrityError, but it doesn't.
I changed the configuration to not create the database in memory and took a look at the 'ports' table and the address is inddeed wrong there.
(venv)[
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from ports;
1|52:54:
2|BB:BB:
3|BB:BB:
sqlite> .quit
#######
I tested against my devstack deployment running with MySQL and it fails there, so it only affects the tests.
stack@stack-
* About to connect() to 0.0.0.0 port 6385 (#0)
* Trying 0.0.0.0...
* Connected to 0.0.0.0 (0.0.0.0) port 6385 (#0)
> PATCH /v1/ports/
> User-Agent: curl/7.29.0
> Host: 0.0.0.0:6385
> Content-Type: application/json
> Accept: application/json
> Content-Length: 71
>
* upload completely sent off: 71 out of 71 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 500 Internal Server Error
< Date: Mon, 18 Nov 2013 16:45:52 GMT
< Server: WSGIServer/0.1 Python/2.7.4
< Content-Type: application/json
< Content-Length: 331
<
* Closing connection 0
{"error_message": "{\"debuginfo\": null, \"faultcode\": \"Server\", \"faultstring\": \"(IntegrityError) (1062, \\\"Duplicate entry 'AA:AA:AA:AA:AA:AB' for key 'iface_
#######
Also, in our code the objects save() method should deal with the IntegrityError and convert it to an IronicException.
summary: |
- Unique Constraint for Port address doesn't work for Updates on tests + Unique Constraint for Port address doesn't work for updates on tests (sqlite) |
summary: |
- Unique Constraint for Port address doesn't work for updates on tests - (sqlite) + Unique Constraint for Port address doesn't work for updates with sqlite |
summary: |
- Unique Constraint for Port address doesn't work for updates with sqlite + UniqueConstraint for Port address doesn't work for updates with sqlite |
Changed in ironic: | |
assignee: | nobody → Yuriy Zveryanskyy (yzveryanskyy) |
Changed in ironic: | |
importance: | Undecided → Medium |
Changed in ironic: | |
milestone: | none → icehouse-1 |
status: | Fix Committed → Fix Released |
Changed in ironic: | |
milestone: | icehouse-1 → 2014.1 |
Fix proposed to branch: master /review. openstack. org/57722
Review: https:/