Repository navigation
Unrecognized http status code: 411 when detaching disk via InstanceClient#detachDiskInstance #3735
Copy link
Copy link
Closed
Labels
🚨 criticalP0 critical issue. Requires immediate fixP0 critical issue. Requires immediate fixapi: computeIssues related to the Compute Engine API.Issues related to the Compute Engine API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Activity
Actually every usage of InstanceClient#detachDiskInstance fails. Here is example of code that fails:
import com.google.cloud.compute.v1.AttachedDiskInitializeParams; import com.google.cloud.compute.v1.Disk; import com.google.cloud.compute.v1.DiskClient; import com.google.cloud.compute.v1.Instance; import com.google.cloud.compute.v1.InstanceClient; import com.google.cloud.compute.v1.NetworkInterface; import com.google.cloud.compute.v1.Operation; import com.google.cloud.compute.v1.ProjectGlobalImageName; import com.google.cloud.compute.v1.ProjectGlobalNetworkName; import com.google.cloud.compute.v1.ProjectRegionSubnetworkName; import com.google.cloud.compute.v1.ProjectZoneDiskName; import com.google.cloud.compute.v1.ProjectZoneDiskTypeName; import com.google.cloud.compute.v1.ProjectZoneInstanceName; import com.google.cloud.compute.v1.ProjectZoneMachineTypeName; import com.google.cloud.compute.v1.ProjectZoneName; import java.io.IOException; import java.util.UUID; public class NewApiExample { private static String PROJECT = "YOUR_PROGECT"; private static String REGION = "us-west1"; private static String ZONE = "us-west1-a"; private static String NETWORK = "YOUR_NETWORK"; private static String SUBNET = "YOUR_SUBNETWORK"; private static String IMAGE = "YOUR_UBUNTU_IMAGE"; public static void main(String[] args) throws InterruptedException { String uuid = UUID.randomUUID().toString(); long startAt =System.currentTimeMillis(); try (InstanceClient instanceClient = InstanceClient.create(); DiskClient diskClient = DiskClient.create()) { System.out.println("Clients created in " + (System.currentTimeMillis() - startAt) + "ms."); ProjectZoneName zone = ProjectZoneName.of(PROJECT, ZONE); ProjectZoneMachineTypeName machineTypeName = ProjectZoneMachineTypeName .of(String.format("custom-%s-%s", 4, 4 * 1024), PROJECT, ZONE); ProjectGlobalNetworkName networkName = ProjectGlobalNetworkName.of(NETWORK, PROJECT); ProjectRegionSubnetworkName subnetworkName = ProjectRegionSubnetworkName .of(PROJECT, REGION, SUBNET); ProjectGlobalImageName imageName = ProjectGlobalImageName.of(IMAGE, PROJECT); NetworkInterface networkInterface = NetworkInterface.newBuilder() .setNetwork(networkName.toString()) .setSubnetwork(subnetworkName.toString()) .build(); AttachedDisk bootDisk = AttachedDisk.newBuilder() .setAutoDelete(true) .setBoot(true) .setInitializeParams(AttachedDiskInitializeParams.newBuilder() .setSourceImage(imageName.toString()) .setDiskSizeGb(String.valueOf(25)) .build()) .build(); ProjectZoneInstanceName instanceName = ProjectZoneInstanceName .of(String.format("test-api-instance-%s", uuid), PROJECT, ZONE); Instance instanceResource = Instance.newBuilder() .setName(instanceName.getInstance()) .addNetworkInterfaces(networkInterface) .setMachineType(machineTypeName.toString()) .addDisks(bootDisk) .build(); Operation op1 = instanceClient.insertInstance(zone, instanceResource); System.out.println(String.format("Instance created: %s", op1.toString())); ProjectZoneDiskTypeName diskTypeName = ProjectZoneDiskTypeName.of("pd-standard", PROJECT, ZONE); ProjectZoneDiskName diskName = ProjectZoneDiskName .of(String.format("test-api-device-name-%s", uuid), PROJECT, ZONE); Disk disk = Disk.newBuilder() .setName(diskName.getDisk()) .setSizeGb(String.valueOf(7)) .setType(diskTypeName.toString()) .build(); Operation op2 = diskClient.insertDisk(zone, disk); System.out.println(String.format("Disk created: %s", op2.toString())); Thread.sleep(10000); AttachedDisk attachedDisk = AttachedDisk.newBuilder() .setDeviceName(diskName.getDisk()) .setAutoDelete(false) .setMode("READ_WRITE") .setSource(diskName.toString()) .build(); Operation op3 = instanceClient.attachDiskInstance(instanceName, false, attachedDisk); System.out.println(String.format("Disk attached: %s", op3.toString())); Thread.sleep(10000); System.out.println("----------------------------------------"); System.out.println(String.format( "After getting error you should manually delete instance %s and disk %s", instanceName.getInstance(), diskName.getDisk() )); System.out.println("----------------------------------------"); //This operation fails Operation op4 = instanceClient.detachDiskInstance(instanceName, diskName.getDisk()); System.out.println(String.format("Disk detached: %s", op4.toString())); } catch (IOException ex) { System.out.println(String.format("Error when creating clients %s", ex.getMessage())); } } }- addedtriage meI really want to be triaged.I really want to be triaged.
on Sep 27, 2018 - addedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.api: computeIssues related to the Compute Engine API.Issues related to the Compute Engine API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
on Sep 27, 2018 - removedtriage meI really want to be triaged.I really want to be triaged.
on Sep 27, 2018 It seems to be more a like bug in detach functionality of compute api v1 than a question.
The problem noted at JetBrains/teamcity-google-agent#27 (comment) seems to be the same thing, but with
stopInstance. The commonality is that both are POST requests with an empty request body. Presumably, in such a case, the underlying HTTP client doesn't set theContent-Lengthheader at all whereas the server requires it.- addedpriority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.and removedpriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
on Jan 29, 2019 - added🚨 criticalP0 critical issue. Requires immediate fixP0 critical issue. Requires immediate fix
on Jan 29, 2019 ack.
Fix is probably just adding the content-length header to all requests. This fix will be added to the gax-java dependency.
Thanks for triaging @matti-cujo
- added a commit that references this issue
on Mar 9, 2026 - added a commit that references this issue
on Mar 20, 2026 - added a commit that references this issue
on Mar 24, 2026
Metadata
Metadata
Assignees
Labels
🚨 criticalP0 critical issue. Requires immediate fixP0 critical issue. Requires immediate fixapi: computeIssues related to the Compute Engine API.Issues related to the Compute Engine API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
When trying to detach disk via InstanceClient#detachDiskInstance the operation fails with the stacktrace