Skip to content

Don't assign IPs from terminating / finalizing ippools #10248

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

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

liuxu623
Copy link
Contributor

@liuxu623 liuxu623 commented Apr 17, 2025

Description

We shouldn't use a IPPool if it's deletionTimestamp is not zero.

Related issues/PRs

Todos

  • Tests
  • Documentation
  • Release note

Release Note

TBD

Reminder for the reviewer

Make sure that this PR has the correct labels and milestone set.

Every PR needs one docs-* label.

  • docs-pr-required: This change requires a change to the documentation that has not been completed yet.
  • docs-completed: This change has all necessary documentation completed.
  • docs-not-required: This change has no user-facing impact and requires no docs.

Every PR needs one release-note-* label.

  • release-note-required: This PR has user-facing changes. Most PRs should have this label.
  • release-note-not-required: This PR has no user-facing changes.

Other optional labels:

  • cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.
  • needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.

@liuxu623 liuxu623 requested a review from a team as a code owner April 17, 2025 12:43
@marvin-tigera marvin-tigera added this to the Calico v3.31.0 milestone Apr 17, 2025
@marvin-tigera marvin-tigera added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Apr 17, 2025
@caseydavenport
Copy link
Member

@liuxu623 nice, this seems like a good enhancement although I believe the scenario this protects against is meant to be covered by deletion logic already via this logic:

if !pool.Spec.Disabled {
logCxt.Debug("Disabling pool to release affinities")
pool.Spec.Disabled = true
// If the Delete has been called with a ResourceVersion then use that to perform the
// update - that way we'll catch update conflicts (we could actually check here, but
// the most likely scenario is there isn't one - so just pass it through and let the
// Update handle any conflicts).
if opts.ResourceVersion != "" {
pool.ResourceVersion = opts.ResourceVersion
}
if _, err := r.Update(ctx, pool, options.SetOptions{}); err != nil {
return nil, err
}
// Reset the resource version before the actual delete since the version of that resource
// will now have been updated.
opts.ResourceVersion = ""
}

Either way, I think what you've done here is better since it protects against anyone sneaking around our validation logic.

@caseydavenport caseydavenport added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact labels Apr 17, 2025
@marvin-tigera marvin-tigera removed release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Apr 17, 2025
@caseydavenport
Copy link
Member

/sem-approve

@caseydavenport
Copy link
Member

I think a unit test to verify this would be a nice addition, if you have some time.

@caseydavenport caseydavenport merged commit 9f70be8 into projectcalico:master Apr 17, 2025
5 of 10 checks passed
@caseydavenport caseydavenport changed the title skip deleting ippool skip deleting terminating / finalizing ippools Apr 17, 2025
@caseydavenport caseydavenport changed the title skip deleting terminating / finalizing ippools Don't assign IPs from terminating / finalizing ippools Apr 17, 2025
@liuxu623
Copy link
Contributor Author

I think a unit test to verify this would be a nice addition, if you have some time.

ok I will add unit test later.

@liuxu623
Copy link
Contributor Author

#10260

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants