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

NPE on GCE attachDisk when VM not found (because user-error wrong region specified)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.8.0
    • 2.0.0
    • jclouds-labs-google
    • None

    Description

      When attaching a disk to a VM, I got an NPE (because I specified the wrong zone - user error!)

      2014-08-19 17:27:39,455 ERROR b.l.b.AbstractVolumeManagerLiveTest [main]: Error creating and attaching volume
      java.lang.NullPointerException: operation should not be null
      at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) ~[guava-17.0.jar:na]
      at brooklyn.location.blockstore.gce.GoogleComputeEngineVolumeManager.waitForOperationToBeDone(GoogleComputeEngineVolumeManager.java:183) ~[classes/:na]
      at brooklyn.location.blockstore.gce.GoogleComputeEngineVolumeManager.attachBlockDevice(GoogleComputeEngineVolumeManager.java:111) ~[classes/:na]
      at brooklyn.location.blockstore.AbstractVolumeManager.createAttachAndMountVolume(AbstractVolumeManager.java:38) ~[classes/:na]
      at brooklyn.location.blockstore.AbstractVolumeManagerLiveTest.testCreateAndAttachVolume(AbstractVolumeManagerLiveTest.java:158) ~[test-classes/:na]

      The sequence of events were:
      1. create VM without specifying region (it was created in asia-east1-c)
      2. attach disk to the VM (but specifying europe-west1-a)
      2.1 jclouds calls POST https://www.googleapis.com/compute/v1/projects/jclouds-gce/zones/europe-west1-a/instances/brooklyn-ryqx-aled-1d9/attachDisk
      2.2 jclouds gets back a 404, so returns null from InstanceApi.attachDiskInZone
      2014-08-19 17:27:39,451 DEBUG jclouds.wire [main]: << " "code": 404,[\n]"
      2014-08-19 17:27:39,451 DEBUG jclouds.wire [main]: << " "message": "The resource 'projects/jclouds-gce/zones/europe-west1-a/instances/brooklyn-ryqx-aled-1d9' was not found"[\n]"
      2.3 tries to look up operation with id null; throws NPE

      I'd have preferred a more graceful error earlier, to say that the VM could not be found.

      Unfortunately the nice message is not available to the caller of instanceApi.attachDiskInZone; it just returns null.

      Attachments

        Activity

          People

            nacx Ignasi Barrera
            aled.sage Aled Sage
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: