Commit cf57674
authored
perf(aws): Batch ECR image layer relationship loads (#2698)
### Type of change
- [x] Bug fix (non-breaking change that fixes an issue)
### Summary
Split ECR image layer relationship writes out of high-fanout node
ingestion queries and load them as scoped matchlinks in smaller batches.
This keeps the existing graph model intact while reducing transaction
memory pressure for repositories with many image layers.
### Related issues or links
N/A
### Breaking changes
None.
### How was this tested?
- Tested locally
```
2026-04-26 16:54:21,267 INFO cartography.intel.aws.ecr Loading 1 ECR repositories for region us-east-1 into graph.
2026-04-26 16:54:21,382 INFO cartography.client.core.tx Loaded 1 ECRRepository nodes
2026-04-26 16:54:21,382 INFO cartography.intel.aws.ecr Loading 1 ECR images and 1 ECR repository images in us-east-1 into graph.
2026-04-26 16:54:21,790 INFO cartography.client.core.tx Loaded 1 ECRImage nodes
2026-04-26 16:54:21,904 INFO cartography.client.core.tx Loaded 1 ECRRepositoryImage nodes
2026-04-26 16:54:21,904 INFO cartography.intel.aws.ecr_image_layers Syncing ECR image layers for region 'us-east-1' in account '<AWS_ACCOUNT_ID>'.
2026-04-26 16:54:21,944 INFO cartography.intel.aws.ecr_image_layers Found 1 distinct ECR image digests in graph for region us-east-1
2026-04-26 16:54:21,944 INFO cartography.intel.aws.ecr_image_layers Starting to fetch layers for 1 images...
2026-04-26 16:54:21,960 INFO cartography.intel.aws.ecr_image_layers Fetching layers for 1 images with 200 concurrent connections...
2026-04-26 16:54:22,738 INFO cartography.intel.aws.ecr_image_layers Fetched layer metadata for 1/1 images (100.0%)
2026-04-26 16:54:22,738 INFO cartography.intel.aws.ecr_image_layers Successfully fetched layers for 1/1 images
2026-04-26 16:54:22,738 INFO cartography.intel.aws.ecr_image_layers Extracted history commands for 10 layers
2026-04-26 16:54:22,739 INFO cartography.intel.aws.ecr_image_layers Successfully fetched layers for 1 images
2026-04-26 16:54:22,739 INFO cartography.intel.aws.ecr_image_layers Loading 10 image layers for region us-east-1 into graph.
2026-04-26 16:54:22,820 INFO cartography.client.core.tx Loaded 10 ECRImageLayer nodes
2026-04-26 16:54:22,820 INFO cartography.intel.aws.ecr_image_layers Loading 9 ECR image layer NEXT relationships for region us-east-1 into graph.
2026-04-26 16:54:22,857 INFO cartography.client.core.tx Loaded 9 (ECRImageLayer)-[NEXT]->(ECRImageLayer) relationships
2026-04-26 16:54:22,857 INFO cartography.intel.aws.ecr_image_layers Loading 1 ECR image HEAD relationships for region us-east-1 into graph.
2026-04-26 16:54:22,888 INFO cartography.client.core.tx Loaded 1 (ECRImage)-[HEAD]->(ECRImageLayer) relationships
2026-04-26 16:54:22,888 INFO cartography.intel.aws.ecr_image_layers Loading 1 ECR image TAIL relationships for region us-east-1 into graph.
2026-04-26 16:54:22,918 INFO cartography.client.core.tx Loaded 1 (ECRImage)-[TAIL]->(ECRImageLayer) relationships
2026-04-26 16:54:23,150 INFO cartography.client.core.tx Loaded 1 ECRImage nodes
2026-04-26 16:54:23,150 INFO cartography.intel.aws.ecr_image_layers Loading 10 ECR image HAS_LAYER relationships for region us-east-1 into graph.
2026-04-26 16:54:23,184 INFO cartography.client.core.tx Loaded 10 (ECRImage)-[HAS_LAYER]->(ECRImageLayer) relationships
2026-04-26 16:54:23,206 INFO cartography.graph.statement Completed ECRImageLayer statement #1
2026-04-26 16:54:23,225 INFO cartography.graph.statement Completed ECRImageLayer statement #2
2026-04-26 16:54:23,246 INFO cartography.graph.statement Completed ECRImageLayer statement #3
2026-04-26 16:54:23,266 INFO cartography.graph.statement Completed ECRImageLayer statement #4
2026-04-26 16:54:23,286 INFO cartography.graph.statement Completed ECRImageLayer statement #5
2026-04-26 16:54:23,286 INFO cartography.graph.job Finished job ECRImageLayer
2026-04-26 16:54:23,307 INFO cartography.graph.statement Completed NEXT statement #1
2026-04-26 16:54:23,307 INFO cartography.graph.job Finished job NEXT
2026-04-26 16:54:23,326 INFO cartography.graph.statement Completed HEAD statement #1
2026-04-26 16:54:23,326 INFO cartography.graph.job Finished job HEAD
2026-04-26 16:54:23,345 INFO cartography.graph.statement Completed TAIL statement #1
2026-04-26 16:54:23,345 INFO cartography.graph.job Finished job TAIL
2026-04-26 16:54:23,365 INFO cartography.graph.statement Completed HAS_LAYER statement #1
2026-04-26 16:54:23,365 INFO cartography.graph.job Finished job HAS_LAYER
```
### 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
- [ ] Screenshot showing the graph before and after changes.
- [x] New or updated unit/integration tests.
#### If you are adding or modifying a synced entity
N/A
#### If you are changing a node or relationship
N/A. This changes the load strategy for existing ECR image layer
relationships; it does not add or rename graph nodes or relationships.
#### If you are implementing a new intel module
N/A
### Notes for reviewers
The main behavior change is that `NEXT`, `HEAD`, `TAIL`, and `HAS_LAYER`
are loaded as flattened matchlink rows instead of as one-to-many
relationship arrays during node ingestion.
---------
Signed-off-by: Kunaal Sikka <[email protected]>1 parent 306249b commit cf57674
4 files changed
Lines changed: 323 additions & 10 deletions
File tree
- cartography
- intel/aws
- models/aws/ecr
- tests/unit/cartography/intel/aws
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| |||
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
42 | | - | |
| 47 | + | |
43 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
| |||
639 | 647 | | |
640 | 648 | | |
641 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
642 | 686 | | |
643 | 687 | | |
644 | 688 | | |
| |||
650 | 694 | | |
651 | 695 | | |
652 | 696 | | |
653 | | - | |
654 | | - | |
655 | | - | |
| 697 | + | |
| 698 | + | |
656 | 699 | | |
657 | 700 | | |
658 | 701 | | |
659 | 702 | | |
660 | 703 | | |
661 | 704 | | |
662 | 705 | | |
663 | | - | |
| 706 | + | |
664 | 707 | | |
665 | 708 | | |
666 | 709 | | |
667 | 710 | | |
668 | 711 | | |
669 | 712 | | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
670 | 761 | | |
671 | 762 | | |
672 | 763 | | |
| |||
679 | 770 | | |
680 | 771 | | |
681 | 772 | | |
682 | | - | |
683 | | - | |
684 | | - | |
| 773 | + | |
| 774 | + | |
685 | 775 | | |
686 | 776 | | |
687 | 777 | | |
688 | | - | |
| 778 | + | |
689 | 779 | | |
690 | 780 | | |
691 | 781 | | |
692 | 782 | | |
693 | 783 | | |
694 | 784 | | |
695 | 785 | | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
696 | 800 | | |
697 | 801 | | |
698 | 802 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
0 commit comments