Skip to content

Commit 29ceead

Browse files
committed
Merge branch 'master' into trevj-arraybuffers-converters
2 parents 200e031 + aa1161c commit 29ceead

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/cloud/digitalocean/provisioner.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,14 @@ class Provisioner {
132132
return this.doRequest_('GET', 'droplets').then((resp: any) => {
133133
// Find and delete the server with the same name
134134
return this.getDroplet_(name);
135-
}).then((resp :any) => {
136-
this.state_.cloud = {};
137-
this.state_.cloud.vm = resp.droplet;
138-
return this.doRequest_('DELETE', 'droplets/' + resp.droplet.id);
135+
}).then((resp: any) => {
136+
this.state_.cloud = this.state_.cloud || {};
137+
this.state_.cloud.vm = this.state_.cloud.vm || resp.droplet;
138+
// Make sure there are no actions in progress before deleting
139+
this.sendStatus_('CLOUD_WAITING_VM');
140+
return this.waitDigitalOceanActions_();
141+
}).then(() => {
142+
return this.doRequest_('DELETE', 'droplets/' + this.state_.cloud.vm.id);
139143
}).then((resp: any) => {
140144
if (resp.status.startsWith('204')) {
141145
// Wait until server is deleted
@@ -144,6 +148,12 @@ class Provisioner {
144148
} else {
145149
return Promise.reject(new Error('error deleting droplet'));
146150
}
151+
}).catch((e: any) => {
152+
if (e.errcode === 'VM_DNE') {
153+
// Don't return an error if droplet doesn't exist
154+
return Promise.resolve<void>();
155+
}
156+
return Promise.reject(e);
147157
});
148158
}
149159

0 commit comments

Comments
 (0)