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

Use IP to identify orphaned allocation to be deleted #467

Merged

Conversation

mlguerrero12
Copy link
Collaborator

  • Del command should not fail when allocation is not found
  • The IP uniquely identifies the correct orphaned allocation that needs to be deleted during IP reconcilation.

Fixes #176

Del command should not fail when allocation is not found

Signed-off-by: Marcelo Guerrero <marguerr@redhat.com>
@coveralls
Copy link

coveralls commented May 22, 2024

Pull Request Test Coverage Report for Build 9204761188

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 21 of 45 (46.67%) changed or added relevant lines in 3 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.2%) to 72.204%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/reconciler/iploop.go 20 26 76.92%
cmd/whereabouts.go 1 9 11.11%
pkg/allocate/allocate.go 0 10 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/allocate/allocate.go 1 63.74%
cmd/whereabouts.go 2 46.34%
Totals Coverage Status
Change from base Build 9076868168: 0.2%
Covered Lines: 1130
Relevant Lines: 1565

💛 - Coveralls

return newips, err
updatedreservelist, ipforoverlappingrangeupdate = allocate.DeallocateIP(reservelist, containerID)
if updatedreservelist == nil {
// Do not fail if allocation is not present.
Copy link
Member

Choose a reason for hiding this comment

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

Cool, I'm following. I like that you logged the condition in allocate.DeallocateIP() -- thanks -- and can silently pass here otherwise. Nice one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that's exactly what I don't like about it lol.

I'm ok with it though, since we do not unit test that function.

Copy link
Member

@dougbtv dougbtv left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you Marcelo

@pliurh
Copy link

pliurh commented May 23, 2024

@mlguerrero12 It looks good to me. Just on a side note. Could you also change the function name of isPodAlive? It's misleading. It should be something likeisOrphanedIP.

Copy link
Collaborator

@maiqueb maiqueb left a comment

Choose a reason for hiding this comment

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

I just have a couple of opinionated nits.

You can merge it without my approval, I don't have better suggestions.

if err != nil {
return nil, nil, err
// DeallocateIP removes allocation from reserve list.
func DeallocateIP(reservelist []types.IPReservation, containerID string) ([]types.IPReservation, 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.

I really dislike this function's signature - you're at least improving by removing one return attribute from it ...

... but I think it still does make sense to return an error on certain conditions. It is up to the caller to know whether to swallow it or pass it along. CNI usually swallows all errors on DEL though.

Unfortunately, the fact we don't have associated unit tests makes my argument weaker, since there's no where we'd actually check the error against something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see your point but I still don't think an error should be returned. However, I will change the logic a bit and return nil for IP when the allocation is not present. It makes more sense in my opinion. When not found, return the reverlist untouched and nil for IP.

Copy link
Collaborator

@maiqueb maiqueb May 23, 2024

Choose a reason for hiding this comment

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

it's fine the way you currently have. Don't worry. If we had some unit tests at least to define the desired behavior, it could be arguable. Since we don't, let's just use the simplest thing.

I'm fine w/ what you have. Really.

However, I will change the logic a bit and return nil for IP when the allocation is not present.

This does make sense though.

return newips, err
updatedreservelist, ipforoverlappingrangeupdate = allocate.DeallocateIP(reservelist, containerID)
if updatedreservelist == nil {
// Do not fail if allocation is not present.
Copy link
Collaborator

Choose a reason for hiding this comment

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

that's exactly what I don't like about it lol.

I'm ok with it though, since we do not unit test that function.

The IP uniquely identifies the correct orphaned allocation
that needs to be deleted during IP reconcilation.

Fixes k8snetworkplumbingwg#176

Signed-off-by: Marcelo Guerrero <marguerr@redhat.com>
@mlguerrero12
Copy link
Collaborator Author

@maiqueb, @pliurh, thanks for you comments. I addressed them. Please have a look again.

Copy link
Member

@dougbtv dougbtv left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you

@dougbtv dougbtv merged commit 015bc84 into k8snetworkplumbingwg:master May 23, 2024
10 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.

ip-reconciler cleans up incorrect IP, leads to duplicate IP
5 participants