Skip to content

Commit

Permalink
Merge branch 'w/2.8/improvement/ZENKO-4941' into tmp/octopus/w/2.9/im…
Browse files Browse the repository at this point in the history
…provement/ZENKO-4941
  • Loading branch information
bert-e committed Dec 3, 2024
2 parents 83c019b + a15cec0 commit 935d0d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/ctst/steps/utils/kubernetes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fs from 'fs';
import * as path from 'path';
import lockFile from 'proper-lockfile';
import { KubernetesHelper, Utils } from 'cli-testing';
Expand Down Expand Up @@ -84,6 +85,10 @@ export async function createJobAndWaitForCompletion(
const lockFilePath = path.join('/tmp', `${jobName}.lock`);
let releaseLock: (() => Promise<void>) | false = false;

if (!fs.existsSync(lockFilePath)) {
fs.writeFileSync(lockFilePath, 'job');
}

try {
// Acquire lock on the file
releaseLock = await lockFile.lock(lockFilePath, { stale: 600000 });
Expand Down Expand Up @@ -148,6 +153,7 @@ export async function createJobAndWaitForCompletion(
// Ensure the lock is released
if (releaseLock) {
await releaseLock();
fs.unlinkSync(lockFilePath);
world.logger.debug(`Released lock for job: ${jobName}`);
}
}
Expand Down

0 comments on commit 935d0d6

Please sign in to comment.