Skip to content

Conversation

@cloutierMat
Copy link
Member

Motivation

This PR aims to fix PortRange.subrange to return an instance of a subclass instead of harcoding PortRange.

While working on Elasticache and MemoryDb in container, I realised it was not possible to create more than 1 Redis/Valkey container at once. This was due to PortRange not validating that the port is available on the host. Using _DockerPortRange would fix the issue, however the subrange method would return an instance of PortRange instead of _DockerPortRange.

Changes

  • use self.__class__ to retrieve the instance's class
  • Add simple unit test

@cloutierMat cloutierMat added area: docker Use Docker with LocalStack semver: patch Non-breaking changes which can be included in patch releases labels Aug 13, 2025
@github-actions
Copy link

github-actions bot commented Aug 13, 2025

Test Results - Preflight, Unit

22 107 tests  +1   20 372 ✅ +1   6m 21s ⏱️ -9s
     1 suites ±0    1 735 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 4301385. ± Comparison against base commit a1ae8f0.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Aug 13, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 7s ⏱️ -1s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 4301385. ± Comparison against base commit a1ae8f0.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Aug 13, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files  ±0      5 suites  ±0   2h 20m 35s ⏱️ -37s
4 987 tests ±0  4 395 ✅ ±0  592 💤 ±0  0 ❌ ±0 
4 993 runs  ±0  4 395 ✅ ±0  598 💤 ±0  0 ❌ ±0 

Results for commit 4301385. ± Comparison against base commit a1ae8f0.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Aug 13, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 45m 25s ⏱️ +19s
4 628 tests ±0  4 188 ✅ ±0  440 💤 ±0  0 ❌ ±0 
4 630 runs  ±0  4 188 ✅ ±0  442 💤 ±0  0 ❌ ±0 

Results for commit 4301385. ± Comparison against base commit a1ae8f0.

♻️ This comment has been updated with latest results.

@cloutierMat cloutierMat marked this pull request as ready for review August 13, 2025 04:06
@cloutierMat cloutierMat requested review from dfangl and simonrw August 13, 2025 04:06
Copy link
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a minor suggestion, but otherwise definitely makes sense!


port_range = PortRange(start, end)
# ensures that we return an instance of a subclass
port_range = self.__class__(start, end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
port_range = self.__class__(start, end)
port_range = type(self)(start, end)

suggestion: I think this is more idiomatic than accessing the dunder class method

@cloutierMat cloutierMat merged commit 5a920cb into main Aug 13, 2025
40 checks passed
@cloutierMat cloutierMat deleted the fix-port-subrange-from-subclass branch August 13, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docker Use Docker with LocalStack semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants