Skip to content

Commit a37b27e

Browse files
authored
chore: introduce promiseall-no-unbounded-parallelism linter rule (#31592)
Since JavaScript is single-threaded, `Promise.all()` will only ever be used for I/O-bound tasks. However, I/O-parallelism isn't free either. Every async I/O-performing task launched will consume some FDs, and their amount is limited. If the amount of promises launched is a function of the input the program runs on, the system FDs might be exhausted. Some concurrency limit must be introduced. This linter rule exists to remind the programmer of that fact. It triggers on every `Promise.all()` invocation and cannot be resolved; the only solution is to think about it, and then silence this rule as proof that you thought about it. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent c1a4b97 commit a37b27e

File tree

240 files changed

+128669
-130160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+128669
-130160
lines changed

packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts

+4
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,16 @@ export class TestFixture extends ShellHelper {
529529

530530
// Bootstrap stacks have buckets that need to be cleaned
531531
const bucketNames = stacksToDelete.map(stack => outputFromStack('BucketName', stack)).filter(defined);
532+
// Parallelism will be reasonable
533+
// eslint-disable-next-line @aws-cdk/promiseall-no-unbounded-parallelism
532534
await Promise.all(bucketNames.map(b => this.aws.emptyBucket(b)));
533535
// The bootstrap bucket has a removal policy of RETAIN by default, so add it to the buckets to be cleaned up.
534536
this.bucketsToDelete.push(...bucketNames);
535537

536538
// Bootstrap stacks have ECR repositories with images which should be deleted
537539
const imageRepositoryNames = stacksToDelete.map(stack => outputFromStack('ImageRepositoryName', stack)).filter(defined);
540+
// Parallelism will be reasonable
541+
// eslint-disable-next-line @aws-cdk/promiseall-no-unbounded-parallelism
538542
await Promise.all(imageRepositoryNames.map(r => this.aws.deleteImageRepository(r)));
539543

540544
await this.aws.deleteStacks(

packages/@aws-cdk-testing/cli-integ/test/resource-pool.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ test('somewhat balance', async () => {
5151

5252
const keys = Object.keys(counters) as Array<keyof typeof counters> ;
5353
const pool = ResourcePool.withResources(POOL_NAME, keys);
54+
// eslint-disable-next-line @aws-cdk/promiseall-no-unbounded-parallelism
5455
await Promise.all(Array.from(range(N)).map(() =>
5556
pool.using(async (x) => {
5657
counters[x] += 1;

packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.managed-compute-environment.js.snapshot/BatchManagedComputeEnvironmentTestDefaultTestDeployAssertD4528F80.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.managed-compute-environment.js.snapshot/batch-stack.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.managed-compute-environment.js.snapshot/batch-stack.template.json

-106
Original file line numberDiff line numberDiff line change
@@ -986,112 +986,6 @@
986986
"UpdatePolicy": {}
987987
}
988988
},
989-
"noOptimalInstancesForARMSecurityGroup7157B016": {
990-
"Type": "AWS::EC2::SecurityGroup",
991-
"Properties": {
992-
"GroupDescription": "batch-stack/noOptimalInstancesForARM/SecurityGroup",
993-
"SecurityGroupEgress": [
994-
{
995-
"CidrIp": "0.0.0.0/0",
996-
"Description": "Allow all outbound traffic by default",
997-
"IpProtocol": "-1"
998-
}
999-
],
1000-
"VpcId": {
1001-
"Ref": "vpcA2121C38"
1002-
}
1003-
}
1004-
},
1005-
"noOptimalInstancesForARMInstanceProfileRole926AEEC5": {
1006-
"Type": "AWS::IAM::Role",
1007-
"Properties": {
1008-
"AssumeRolePolicyDocument": {
1009-
"Statement": [
1010-
{
1011-
"Action": "sts:AssumeRole",
1012-
"Effect": "Allow",
1013-
"Principal": {
1014-
"Service": "ec2.amazonaws.com"
1015-
}
1016-
}
1017-
],
1018-
"Version": "2012-10-17"
1019-
},
1020-
"ManagedPolicyArns": [
1021-
{
1022-
"Fn::Join": [
1023-
"",
1024-
[
1025-
"arn:",
1026-
{
1027-
"Ref": "AWS::Partition"
1028-
},
1029-
":iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
1030-
]
1031-
]
1032-
}
1033-
]
1034-
}
1035-
},
1036-
"noOptimalInstancesForARMInstanceProfile37BE9D32": {
1037-
"Type": "AWS::IAM::InstanceProfile",
1038-
"Properties": {
1039-
"Roles": [
1040-
{
1041-
"Ref": "noOptimalInstancesForARMInstanceProfileRole926AEEC5"
1042-
}
1043-
]
1044-
}
1045-
},
1046-
"noOptimalInstancesForARMF146AA4D": {
1047-
"Type": "AWS::Batch::ComputeEnvironment",
1048-
"Properties": {
1049-
"ComputeResources": {
1050-
"AllocationStrategy": "BEST_FIT_PROGRESSIVE",
1051-
"Ec2Configuration": [
1052-
{
1053-
"ImageIdOverride": {
1054-
"Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter"
1055-
},
1056-
"ImageType": "ECS_AL2"
1057-
}
1058-
],
1059-
"InstanceRole": {
1060-
"Fn::GetAtt": [
1061-
"noOptimalInstancesForARMInstanceProfile37BE9D32",
1062-
"Arn"
1063-
]
1064-
},
1065-
"InstanceTypes": [
1066-
"a1.large",
1067-
"m6g"
1068-
],
1069-
"MaxvCpus": 256,
1070-
"MinvCpus": 0,
1071-
"SecurityGroupIds": [
1072-
{
1073-
"Fn::GetAtt": [
1074-
"noOptimalInstancesForARMSecurityGroup7157B016",
1075-
"GroupId"
1076-
]
1077-
}
1078-
],
1079-
"Subnets": [
1080-
{
1081-
"Ref": "vpcPrivateSubnet1Subnet934893E8"
1082-
},
1083-
{
1084-
"Ref": "vpcPrivateSubnet2Subnet7031C2BA"
1085-
}
1086-
],
1087-
"Type": "EC2"
1088-
},
1089-
"ReplaceComputeEnvironment": false,
1090-
"State": "ENABLED",
1091-
"Type": "managed",
1092-
"UpdatePolicy": {}
1093-
}
1094-
},
1095989
"taggedCESecurityGroup82CCF59F": {
1096990
"Type": "AWS::EC2::SecurityGroup",
1097991
"Properties": {

packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.managed-compute-environment.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.managed-compute-environment.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.managed-compute-environment.js.snapshot/manifest.json

+2-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)