src: change sticky disk key to repo name
This commit is contained in:
parent
7cbe92e7ed
commit
bda6587832
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14
src/main.ts
14
src/main.ts
|
@ -206,14 +206,20 @@ async function getWithRetry(client: AxiosInstance, url: string, formData: FormDa
|
||||||
throw new Error('Max retries reached');
|
throw new Error('Max retries reached');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getStickyDisk(dockerfilePath: string, retryCondition: (error: AxiosError) => boolean, options?: {signal?: AbortSignal}): Promise<unknown> {
|
async function getStickyDisk(retryCondition: (error: AxiosError) => boolean, options?: {signal?: AbortSignal}): Promise<unknown> {
|
||||||
const client = await getBlacksmithAgentClient();
|
const client = await getBlacksmithAgentClient();
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('stickyDiskKey', dockerfilePath);
|
// TODO(adityamaru): Support a stickydisk-per-build flag that will namespace the stickydisks by Dockerfile.
|
||||||
|
// For now, we'll use the repo name as the stickydisk key.
|
||||||
|
const repoName = process.env.GITHUB_REPO_NAME || '';
|
||||||
|
if (repoName === '') {
|
||||||
|
throw new Error('GITHUB_REPO_NAME is not set');
|
||||||
|
}
|
||||||
|
formData.append('stickyDiskKey', repoName);
|
||||||
formData.append('region', process.env.BLACKSMITH_REGION || 'eu-central');
|
formData.append('region', process.env.BLACKSMITH_REGION || 'eu-central');
|
||||||
formData.append('installationModelID', process.env.BLACKSMITH_INSTALLATION_MODEL_ID || '');
|
formData.append('installationModelID', process.env.BLACKSMITH_INSTALLATION_MODEL_ID || '');
|
||||||
formData.append('vmID', process.env.VM_ID || '');
|
formData.append('vmID', process.env.VM_ID || '');
|
||||||
core.debug(`Getting sticky disk for ${dockerfilePath}`);
|
core.debug(`Getting sticky disk for ${repoName}`);
|
||||||
core.debug('FormData contents:');
|
core.debug('FormData contents:');
|
||||||
for (const pair of formData.entries()) {
|
for (const pair of formData.entries()) {
|
||||||
core.debug(`${pair[0]}: ${pair[1]}`);
|
core.debug(`${pair[0]}: ${pair[1]}`);
|
||||||
|
@ -421,7 +427,7 @@ async function getBuilderAddr(inputs: context.Inputs, dockerfilePath: string): P
|
||||||
|
|
||||||
let buildResponse: {docker_build_id: string} | null = null;
|
let buildResponse: {docker_build_id: string} | null = null;
|
||||||
try {
|
try {
|
||||||
await getStickyDisk(dockerfilePath, retryCondition, {signal: controller.signal});
|
await getStickyDisk(retryCondition, {signal: controller.signal});
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
await maybeFormatBlockDevice(device);
|
await maybeFormatBlockDevice(device);
|
||||||
buildResponse = await reportBuild(dockerfilePath);
|
buildResponse = await reportBuild(dockerfilePath);
|
||||||
|
|
Loading…
Reference in New Issue