Skip to content

Commit 659b1d9

Browse files
committed
Don't return error in destroyServer_ if droplet doesn't exist
1 parent e1d0894 commit 659b1d9

3 files changed

Lines changed: 8 additions & 19 deletions

File tree

src/cloud/digitalocean/provisioner.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ 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) => {
135+
}).then((resp: any) => {
136136
this.state_.cloud = this.state_.cloud || {};
137137
this.state_.cloud.vm = this.state_.cloud.vm || resp.droplet;
138138
// Make sure there are no actions in progress before deleting
139+
this.sendStatus_('CLOUD_WAITING_VM');
139140
return this.waitDigitalOceanActions_();
140141
}).then(() => {
141142
return this.doRequest_('DELETE', 'droplets/' + this.state_.cloud.vm.id);
@@ -147,6 +148,12 @@ class Provisioner {
147148
} else {
148149
return Promise.reject(new Error('error deleting droplet'));
149150
}
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);
150157
});
151158
}
152159

src/cloud/install/freedom-module.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
"value": ["string", "number", "string", "string"],
1616
"ret": "object"
1717
},
18-
"cancel": {
19-
"type": "method",
20-
"value": [],
21-
"ret": []
22-
},
2318
"err": {
2419
"message": "string"
2520
},

src/cloud/install/installer.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ const PROGRESS_PREFIX = 'CLOUD_INSTALL_PROGRESS';
2424
// Prefix for status updates.
2525
const STATUS_PREFIX = 'CLOUD_INSTALL_STATUS';
2626

27-
// Status indicating that the installer has been canceled.
28-
const CANCELED_STATUS = 'CANCELED';
29-
3027
// Retry timing for SSH connection establishment.
3128
const INITIAL_CONNECTION_INTERVAL_MS = 500;
3229
const MAX_CONNECTION_INTERVAL_MS = 10000;
@@ -36,7 +33,6 @@ const MAX_CONNECTION_INTERVAL_MS = 10000;
3633
// so that we have fewer paths to test.
3734
class CloudInstaller {
3835
constructor(private dispatchEvent_: (name: string, args: Object) => void) {}
39-
private status_ :string = undefined;
4036

4137
// Runs the install command via SSH, resolving with the invitation URL.
4238
public install = (
@@ -58,10 +54,6 @@ class CloudInstaller {
5854

5955
let numAttempts = 0;
6056
return promises.retryWithExponentialBackoff(() => {
61-
if (this.status_ === CANCELED_STATUS) {
62-
log.debug('Canceling cloud installer...');
63-
return Promise.reject(new Error('canceled'));
64-
}
6557
log.debug('connection attempt %1...', (++numAttempts));
6658
return new Promise<string>((F, R) => {
6759
const connection = new Client();
@@ -93,7 +85,6 @@ class CloudInstaller {
9385
this.dispatchEvent_('progress', progress);
9486
}
9587
} else if (line.indexOf(STATUS_PREFIX) === 0) {
96-
this.status_ = line;
9788
this.dispatchEvent_('status', line);
9889
}
9990
});
@@ -146,10 +137,6 @@ class CloudInstaller {
146137
});
147138
}, MAX_CONNECTION_INTERVAL_MS, INITIAL_CONNECTION_INTERVAL_MS);
148139
}
149-
150-
public cancel = () : void => {
151-
this.status_ = CANCELED_STATUS;
152-
}
153140
}
154141

155142
export = CloudInstaller;

0 commit comments

Comments
 (0)