Skip to content

Commit 92efb95

Browse files
committed
add more barriers to flaky test
1 parent 2ee3de9 commit 92efb95

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/core/src/awsService/ec2/sshKeyPair.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class SshKeyPair {
1717
private deleted: boolean = false
1818

1919
private constructor(
20-
private keyPath: string,
20+
private readonly keyPath: string,
2121
lifetime: number
2222
) {
2323
this.publicKeyPath = `${keyPath}.pub`
@@ -30,9 +30,9 @@ export class SshKeyPair {
3030

3131
public static async getSshKeyPair(keyPath: string, lifetime: number) {
3232
// Overwrite key if already exists
33-
if (await fs.existsFile(keyPath)) {
34-
await fs.delete(keyPath)
35-
}
33+
await fs.delete(keyPath, { force: true })
34+
await fs.delete(`${keyPath}.pub`, { force: true })
35+
3636
await SshKeyPair.generateSshKeyPair(keyPath)
3737
return new SshKeyPair(keyPath, lifetime)
3838
}
@@ -72,6 +72,10 @@ export class SshKeyPair {
7272
}
7373

7474
public async delete(): Promise<void> {
75+
if (await fs.existsDir(this.keyPath)) {
76+
throw new Error('ec2: key path points to directory, not file')
77+
}
78+
7579
await fs.delete(this.keyPath)
7680
await fs.delete(this.publicKeyPath)
7781

0 commit comments

Comments
 (0)