Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manager/allocator: lift portAllocator out of package cnmallocator #3168

Merged
merged 3 commits into from Feb 23, 2024

Conversation

corhere
Copy link
Contributor

@corhere corhere commented Feb 20, 2024

- What I did
Lifted portAllocator into the allocator package from cnmallocator to separate the concerns

- How I did it
By shuffling code around

- How to test it
CI

- Description for the changelog

N/A; refactor of unexported code

@corhere corhere force-pushed the lift-portallocator branch 2 times, most recently from d0a1c5e to 38585b4 Compare February 21, 2024 19:12
Replicate the port allocation-related tests from the CNM network
allocator's test corpus in preparation for lifting port allocation into
allocator.Allocator.

Signed-off-by: Cory Snider <csnider@mirantis.com>
The portAllocator constructor function newPortAllocator() takes no
arguments; all its initial state is taken from hardcoded constants in
the source code. Any failure to construct a port allocator must
therefore be the result of a bug in the code, which can only be fixed
with a code change. As there is nothing the caller can do at runtime to
cause the failure, there is little value in returning the error to the
caller. Change the constructor to panic on failure instead.

Signed-off-by: Cory Snider <csnider@mirantis.com>
The port allocation logic does not depend on the network allocator
implementation in any meaningful way. It has no knowledge of the CNM
network allocator's state, and it does not need to change if the
network allocator changes. Allocating node ports is fundamentally a
seaparate concern from allocating network resources for services and
tasks. Therefore the low-level network allocator should not be
responsible for allocating both. Lift the port allocator into the
Allocator's network context as a sibling of the low-level network
allocator.

Signed-off-by: Cory Snider <csnider@mirantis.com>
@codecov-commenter
Copy link

Codecov Report

Merging #3168 (6531bf8) into master (9afd813) will decrease coverage by 0.12%.
Report is 37 commits behind head on master.
The diff coverage is 72.34%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3168      +/-   ##
==========================================
- Coverage   61.75%   61.63%   -0.12%     
==========================================
  Files         155      155              
  Lines       31143    31144       +1     
==========================================
- Hits        19232    19197      -35     
- Misses      10371    10399      +28     
- Partials     1540     1548       +8     

@dperny dperny merged commit 6531bf8 into moby:master Feb 23, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants