There seems to be an issue with the VM instances when recycling the names. In the below example I create, delete and create again an instance using the same name. The error is shown in the output snippet below.
var BUILDER_MACHINE_NAME = "image2";
var BUILDER_MACHINE_CONFIG = {
os: "ubuntu",
machineType: "g1-small"
};
var gce = gcloud.compute();
var zone = gce.zone(zone);
zone.createVM(BUILDER_MACHINE_NAME, BUILDER_MACHINE_CONFIG, function(err, vm, operation, apiResponse) {
if (err) { return callback(err); }
console.dir(apiResponse);
console.log("1 --------------");
operation.onComplete(function(err, metadata) {
if (err) { return callback(err); }
console.dir(metadata);
console.log("2 --------------");
vm.delete(function(err, operation, apiResponse) {
if (err) { return callback(err); }
console.dir(apiResponse);
console.log("3 --------------");
operation.onComplete(function(err, metadata) {
if (err) { return callback(err); }
console.dir(metadata);
console.log("4 --------------");
zone.createVM(BUILDER_MACHINE_NAME, BUILDER_MACHINE_CONFIG, function(err, vm, operation, apiResponse) {
if (err) { return callback(err); }
console.dir(apiResponse);
console.log("5 --------------");
operation.onComplete(function(err, metadata) {
if (err) { return callback(err); }
console.dir(metadata);
});
});
});
});
});
});
knoblauch:gcloud gabriel$ node test_start_instance.js
{ kind: 'compute#operation',
id: '10583107913049906294',
name: 'operation-1447076061239-5241ba697d6d9-c5dede0b-34ef99d6',
zone: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c',
operationType: 'insert',
targetLink: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c/instances/image2',
status: 'PENDING',
user: '262451203973-qh79osjjiu4p1m535ctcu8easjdqsqq3@developer.gserviceaccount.com',
progress: 0,
insertTime: '2015-11-09T05:34:21.878-08:00',
startTime: '2015-11-09T05:34:22.254-08:00',
selfLink: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c/operations/operation-1447076061239-5241ba697d6d9-c5dede0b-34ef99d6' }
1 --------------
{ kind: 'compute#operation',
id: '10583107913049906294',
name: 'operation-1447076061239-5241ba697d6d9-c5dede0b-34ef99d6',
zone: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c',
operationType: 'insert',
targetLink: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c/instances/image2',
targetId: '4373660117496197775',
status: 'DONE',
user: '262451203973-qh79osjjiu4p1m535ctcu8easjdqsqq3@developer.gserviceaccount.com',
progress: 100,
insertTime: '2015-11-09T05:34:21.878-08:00',
startTime: '2015-11-09T05:34:22.254-08:00',
endTime: '2015-11-09T05:34:39.789-08:00',
selfLink: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c/operations/operation-1447076061239-5241ba697d6d9-c5dede0b-34ef99d6' }
2 --------------
{ kind: 'compute#operation',
id: '6870260316579089297',
name: 'operation-1447076082997-5241ba7e3d709-61971dad-f5319c1a',
zone: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c',
operationType: 'delete',
targetLink: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c/instances/image2',
targetId: '4373660117496197775',
status: 'PENDING',
user: '262451203973-qh79osjjiu4p1m535ctcu8easjdqsqq3@developer.gserviceaccount.com',
progress: 0,
insertTime: '2015-11-09T05:34:43.109-08:00',
startTime: '2015-11-09T05:34:43.445-08:00',
selfLink: 'https://www.googleapis.com/compute/v1/projects/sigma-cairn-99810/zones/europe-west1-c/operations/operation-1447076082997-5241ba7e3d709-61971dad-f5319c1a' }
3 --------------
{ [Error: Operation did not complete.] code: 'OPERATION_INCOMPLETE' }
There seems to be an issue with the VM instances when recycling the names. In the below example I create, delete and create again an instance using the same name. The error is shown in the output snippet below.