Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-807

org.jclouds.openstack.nova.v2_0.features.ImageApi.listInDetail may fail for some Images with structured metadata

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.8.0, 2.0.0
    • None
    • jclouds-labs-openstack
    • None

    Description

      In our environment (Openstack Icehouse), the list of images with details may return some structured data in metadata, for instance :

      "metadata": {
          "block_device_mapping": [
              {
                  "guest_format": null,
                  "boot_index": 0,
                  "no_device": null,
                  "volume_id": null,
                  "volume_size": null,
                  "disk_bus": "virtio",
                  "image_id": null,
                  "source_type": "snapshot",
                  "device_type": "disk",
                  "snapshot_id": "ce746121-7829-4818-bf5b-2b86d48b5ce0",
                  "destination_type": "volume",
                  "delete_on_termination": null
              },
              {
                  "guest_format": null,
                  "boot_index": null,
                  "no_device": null,
                  "volume_id": null,
                  "volume_size": null,
                  "disk_bus": null,
                  "image_id": null,
                  "source_type": "snapshot",
                  "device_type": null,
                  "snapshot_id": "a659cb24-c84e-472b-8ec2-9e4af8211d08",
                  "destination_type": "volume",
                  "delete_on_termination": null
              }
          ],
          "container_format": "bare"
          [...]
      }
      

      In that case, the deserialization code fails with the following message "com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY ..." since the class org.jclouds.openstack.nova.v2_0.domain.Image contains metadata as a Map<String, String> but block_device_mapping is an array of objects instead of a String.

      This issue seems present in 1.8.x and 2.0.0

      A modification of the test case jclouds/apis/openstack-nova/src/test/resources/image_details.json explains the problem :

      put:

      "metadata": {
                  "ImageType": "Gold",
                  "ImageVersion": "1.5",
                  "block_device_mapping": [{"guest_format": null, "boot_index": 0, "no_device": null, "volume_id": null, "volume_size": null, "disk_bus": "virtio", "image_id": null, "source_type": "snapshot", "device_type": "disk", "snapshot_id": "ce746121-7829-4818-bf5b-2b86d48b5ce0", "destination_type": "volume", "delete_on_termination": null}, {"guest_format": null, "boot_index": null, "no_device": null, "volume_id": null, "volume_size": null, "disk_bus": null, "image_id": null, "source_type": "snapshot", "device_type": null, "snapshot_id": "a659cb24-c84e-472b-8ec2-9e4af8211d08", "destination_type": "volume", "delete_on_termination": null}]
              },
      

      instead of

      "metadata": {
                  "ImageType": "Gold",
                  "ImageVersion": "1.5"
      }
      

      The message is then:

      testGetImageWhenResponseIs2xx(org.jclouds.openstack.nova.v2_0.features.ImageApiExpectTest)  Time elapsed: 0.006 sec  <<< FAILURE!
      java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 16 column 38 path $.image.metadata.
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pierre.souchay Pierre Souchay
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: