Skip to content
New issue

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

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

Already on GitHub? # to your account

retryOnConflict shouldnt' retry on NotFound #3192

Merged
merged 2 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/ipamd/ipamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,11 @@ func (c *IPAMContext) AnnotatePod(podName string, podNamespace string, key strin
if err == nil && pod == nil {
log.Warnf("get a nil pod for pod name %s and namespace %s", podName, podNamespace)
}
// since the GetPod() error has been decorated, we have to check key words
Copy link
Member

Choose a reason for hiding this comment

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

I would improve the comment to something like this to be more clear. But we can do as a follow up.

releasedIP is only set in the DelNetwork RPC call. We don’t want to error out on removing PodAnnotation when Pod is deleted and IP is being released.

// releasedIP is not empty meaning del path
if releasedIP != "" && err != nil && strings.Contains(err.Error(), "not found") {
return nil
}
return err
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/ipamd/ipamd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2295,8 +2295,7 @@ func TestAnnotatePod(t *testing.T) {

// Test that delete on a non-existant pod fails without crashing
err = mockContext.AnnotatePod("no-exist-name", "no-exist-namespace", "ip-address", "", ipTwo)
assert.Error(t, err)
assert.Equal(t, fmt.Errorf("error while trying to retrieve pod info: pods \"no-exist-name\" not found"), err)
assert.NoError(t, err)
}

func TestAddFeatureToCNINode(t *testing.T) {
Expand Down
Loading