fix integration test: locking
parent
9aaaac967c
commit
3ea2f18b21
|
|
@ -5266,9 +5266,14 @@ class SharedWorkspaceLocking {
|
|||
const workspaces = yield SharedWorkspaceLocking.GetAllWorkspaces(buildParametersContext);
|
||||
for (const element of workspaces) {
|
||||
yield new Promise((promise) => setTimeout(promise, 1500));
|
||||
if (!(yield SharedWorkspaceLocking.IsWorkspaceLocked(element, buildParametersContext)) &&
|
||||
(yield SharedWorkspaceLocking.IsWorkspaceBelowMax(``, buildParametersContext))) {
|
||||
const isLocked = yield SharedWorkspaceLocking.IsWorkspaceLocked(element, buildParametersContext);
|
||||
const isBelowMax = yield SharedWorkspaceLocking.IsWorkspaceBelowMax(element, buildParametersContext);
|
||||
if (!isLocked && isBelowMax) {
|
||||
result.push(element);
|
||||
cloud_runner_logger_1.default.log(`workspace ${element} is free`);
|
||||
}
|
||||
else {
|
||||
cloud_runner_logger_1.default.log(`workspace ${element} is NOT free ${!isLocked} ${isBelowMax}`);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -5356,12 +5361,8 @@ class SharedWorkspaceLocking {
|
|||
}
|
||||
static ReleaseWorkspace(workspace, runId, buildParametersContext) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!(yield SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
||||
return true;
|
||||
}
|
||||
const file = (yield SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext)).filter((x) => x.includes(`_${runId}_lock`));
|
||||
cloud_runner_logger_1.default.log(`${JSON.stringify(yield SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext))}`);
|
||||
cloud_runner_logger_1.default.log(`Deleting file ${file}`);
|
||||
cloud_runner_logger_1.default.log(`Deleting lock ${workspace}/${file}`);
|
||||
cloud_runner_logger_1.default.log(`aws s3 rm ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/${workspace}/${file}`);
|
||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`aws s3 rm ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/${workspace}/${file}`, false, true);
|
||||
return !SharedWorkspaceLocking.HasWorkspaceLock(workspace, runId, buildParametersContext);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -108,11 +108,13 @@ export class SharedWorkspaceLocking {
|
|||
const workspaces = await SharedWorkspaceLocking.GetAllWorkspaces(buildParametersContext);
|
||||
for (const element of workspaces) {
|
||||
await new Promise((promise) => setTimeout(promise, 1500));
|
||||
if (
|
||||
!(await SharedWorkspaceLocking.IsWorkspaceLocked(element, buildParametersContext)) &&
|
||||
(await SharedWorkspaceLocking.IsWorkspaceBelowMax(``, buildParametersContext))
|
||||
) {
|
||||
const isLocked = await SharedWorkspaceLocking.IsWorkspaceLocked(element, buildParametersContext);
|
||||
const isBelowMax = await SharedWorkspaceLocking.IsWorkspaceBelowMax(element, buildParametersContext);
|
||||
if (!isLocked && isBelowMax) {
|
||||
result.push(element);
|
||||
CloudRunnerLogger.log(`workspace ${element} is free`);
|
||||
} else {
|
||||
CloudRunnerLogger.log(`workspace ${element} is NOT free ${!isLocked} ${isBelowMax}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -245,16 +247,10 @@ export class SharedWorkspaceLocking {
|
|||
runId: string,
|
||||
buildParametersContext: BuildParameters,
|
||||
): Promise<boolean> {
|
||||
if (!(await SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
||||
return true;
|
||||
}
|
||||
const file = (await SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext)).filter((x) =>
|
||||
x.includes(`_${runId}_lock`),
|
||||
);
|
||||
CloudRunnerLogger.log(
|
||||
`${JSON.stringify(await SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext))}`,
|
||||
);
|
||||
CloudRunnerLogger.log(`Deleting file ${file}`);
|
||||
CloudRunnerLogger.log(`Deleting lock ${workspace}/${file}`);
|
||||
CloudRunnerLogger.log(
|
||||
`aws s3 rm ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/${workspace}/${file}`,
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue