fixes
parent
b4f87f2bcb
commit
716c604f16
|
@ -5749,7 +5749,7 @@ class SharedWorkspaceLocking {
|
||||||
return lines.map((x) => x.replace(`/`, ``)).includes(buildParametersContext.cacheKey);
|
return lines.map((x) => x.replace(`/`, ``)).includes(buildParametersContext.cacheKey);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static GetAllLocks(workspace, buildParametersContext) {
|
static GetAllLocksForWorkspace(workspace, buildParametersContext) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!(yield SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
if (!(yield SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -5790,12 +5790,12 @@ class SharedWorkspaceLocking {
|
||||||
}
|
}
|
||||||
static DoesWorkspaceExist(workspace, buildParametersContext) {
|
static DoesWorkspaceExist(workspace, buildParametersContext) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return ((yield SharedWorkspaceLocking.GetAllWorkspaces(buildParametersContext)).filter((x) => x.endsWith(`${workspace}_workspace`)).length > 0);
|
return ((yield SharedWorkspaceLocking.GetAllWorkspaces(buildParametersContext)).filter((x) => x.includes(workspace) && x.endsWith(`_workspace`)).length > 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static HasWorkspaceLock(workspace, runId, buildParametersContext) {
|
static HasWorkspaceLock(workspace, runId, buildParametersContext) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const locks = (yield SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext))
|
const locks = (yield SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext))
|
||||||
.map((x) => {
|
.map((x) => {
|
||||||
return {
|
return {
|
||||||
name: x,
|
name: x,
|
||||||
|
@ -5867,12 +5867,6 @@ class SharedWorkspaceLocking {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const files = yield SharedWorkspaceLocking.ReadLines(`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/`);
|
const files = yield SharedWorkspaceLocking.ReadLines(`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/`);
|
||||||
const workspaceFileDoesNotExists = files.filter((x) => {
|
|
||||||
return x.endsWith(`${workspace}_workspace`);
|
|
||||||
}).length === 0;
|
|
||||||
if (workspaceFileDoesNotExists) {
|
|
||||||
throw new Error(`Workspace file doesn't exist`);
|
|
||||||
}
|
|
||||||
const lockFilesExist = files.filter((x) => {
|
const lockFilesExist = files.filter((x) => {
|
||||||
return x.includes(workspace) && x.includes(`_lock`);
|
return x.includes(workspace) && x.includes(`_lock`);
|
||||||
}).length > 0;
|
}).length > 0;
|
||||||
|
@ -5916,7 +5910,7 @@ class SharedWorkspaceLocking {
|
||||||
}
|
}
|
||||||
static ReleaseWorkspace(workspace, runId, buildParametersContext) {
|
static ReleaseWorkspace(workspace, runId, buildParametersContext) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const files = yield SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext);
|
const files = yield SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext);
|
||||||
const file = files.find((x) => x.endsWith(`${workspace}_workspace_lock`) && x.includes(runId));
|
const file = files.find((x) => x.endsWith(`${workspace}_workspace_lock`) && x.includes(runId));
|
||||||
cloud_runner_logger_1.default.log(`All Locks ${files} ${workspace} ${runId}`);
|
cloud_runner_logger_1.default.log(`All Locks ${files} ${workspace} ${runId}`);
|
||||||
cloud_runner_logger_1.default.log(`Deleting lock ${workspace}/${file}`);
|
cloud_runner_logger_1.default.log(`Deleting lock ${workspace}/${file}`);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -29,7 +29,10 @@ export class SharedWorkspaceLocking {
|
||||||
|
|
||||||
return lines.map((x) => x.replace(`/`, ``)).includes(buildParametersContext.cacheKey);
|
return lines.map((x) => x.replace(`/`, ``)).includes(buildParametersContext.cacheKey);
|
||||||
}
|
}
|
||||||
public static async GetAllLocks(workspace: string, buildParametersContext: BuildParameters): Promise<string[]> {
|
public static async GetAllLocksForWorkspace(
|
||||||
|
workspace: string,
|
||||||
|
buildParametersContext: BuildParameters,
|
||||||
|
): Promise<string[]> {
|
||||||
if (!(await SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
if (!(await SharedWorkspaceLocking.DoesWorkspaceExist(workspace, buildParametersContext))) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -86,8 +89,8 @@ export class SharedWorkspaceLocking {
|
||||||
|
|
||||||
public static async DoesWorkspaceExist(workspace: string, buildParametersContext: BuildParameters) {
|
public static async DoesWorkspaceExist(workspace: string, buildParametersContext: BuildParameters) {
|
||||||
return (
|
return (
|
||||||
(await SharedWorkspaceLocking.GetAllWorkspaces(buildParametersContext)).filter((x) =>
|
(await SharedWorkspaceLocking.GetAllWorkspaces(buildParametersContext)).filter(
|
||||||
x.endsWith(`${workspace}_workspace`),
|
(x) => x.includes(workspace) && x.endsWith(`_workspace`),
|
||||||
).length > 0
|
).length > 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +99,7 @@ export class SharedWorkspaceLocking {
|
||||||
runId: string,
|
runId: string,
|
||||||
buildParametersContext: BuildParameters,
|
buildParametersContext: BuildParameters,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const locks = (await SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext))
|
const locks = (await SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext))
|
||||||
.map((x) => {
|
.map((x) => {
|
||||||
return {
|
return {
|
||||||
name: x,
|
name: x,
|
||||||
|
@ -189,15 +192,6 @@ export class SharedWorkspaceLocking {
|
||||||
`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/`,
|
`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const workspaceFileDoesNotExists =
|
|
||||||
files.filter((x) => {
|
|
||||||
return x.endsWith(`${workspace}_workspace`);
|
|
||||||
}).length === 0;
|
|
||||||
|
|
||||||
if (workspaceFileDoesNotExists) {
|
|
||||||
throw new Error(`Workspace file doesn't exist`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const lockFilesExist =
|
const lockFilesExist =
|
||||||
files.filter((x) => {
|
files.filter((x) => {
|
||||||
return x.includes(workspace) && x.includes(`_lock`);
|
return x.includes(workspace) && x.includes(`_lock`);
|
||||||
|
@ -267,7 +261,7 @@ export class SharedWorkspaceLocking {
|
||||||
runId: string,
|
runId: string,
|
||||||
buildParametersContext: BuildParameters,
|
buildParametersContext: BuildParameters,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const files = await SharedWorkspaceLocking.GetAllLocks(workspace, buildParametersContext);
|
const files = await SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext);
|
||||||
const file = files.find((x) => x.endsWith(`${workspace}_workspace_lock`) && x.includes(runId));
|
const file = files.find((x) => x.endsWith(`${workspace}_workspace_lock`) && x.includes(runId));
|
||||||
CloudRunnerLogger.log(`All Locks ${files} ${workspace} ${runId}`);
|
CloudRunnerLogger.log(`All Locks ${files} ${workspace} ${runId}`);
|
||||||
CloudRunnerLogger.log(`Deleting lock ${workspace}/${file}`);
|
CloudRunnerLogger.log(`Deleting lock ${workspace}/${file}`);
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe('Cloud Runner Locking', () => {
|
||||||
expect(lines.map((x) => x.replace(`/`, ``)).includes(buildParameters.cacheKey));
|
expect(lines.map((x) => x.replace(`/`, ``)).includes(buildParameters.cacheKey));
|
||||||
expect(await SharedWorkspaceLocking.DoesCacheKeyTopLevelExist(buildParameters)).toBeTruthy();
|
expect(await SharedWorkspaceLocking.DoesCacheKeyTopLevelExist(buildParameters)).toBeTruthy();
|
||||||
expect(await SharedWorkspaceLocking.DoesWorkspaceExist(newWorkspaceName, buildParameters)).toBeTruthy();
|
expect(await SharedWorkspaceLocking.DoesWorkspaceExist(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
const allLocks = await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName, buildParameters);
|
const allLocks = await SharedWorkspaceLocking.GetAllLocksForWorkspace(newWorkspaceName, buildParameters);
|
||||||
expect(
|
expect(
|
||||||
(
|
(
|
||||||
await SharedWorkspaceLocking.ReadLines(
|
await SharedWorkspaceLocking.ReadLines(
|
||||||
|
@ -66,11 +66,14 @@ describe('Cloud Runner Locking', () => {
|
||||||
const isExpectedLockedAfterLocking =
|
const isExpectedLockedAfterLocking =
|
||||||
(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)) === true;
|
(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)) === true;
|
||||||
expect(isExpectedLockedAfterLocking).toBeTruthy();
|
expect(isExpectedLockedAfterLocking).toBeTruthy();
|
||||||
const locksBeforeRelease = await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName, buildParameters);
|
const locksBeforeRelease = await SharedWorkspaceLocking.GetAllLocksForWorkspace(
|
||||||
|
newWorkspaceName,
|
||||||
|
buildParameters,
|
||||||
|
);
|
||||||
CloudRunnerLogger.log(JSON.stringify(locksBeforeRelease, undefined, 4));
|
CloudRunnerLogger.log(JSON.stringify(locksBeforeRelease, undefined, 4));
|
||||||
expect(locksBeforeRelease.length).toBe(1);
|
expect(locksBeforeRelease.length).toBe(1);
|
||||||
await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId, buildParameters);
|
await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId, buildParameters);
|
||||||
const locks = await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName, buildParameters);
|
const locks = await SharedWorkspaceLocking.GetAllLocksForWorkspace(newWorkspaceName, buildParameters);
|
||||||
expect(locks.length).toBe(0);
|
expect(locks.length).toBe(0);
|
||||||
const isExpectedNotLockedAfterReleasing =
|
const isExpectedNotLockedAfterReleasing =
|
||||||
(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)) === false;
|
(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)) === false;
|
||||||
|
@ -175,7 +178,7 @@ describe('Cloud Runner Locking', () => {
|
||||||
expect(await SharedWorkspaceLocking.HasWorkspaceLock(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
expect(await SharedWorkspaceLocking.HasWorkspaceLock(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||||
expect(await SharedWorkspaceLocking.DoesWorkspaceExist(newWorkspaceName, buildParameters)).toBeTruthy();
|
expect(await SharedWorkspaceLocking.DoesWorkspaceExist(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
expect(await SharedWorkspaceLocking.GetAllWorkspaces(buildParameters)).toHaveLength(1);
|
expect(await SharedWorkspaceLocking.GetAllWorkspaces(buildParameters)).toHaveLength(1);
|
||||||
expect(await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName, buildParameters)).toHaveLength(1);
|
expect(await SharedWorkspaceLocking.GetAllLocksForWorkspace(newWorkspaceName, buildParameters)).toHaveLength(1);
|
||||||
expect(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)).toBeTruthy();
|
expect(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
expect(await SharedWorkspaceLocking.GetFreeWorkspaces(buildParameters)).toHaveLength(0);
|
expect(await SharedWorkspaceLocking.GetFreeWorkspaces(buildParameters)).toHaveLength(0);
|
||||||
}, 150000);
|
}, 150000);
|
||||||
|
|
Loading…
Reference in New Issue