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

feat: support allocating IP with index from node chunk #55

Conversation

vasrem
Copy link
Collaborator

@vasrem vasrem commented Oct 9, 2024

This feature enables us to allocate the IP that is offset by index from the start of the range allocated for a particular node using CNI args. It is useful when a particular workload that runs as DaemonSet wants to allocate always the same IP, even if it's recreated.

@coveralls
Copy link

coveralls commented Oct 9, 2024

Coverage Status

coverage: 70.448% (+0.3%) from 70.122%
when pulling 9d75e01 on vasrem:feature/support-request-for-specific-ip-index-in-chunk
into 6649bfc on Mellanox:main.

if len(n.IPAM.RequestedIPs) > 0 {
return nil, fmt.Errorf("allocateIPWithIndex can't be used together with static IP request")
}
if n.IPAM.Features.AllocateDefaultGateway {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like we will never reach this code. This condition is already handled on line 209

}

// IPOffsetBy returns the IP that is offseted by index from the given IP
func IPOffsetBy(ip net.IP, index int32) net.IP {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use this one

func NextIPWithOffset(ip net.IP, offset int64) net.IP {

This feature enables us to allocate the IP that is offset by index from
the start of the range allocated for a particular node using CNI args.
It is useful when a particular workload that runs as DaemonSet wants to
allocate always the same IP, even if it's recreated.

Signed-off-by: Vasilis Remmas <[email protected]>
@vasrem vasrem force-pushed the feature/support-request-for-specific-ip-index-in-chunk branch from cb88c3f to 9d75e01 Compare October 10, 2024 07:05
Copy link
Collaborator

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

LGTM

@ykulazhenkov ykulazhenkov merged commit c91bd0c into Mellanox:main Oct 10, 2024
9 checks passed
@vasrem vasrem deleted the feature/support-request-for-specific-ip-index-in-chunk branch October 10, 2024 08:19
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.

4 participants