[2.5.3] Internal Server Error when creating partition using maas api

Hi, I was trying to use the MaaS API to create partitions. However, it has been yielding inconsistent results.
There are normally two outcomes:

  1. Partition is created correctly. The response will return a json object:
{
    "uuid": "20e0cbcc-2ec1-439f-91b0-f59a2655e7a4",
    "size": 536870912,
    "bootable": false,
    "tags": [],
    "device_id": 2,
    "path": "/dev/disk/by-dname/sda-part1",
    "type": "partition",
    "filesystem": null,
    "system_id": "kqssn7",
    "id": 134,
    "used_for": "Unused",
    "resource_uri": "/MAAS/api/2.0/nodes/kqssn7/blockdevices/2/partition/134"
}
  1. Error 500 where it says that ‘Partition’ object is not iterable. This is the logs that I’ve found in the MaaS regiond.log
2019-06-03 16:02:09 maasserver: [error] ################################ Exception: 'Partition' object is not iterable ################################
2019-06-03 16:02:09 maasserver: [error] Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 277, in view_atomic_with_post_commit_savepoint
    return view_atomic(*args, **kwargs)
  File "/usr/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3/dist-packages/maasserver/api/support.py", line 70, in __call__
    response = upcall(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/views/decorators/vary.py", line 21, in inner_func
    response = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/piston3/resource.py", line 229, in __call__
    else: stream = srl.render(request)
  File "/usr/lib/python3/dist-packages/piston3/emitters.py", line 464, in render
    response = serializers.serialize(format, self.data, indent=True)
  File "/usr/lib/python3/dist-packages/django/core/serializers/__init__.py", line 129, in serialize
    s.serialize(queryset, **options)
  File "/usr/lib/python3/dist-packages/django/core/serializers/base.py", line 80, in serialize
    for count, obj in enumerate(queryset, start=1):
TypeError: 'Partition' object is not iterable

2019-06-03 16:02:09 regiond: [info] 10.0.2.2 POST /MAAS/api/2.0/nodes/kqssn7/blockdevices/2/partitions/ HTTP/1.1 --> 500 INTERNAL_SERVER_ERROR (referrer: -; agent: python-requests/2.22.0)

Okay, seems like I might have found the solution to this.

Apparently, this is the case on the Accept Header. The link is from here https://bugs.launchpad.net/maas/+bug/1777443

If the Accept header changes to something such as ‘application/json’ then the request works.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.