Skip to content

Listing instances with SBS volumes leads to a parsing exception #1069

@cyclimse

Description

@cyclimse

Hey there!

The SDK is currently unable to list instances with SBS volumes due to an issue when parsing the Volume type:

Here's a minimal example:

import scaleway
import scaleway.instance.v1 as instance


def main():
    client = scaleway.Client.from_config_file_and_env()
    instance_api = instance.InstanceV1API(client)

    servers = instance_api.list_servers_all(zone="fr-par-1")
    for server in servers:
        print(f"Server ID: {server.id}, Name: {server.name}, State: {server.state}")


if __name__ == "__main__":
    main()

Running this script on a Scaleway project with instances using an SBS root volume leads to a parsing exception:

 File "/home/cyclimse/pythonbug/.venv/lib/python3.12/site-packages/scaleway/instance/v1/marshalling.py", line 1993, in unmarshal_ListServersResponse
    [unmarshal_Server(v) for v in field] if field is not None else None
     ^^^^^^^^^^^^^^^^^^^
  File "/home/cyclimse/pythonbug/.venv/lib/python3.12/site-packages/scaleway/instance/v1/marshalling.py", line 801, in unmarshal_Server
    args["image"] = unmarshal_Image(field)
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cyclimse/pythonbug/.venv/lib/python3.12/site-packages/scaleway/instance/v1/marshalling.py", line 388, in unmarshal_Image
    {key: unmarshal_Volume(value) for key, value in field.items()}
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cyclimse/pythonbug/.venv/lib/python3.12/site-packages/scaleway/instance/v1/marshalling.py", line 335, in unmarshal_Volume
    return Volume(**args)
TypeError: Volume.__init__() missing 5 required positional arguments: 'organization', 'project', 'tags', 'state', and 'zone'

The issue seems to occur because SBS volumes returned by the instance API don't fully comply with the OpenAPI schema:

scw instance server list -o json | jq
...
"volumes": {
      "0": {
        "id": "3de64dd9-fbf1-4099-a1d9-fed51322bc8c",
        "name": null, # Expected by the SDK
        "export_uri": null,
        "organization": null, # Expected by the SDK
        "server": null,
        "size": null,
        "volume_type": "sbs_volume",
        "creation_date": null,
        "modification_date": null,
        "state": null,
        "project": null,
        "boot": false,
        "zone": "fr-par-1"
      }
    },
...

Whereas local storage volumes (which are handled correctly by the Python SDK) don't behave this way:

...
 "volumes": {
      "0": {
        "id": "c4fe2edf-5f15-41a5-8d6d-43cc89417a99",
        "name": "k8s_base_node",
        ....
        "size": 150000000000,
        "volume_type": "l_ssd",
       ...
      }
    },
...

Thanks a lot and have a great day!

Metadata

Metadata

Labels

instanceInstance issues, bugs and feature requestspriority:highestBugs filled by customers, security issuessbsScaleway Block Storage issues, bugs and feature requests

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions