Skip to content

Commit aa05aa4

Browse files
authored
Merge pull request #101 from useblacksmith/tailscale-cleanup
src: only log fatal errors in tailscale teardown
2 parents 1def72d + feb3751 commit aa05aa4

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"packageManager": "yarn@3.6.3",
2828
"dependencies": {
2929
"@actions/core": "^1.10.1",
30-
"@buf/blacksmith_vm-agent.connectrpc_es": "^1.6.1-20250211212423-70f4f1344c53.2",
30+
"@buf/blacksmith_vm-agent.connectrpc_es": "^1.6.1-20250304023716-e8d233d92eac.2",
3131
"@connectrpc/connect": "^1.6.1",
3232
"@connectrpc/connect-node": "^1.6.1",
3333
"@docker/actions-toolkit": "0.37.1",

src/setup_builder.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,25 @@ export async function joinTailnet(): Promise<void> {
195195
export async function leaveTailnet(): Promise<void> {
196196
try {
197197
// Check if we're part of a tailnet before trying to leave
198-
const {stdout} = await execAsync('sudo tailscale status');
199-
if (stdout.trim() !== '') {
200-
await execAsync('sudo tailscale down');
201-
core.debug('Successfully left tailnet');
202-
} else {
203-
core.debug('Not part of a tailnet, skipping leave');
198+
try {
199+
const {stdout} = await execAsync('sudo tailscale status');
200+
if (stdout.trim() !== '') {
201+
await execAsync('sudo tailscale down');
202+
core.debug('Successfully left tailnet.');
203+
} else {
204+
core.debug('Not part of a tailnet, skipping leave.');
205+
}
206+
} catch (error: unknown) {
207+
// Type guard for ExecException which has the code property
208+
if (error && typeof error === 'object' && 'code' in error && error.code === 1) {
209+
core.debug('Not part of a tailnet, skipping leave.');
210+
return;
211+
}
212+
// Any other exit code indicates a real error
213+
throw error;
204214
}
205215
} catch (error) {
206-
core.warning(`Error leaving tailnet: ${error.message}`);
216+
core.warning(`Error leaving tailnet: ${error instanceof Error ? error.message : String(error)}`);
207217
}
208218
}
209219

0 commit comments

Comments
 (0)