API client blocks when deleting a resource
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Fix Released
|
Critical
|
Jeroen T. Vermeulen | ||
1.5 |
Fix Released
|
Critical
|
Jeroen T. Vermeulen | ||
maas (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
When using the API client to delete a resource, the resource is deleted all right but the client blocks forever.
[Test Case]
= How to reproduce =
Assuming you've got a MAAS server installed on localhost:
# Create admin user.
sudo maas-region-admin createadmin --username admin --password test --email <email address hidden>
# Set up maas cli.
sudo maas login maas http://
# Create a zone object.
sudo maas maas zones create name=test_zone
# Get the api key for the admin user.
sudo maas-region-admin apikey --username admin
<grab the API key>
# Now, in a python shell:
python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from apiclient.creds import convert_
>>> from apiclient.
... MAASClient,
... MAASDispatcher,
... MAASOAuth,
... urllib2,
... )
>>> credentials = convert_
>>> auth = MAASOAuth(
>>> client = MAASClient(auth, MAASDispatcher(), "http://
>>> zone_uri = u'/api/
>>> client.
<blocked forever>
= Notes =
- The same happens when deleting a node so I suspect this is a general problem with the `delete()` method.
- If you CTL-C the last command (the deletion of the zone), `sudo maas maas zones read` will show that the zone has effectively be deleted.
= Workaround =
A (pretty ugly) workaround is to set a timeout to `urlopen` used by the API client.
>>> from functools import partial
>>> urlopen_
>>> from apiclient import maas_client
>>> maas_client.
Related branches
- Gavin Panella (community): Approve
-
Diff: 39 lines (+12/-3)2 files modifiedsrc/apiclient/maas_client.py (+4/-2)
src/apiclient/tests/test_maas_client.py (+8/-1)
- Jeroen T. Vermeulen (community): Approve
-
Diff: 39 lines (+12/-3)2 files modifiedsrc/apiclient/maas_client.py (+4/-2)
src/apiclient/tests/test_maas_client.py (+8/-1)
description: | updated |
Changed in maas: | |
importance: | Undecided → Critical |
status: | New → Triaged |
Changed in maas: | |
assignee: | nobody → Jeroen T. Vermeulen (jtv) |
status: | Triaged → In Progress |
Changed in maas: | |
status: | In Progress → Fix Committed |
Changed in maas: | |
milestone: | none → 14.10 |
Changed in maas: | |
milestone: | 14.10 → none |
description: | updated |
Changed in maas: | |
status: | Fix Committed → Fix Released |
Changed in maas (Ubuntu): | |
status: | New → Fix Released |
tags: |
added: verification-done removed: verification-needed |
All of the API's DELETE implementations return piston. utils.rc. DELETED: status code 204 (“No Content”) and an empty body. It sounds as if the error is in that area somewhere... What should happen AFAICS is that Django (in conditional_ content_ removal) strips the empty text body from the response, but as Raphaël has pointed out elsewhere, perhaps that leaves a file-like object unclosed or something.