Use cache key to segment lock folders
parent
7952083ef0
commit
ffc99d1acf
|
|
@ -654,6 +654,12 @@ class SharedWorkspaceLocking {
|
|||
return (yield SharedWorkspaceLocking.ReadLines(`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/`)).map((x) => x.replace(`/`, ``));
|
||||
});
|
||||
}
|
||||
static DoesWorkspaceTopLevelExist(buildParametersContext) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const results = (yield SharedWorkspaceLocking.ReadLines(`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}`)).map((x) => x.replace(`/`, ``));
|
||||
return results.includes(buildParametersContext.cacheKey);
|
||||
});
|
||||
}
|
||||
static GetAllLocks(workspace, buildParametersContext) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!(yield SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
||||
|
|
@ -668,6 +674,7 @@ class SharedWorkspaceLocking {
|
|||
return;
|
||||
}
|
||||
cloud_runner_logger_1.default.log(`run agent ${runId} is trying to access a workspace`);
|
||||
if (yield SharedWorkspaceLocking.DoesWorkspaceTopLevelExist(buildParametersContext)) {
|
||||
const workspaces = yield SharedWorkspaceLocking.GetFreeWorkspaces(buildParametersContext);
|
||||
for (const element of workspaces) {
|
||||
if (yield SharedWorkspaceLocking.LockWorkspace(element, runId, buildParametersContext)) {
|
||||
|
|
@ -675,6 +682,7 @@ class SharedWorkspaceLocking {
|
|||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
const workspace = yield SharedWorkspaceLocking.CreateWorkspace(workspaceIfCreated, buildParametersContext, runId);
|
||||
cloud_runner_logger_1.default.log(`run agent ${runId} didn't find a free workspace so created: ${workspace}`);
|
||||
return workspace;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -16,6 +16,13 @@ export class SharedWorkspaceLocking {
|
|||
)
|
||||
).map((x) => x.replace(`/`, ``));
|
||||
}
|
||||
public static async DoesWorkspaceTopLevelExist(buildParametersContext: BuildParameters) {
|
||||
const results = (await SharedWorkspaceLocking.ReadLines(`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}`)).map(
|
||||
(x) => x.replace(`/`, ``),
|
||||
);
|
||||
|
||||
return results.includes(buildParametersContext.cacheKey);
|
||||
}
|
||||
public static async GetAllLocks(workspace: string, buildParametersContext: BuildParameters): Promise<string[]> {
|
||||
if (!(await SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
||||
throw new Error("Workspace doesn't exist, can't call get all locks");
|
||||
|
|
@ -38,6 +45,7 @@ export class SharedWorkspaceLocking {
|
|||
|
||||
CloudRunnerLogger.log(`run agent ${runId} is trying to access a workspace`);
|
||||
|
||||
if (await SharedWorkspaceLocking.DoesWorkspaceTopLevelExist(buildParametersContext)) {
|
||||
const workspaces = await SharedWorkspaceLocking.GetFreeWorkspaces(buildParametersContext);
|
||||
for (const element of workspaces) {
|
||||
if (await SharedWorkspaceLocking.LockWorkspace(element, runId, buildParametersContext)) {
|
||||
|
|
@ -46,6 +54,7 @@ export class SharedWorkspaceLocking {
|
|||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const workspace = await SharedWorkspaceLocking.CreateWorkspace(workspaceIfCreated, buildParametersContext, runId);
|
||||
CloudRunnerLogger.log(`run agent ${runId} didn't find a free workspace so created: ${workspace}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue