Skip to content

libnetwork/ipamutils: various cleanups and refactor#42509

Closed
thaJeztah wants to merge 5 commits intomoby:masterfrom
thaJeztah:ipamutils_cleanup
Closed

libnetwork/ipamutils: various cleanups and refactor#42509
thaJeztah wants to merge 5 commits intomoby:masterfrom
thaJeztah:ipamutils_cleanup

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

Migrated from moby/libnetwork#2593
closes moby/libnetwork#2593

Created using:

curl -fsSL https://patch-diff.githubusercontent.com/raw/moby/libnetwork/pull/2593.patch | git am --3way -S --directory=libnetwork
  • ipamutils: use RWMutex to allow concurrent reads
  • ipamutils: reformat for readability, and improve godoc
  • ipamutils: un-export global variables, and use accessors instead
    The GetLocalScopeDefaultNetworks() and GetGlobalScopeDefaultNetworks() protect these variables with a lock, but various parts in the code were directly accessing the variables without locks.
  • ipamutils: generate default pools on first use, instead of init()
    This package defines the NetworkToSplit type. Curently importing the package also initializes the default address pools (which may not be needed, e.g., when used in the client.
    This patch changes initialization to happen on first use, instead of init(), to allow the package to be imported without initializing these pools.

@thaJeztah thaJeztah added status/2-code-review area/networking Networking kind/refactor PR's that refactor, or clean-up code labels Jun 10, 2021
@thaJeztah thaJeztah marked this pull request as draft June 10, 2021 15:03
@thaJeztah thaJeztah marked this pull request as ready for review June 16, 2021 17:05
The `GetLocalScopeDefaultNetworks()` and `GetGlobalScopeDefaultNetworks()`
protect these variables with a lock, but various parts in the code
were directly accessing the variables without locks.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This package defines the `NetworkToSplit` type. Curently importing
the package also initializes the default address pools (which may
not be needed, e.g., when used in the client.

This patch changes initialization to happen on first use, instead
of `init()`, to allow the package to be imported without initializing
these pools.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@corhere
Copy link
Copy Markdown
Contributor

corhere commented Mar 31, 2023

@corhere corhere closed this Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking Networking kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants