[dev] use cidr based ip notation when merging lld addrs #11000
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of change
To create a new link layer device address, we are required to populate an object which among other things includes the IP address in CIDR notation. The code in the state package breaks this down into an IP and CIDR value which is then persisted to the DB.
When we retrieve a link layer device address from disk, we can only access the IP and subnet CIDR values.
The changes introduced by #10979 (this commit in particular) included additional logic to backfill the provider-specific IDs to existing link layer devices and their addresses. The introduced merge code would create a new set of link layer device addresses by re-using the original values (reported by the machiner) plus the provider-specific IDs.
Unfortunately, that code contained a bug: instead of converting the existing address into CIDR format, it pulled the data from the
SubnetCIDR
method of the link layer device address. By passing that value back into the state, we ended up with invalid IP addresses for the machines (following x.y.z.0 and x.y.0.0 patterns due to the way that the state code works).This PR contributes a small fix where we basically recombine the existing IP and CIDR into an IP-in-CIDR-format value which we can then pass to the state code and get the correct address values persisted to the DB.
QA steps
Run
nw-network-health-aws
with this PR (this is how we caught the bug in the first place)