Skip to content

Commit

Permalink
fix: make sure to pass the auth headers when reporting shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
billyb2 committed Nov 14, 2024
1 parent 8acea26 commit cfa7296
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/tasks/buildkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ keepBytes = ${cacheSizeBytes}
console.log(`BuildKit exited with error: ${error}`)
}

await shutdown(rootDir, task)
await shutdown(rootDir, task, headers)
})

try {
Expand All @@ -255,15 +255,15 @@ keepBytes = ${cacheSizeBytes}
}

// If we have successfully stopped buildkit, we can shutdown.
await shutdown(rootDir, task)
await shutdown(rootDir, task, headers)
} catch (error) {
throw error
} finally {
controller.abort()
}
}

async function shutdown(rootDir: string, task: RegisterMachineResponse_BuildKitTask) {
async function shutdown(rootDir: string, task: RegisterMachineResponse_BuildKitTask, headers: HeadersInit) {
// Remove estargz cache because we will rely on the buildkit layer cache instead.
await execa('rm', ['-rf', `${rootDir}/runc-stargz/snapshots/stargz`], {stdio: 'inherit'}).catch((err) => {
console.error(err)
Expand All @@ -290,10 +290,10 @@ async function shutdown(rootDir: string, task: RegisterMachineResponse_BuildKitT
}

// Report shutdown to the API to indicate that the machine is no longer available.
await reportShutdown()
await reportShutdown(headers)
}

async function reportShutdown() {
async function reportShutdown(headers: HeadersInit) {
const signal = AbortSignal.timeout(5000)
return await client.shutdown({}, {signal})
return await client.shutdown({}, {headers, signal})
}

0 comments on commit cfa7296

Please sign in to comment.