Skip to content

Commit bd84267

Browse files
authored
Merge pull request #129 from depot/billy/fix/shutdown-headers
fix: make sure to pass the auth headers when reporting shutdown
2 parents 8acea26 + cfa7296 commit bd84267

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/tasks/buildkit.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ keepBytes = ${cacheSizeBytes}
241241
console.log(`BuildKit exited with error: ${error}`)
242242
}
243243

244-
await shutdown(rootDir, task)
244+
await shutdown(rootDir, task, headers)
245245
})
246246

247247
try {
@@ -255,15 +255,15 @@ keepBytes = ${cacheSizeBytes}
255255
}
256256

257257
// If we have successfully stopped buildkit, we can shutdown.
258-
await shutdown(rootDir, task)
258+
await shutdown(rootDir, task, headers)
259259
} catch (error) {
260260
throw error
261261
} finally {
262262
controller.abort()
263263
}
264264
}
265265

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

292292
// Report shutdown to the API to indicate that the machine is no longer available.
293-
await reportShutdown()
293+
await reportShutdown(headers)
294294
}
295295

296-
async function reportShutdown() {
296+
async function reportShutdown(headers: HeadersInit) {
297297
const signal = AbortSignal.timeout(5000)
298-
return await client.shutdown({}, {signal})
298+
return await client.shutdown({}, {headers, signal})
299299
}

0 commit comments

Comments
 (0)