Skip to content

Commit 72bd48a

Browse files
committed
fix: update cleanup
1 parent df0b217 commit 72bd48a

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

scripts/cleanupAtlasTestLeftovers.test.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,27 @@ async function findAllTestProjects(client: ApiClient, orgId: string): Promise<Gr
3838
async function deleteAllClustersOnStaleProject(client: ApiClient, projectId: string): Promise<string[]> {
3939
const errors: string[] = [];
4040

41-
try {
42-
const allClusters = await client
43-
.listClusters({
44-
params: {
45-
path: {
46-
groupId: projectId || "",
47-
},
41+
const allClusters = await client
42+
.listClusters({
43+
params: {
44+
path: {
45+
groupId: projectId || "",
4846
},
49-
})
50-
.then((res) => res.results || []);
47+
},
48+
})
49+
.then((res) => res.results || []);
5150

52-
const results = await Promise.allSettled(
53-
allClusters.map((cluster) =>
54-
client.deleteCluster({
51+
await Promise.allSettled(
52+
allClusters.map(async (cluster) => {
53+
try {
54+
await client.deleteCluster({
5555
params: { path: { groupId: projectId || "", clusterName: cluster.name || "" } },
56-
})
57-
)
58-
);
59-
60-
results.forEach((result, index) => {
61-
if (result.status === "rejected") {
62-
const clusterName = allClusters[index]?.name || "unknown";
63-
errors.push(`Failed to delete cluster ${clusterName} in project ${projectId}: ${result.reason}`);
56+
});
57+
} catch (error) {
58+
errors.push(`Failed to delete cluster ${cluster.name} in project ${projectId}: ${String(error)}`);
6459
}
65-
});
66-
} catch (error) {
67-
errors.push(`Failed to list clusters for project ${projectId}: ${String(error)}`);
68-
}
60+
})
61+
);
6962

7063
return errors;
7164
}

0 commit comments

Comments
 (0)