Skip to content

Commit

Permalink
Fix #61, 62: very frequent freezing of VM during teardown
Browse files Browse the repository at this point in the history
This will only mitigate the issue and doesn't fix the root cause. The
action doesn't shutdown the VM anymore. Since the action is run
inside a VM itself, everything will be cleaned up automatically.
Hopefully this will make the issue less likely to occur.
  • Loading branch information
jacob-carlborg committed Nov 20, 2023
1 parent 5272ec7 commit 16fa3b8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 46 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Run any SSH commands to the VM in verbose mode when debug mode is enabled
- Mitigate very frequent freezing of VM during teardown ([#61](https://github.com/cross-platform-actions/action/issues/61), [#72](https://github.com/cross-platform-actions/action/issues/72))
With this change the action doesn't shutdown the VM. Since the action is
run inside a VM itself, everything will be cleaned up automatically.

## [0.21.1] - 2023-11-03
### Fixed
Expand Down
25 changes: 3 additions & 22 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions src/action/action.ts
Expand Up @@ -119,15 +119,9 @@ export class Action {
} finally {
core.startGroup('Tearing down VM')
await this.syncBack(vm.ipAddress)
await vm.stop()
}
} finally {
try {
await vm.terminate()
fs.rmSync(this.tempPath, {recursive: true})
} finally {
core.endGroup()
}
core.endGroup()
}
}

Expand Down
18 changes: 2 additions & 16 deletions src/vm.ts
Expand Up @@ -69,8 +69,8 @@ export abstract class Vm {
core.info('Booting VM')
core.debug(this.command.join(' '))
this.vmProcess = spawn('sudo', this.command, {
detached: false,
stdio: ['ignore', 'inherit', 'inherit']
detached: true,
stdio: ['ignore', 'ignore', 'ignore']
})

if (this.vmProcess.exitCode) {
Expand Down Expand Up @@ -104,20 +104,6 @@ export abstract class Vm {
)
}

async stop(): Promise<void> {
core.info('Shuting down VM')
await this.shutdown()
}

async terminate(): Promise<number> {
core.info('Terminating VM')
return await exec.exec(
'sudo',
['kill', '-s', 'TERM', this.vmProcess.pid.toString()],
{ignoreReturnCode: true}
)
}

async setupWorkDirectory(
homeDirectory: string,
workDirectory: string
Expand Down

0 comments on commit 16fa3b8

Please sign in to comment.