Commit 8a79bd4
authored
fix(aws): skip CodeBuild unsupported/timeout regions (#2390)
### Type of change
<!-- Mark the relevant option with an "x" -->
- [x] Bug fix (non-breaking change that fixes an issue)
### Summary
This PR hardens AWS CodeBuild sync so a single problematic region does
not fail the entire AWS sync run.
Changes:
- Pre-filters CodeBuild regions by intersecting requested regions with
`boto3` available CodeBuild regions across partitions.
- Skips unsupported regions with an explicit log message.
- Extends `aws_handle_regions` to treat regional endpoint timeout
connectivity errors (`ConnectTimeoutError`, `ReadTimeoutError`) as
skippable regional failures, similar to existing
`EndpointConnectionError` behavior.
- Adds/updates unit tests for unsupported-region skip, timeout skip
behavior, and non-skippable error propagation.
### Related issues or links
<!-- Include links to relevant issues or other pages. Use "Fixes #123"
or "Closes #123" to auto-close issues. -->
- Fixes #N/A
### Breaking changes
<!-- If this PR introduces breaking changes, describe the impact and
migration path. Otherwise, delete this section. -->
None.
### How was this tested?
<!-- Describe how you tested your changes. Include relevant details such
as test configuration, commands run, or manual testing steps. -->
### Checklist
#### General
- [x] I have read the [contributing
guidelines](https://cartography-cncf.github.io/cartography/dev/developer-guide.html).
- [x] The linter passes locally (`make lint`).
- [x] I have added/updated tests that prove my fix is effective or my
feature works.
#### Proof of functionality
<!-- Provide at least one of the following to help reviewers verify your
changes: -->
- [ ] Screenshot showing the graph before and after changes.
- [x] New or updated unit/integration tests.
#### If you are adding or modifying a synced entity
- [ ] Included Cartography sync logs from a real environment
demonstrating successful synchronization of the new/modified entity.
Logs should show:
- The sync job starting and completing without errors
- The number of nodes/relationships created or updated
- Example:
```
INFO:cartography.intel.aws.ec2:Loading 42 EC2 instances for region
us-east-1
INFO:cartography.intel.aws.ec2:Synced EC2 instances in 3.21 seconds
```
#### If you are changing a node or relationship
- [ ] Updated the [schema
documentation](https://github.com/cartography-cncf/cartography/tree/master/docs/root/modules).
- [ ] Updated the [schema
README](https://github.com/cartography-cncf/cartography/blob/master/docs/schema/README.md).
#### If you are implementing a new intel module
- [ ] Used the NodeSchema [data
model](https://cartography-cncf.github.io/cartography/dev/writing-intel-modules.html#defining-a-node).
### Notes for reviewers
<!-- Optional: Add any context that would help reviewers, such as areas
to focus on, design decisions, or open questions. -->
Root cause:
- CodeBuild regional iteration could hit per-region
endpoint/connectivity failures and fail the whole sync path.
Why this is safe:
- Scope is limited to region filtering and regional connectivity
exceptions.
- Non-skippable auth/config errors are still raised.
Errors now skipped:
- Unsupported CodeBuild regions (pre-filtered in CodeBuild sync).
- `EndpointConnectionError` (existing behavior).
- `ConnectTimeoutError` and `ReadTimeoutError` (new handling in regional
wrapper).
Errors still raised:
- Non-skippable auth/config errors, e.g. `InvalidToken` and other
unhandled `ClientError`s.
Redacted incident logs (as observed):
```text
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "https://codebuild.ca-west-1.amazonaws.com/"
urllib3.exceptions.ConnectTimeoutError: (<AWSHTTPSConnection(host='codebuild.ca-west-1.amazonaws.com', port=443)>, 'Connection to codebuild.ca-west-1.amazonaws.com timed out. (connect timeout=60)')
```
```text
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the AssumeRole operation:
User: arn:aws:sts::<redacted>:assumed-role/<redacted>/<session-id>
is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::<redacted>:role/SubImageScanRole
```
Signed-off-by: Kunaal Sikka <kunaal@subimage.io>1 parent cc602ea commit 8a79bd4
4 files changed
Lines changed: 113 additions & 1 deletion
File tree
- cartography
- intel/aws
- tests/unit/cartography
- intel/aws
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
19 | 35 | | |
20 | 36 | | |
21 | 37 | | |
| |||
113 | 129 | | |
114 | 130 | | |
115 | 131 | | |
116 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
117 | 150 | | |
118 | 151 | | |
119 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
718 | 720 | | |
719 | 721 | | |
720 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
721 | 729 | | |
722 | 730 | | |
723 | 731 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| |||
0 commit comments