Skip to content

Commit

Permalink
Merge branch 'M3-8953' of github.com:jaalah-akamai/manager into M3-8953
Browse files Browse the repository at this point in the history
  • Loading branch information
jaalah committed Dec 3, 2024
2 parents 9559a04 + 4d7799e commit 25f82d6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/manager/src/queries/object-storage/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,21 @@ export const getAllBucketsFromEndpoints = async (
return { buckets: [], errors: [] };
}

// Avoid multiple getBucket calls for the same region while also
// keeping some endpoint information in case of an error being
// returned for that region
const uniqueRegions: Set<string> = new Set();
const filteredEndpoints: ObjectStorageEndpoint[] = [];

for (const endpoint of endpoints) {
if (!uniqueRegions.has(endpoint.region)) {
filteredEndpoints.push(endpoint);
}
uniqueRegions.add(endpoint.region);
}

const results = await Promise.all(
endpoints.map((endpoint) =>
filteredEndpoints.map((endpoint) =>
getAll<ObjectStorageBucket>((params) =>
getBucketsInRegion(endpoint.region, params)
)()
Expand All @@ -187,7 +200,7 @@ export const getAllBucketsFromEndpoints = async (
}
});

if (errors.length === endpoints.length) {
if (errors.length === filteredEndpoints.length) {
throw new Error('Unable to get Object Storage buckets.');
}

Expand Down

0 comments on commit 25f82d6

Please sign in to comment.