Skip to content

Commit

Permalink
clean mivroVM shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
srieger1 committed Oct 23, 2023
1 parent 71cdf05 commit bc31cfc
Showing 1 changed file with 45 additions and 35 deletions.
80 changes: 45 additions & 35 deletions backend/src/providers/FirecrackerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class microVMInstance {
groupNumber: number;
environment: string;
process: ChildProcess;
microVM: microVM;
}

class microVM {
Expand Down Expand Up @@ -552,6 +553,7 @@ export default class FirecrackerProvider implements InstanceProvider {
microVMIPAddress,
{
vmEndpoint: vmEndpoint,
microVM: mv,
process: process,
expirationDate: expirationDate,
tapInterfaceId: tap_id,
Expand Down Expand Up @@ -658,43 +660,51 @@ export default class FirecrackerProvider implements InstanceProvider {
if (vmEndpoint !== undefined && fc !== undefined && fi !== undefined) {
// wait for stop tasks to end
await providerInstance.sleep(1000);
if (fi.kill()) {
// wait for process to be killed properly before deleting the tap dev
await providerInstance.sleep(1000);

// delete tap interface
exec(
"sudo brctl delif " +
this.bridgeInterface +
" " +
fc.tapInterfaceId +
" && sudo ip tuntap del " +
fc.tapInterfaceId +
" mode tap",
(error, stdout, stderr) => {
if (error) {
return reject(
new Error(
"FirecrackerProvider: Unable to remove TAP device." +
stderr +
" " +
stdout
)
);
}
}
await fc.microVM

Check failure on line 663 in backend/src/providers/FirecrackerProvider.ts

View workflow job for this annotation

GitHub Actions / backend (16)

Replace `⏎········.invokeAction("SendCtrlAltDel")⏎········` with `.invokeAction("SendCtrlAltDel")`
.invokeAction("SendCtrlAltDel")
.then(async () => {
console.log(

Check failure on line 666 in backend/src/providers/FirecrackerProvider.ts

View workflow job for this annotation

GitHub Actions / backend (16)

Replace `⏎············"FirecrackerProvider:·microVM·stopped"⏎··········` with `"FirecrackerProvider:·microVM·stopped"`
"FirecrackerProvider: microVM stopped"
);
this.availableIpAddresses.push(vmEndpoint.IPAddress);
this.firecrackers.delete(instance);
// wait for stop tasks to end, is this still necessary after SendCtrlAltDel?
if (fi.kill()) {
// wait for process to be killed properly before deleting the tap dev
await providerInstance.sleep(1000);

// delete tap interface
exec(
"sudo brctl delif " +
this.bridgeInterface +
" " +
fc.tapInterfaceId +
" && sudo ip tuntap del " +
fc.tapInterfaceId +
" mode tap",
(error, stdout, stderr) => {
if (error) {
return reject(
new Error(
"FirecrackerProvider: Unable to remove TAP device." +
stderr +
" " +
stdout
)
);
}
}
);
this.availableIpAddresses.push(vmEndpoint.IPAddress);
this.firecrackers.delete(instance);

return resolve();
} else {
return reject(
new Error(
"FirecrackerProvider: Could not delete instance: " + instance
)
);
}
return resolve();
} else {
return reject(
new Error(
"FirecrackerProvider: Could not delete instance: " + instance
)
);
}
})

Check failure on line 707 in backend/src/providers/FirecrackerProvider.ts

View workflow job for this annotation

GitHub Actions / backend (16)

Insert `;`
} else {
return reject(new Error(InstanceNotFoundErrorMessage));
}
Expand Down

0 comments on commit bc31cfc

Please sign in to comment.