I am trying to detach a disk from GCP vm. I am using the google_cloud_cpp apis to do this. I am passing all the values properly. Attaching the output of parameters I am passing to DetachDisk here for reference. When I see the VM logs, There is no device name at all.
DetachDiskRequest:
device_name: "test-dev-disk-1"
instance: "test-dev"
project: "r1-sd-test-lgbow"
zone: "us-east4-b"
google:☁️:cpp::compute::instances::v1::DetachDiskRequest request;
request.set_device_name(disk_name);
request.set_project(projectId);
request.set_zone(zone);
request.set_instance(instanceName);
// print the request
std::cout << "DetachDiskRequest: " << request.DebugString() << std::endl;
auto detach_result = instance_client.DetachDisk(request).get();
if (!detach_result.status().ok()) {
std::ostringstream error_message;
error_message << "Failed to detach disk: " << detach_result.status().message();
std::cerr << error_message.str() << std::endl;
throw std::runtime_error(error_message.str());
} else {
std::cout << "Disk Detach operation initiated successfully" << std::endl;
}
This function always throws an error "Failed to detach disk: Error in non-idempotent operation: Invalid value for field 'deviceName': ''. Device name must be provided.
Error: Failed to detach disk: Error in non-idempotent operation: Invalid value for field 'deviceName': ''. Device name must be provided."