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

The webhook should reject IPPool deletion if any IP has been allocated #135

Open
jessehu opened this issue Sep 13, 2022 · 23 comments
Open
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. triage/accepted Indicates an issue is ready to be actively worked on.

Comments

@jessehu
Copy link

jessehu commented Sep 13, 2022

What steps did you take and what happened:
[A clear and concise description on how to REPRODUCE the bug.]

What did you expect to happen:

Anything else you would like to add:
Looks like it doesn't handle the delete request: https://github.com/metal3-io/ip-address-manager/blob/main/api/v1alpha1/ippool_webhook.go#L137

Environment:

  • Cluster-api version:
  • CAPM3 version:
  • IPAM version:
  • Minikube version:
  • environment (metal3-dev-env or other):
  • Kubernetes version: (use kubectl version):

/kind bug

@metal3-io-bot metal3-io-bot added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue lacks a `triage/foo` label and requires one. labels Sep 13, 2022
@furkatgofurov7
Copy link
Member

furkatgofurov7 commented Sep 21, 2022

I am not sure tbh if we want to have logic for ippool webhook deletion.. reconcileDelete() does check for the allocations already

func (r *IPPoolReconciler) reconcileDelete(ctx context.Context,
ipPoolMgr ipam.IPPoolManagerInterface,
) (ctrl.Result, error) {
allocationsNb, err := ipPoolMgr.UpdateAddresses(ctx)
if err != nil {
return checkRequeueError(err, "Failed to delete the old secrets")
}
if allocationsNb == 0 {
// ippool is marked for deletion and ready to be deleted,
// so remove the finalizer.
ipPoolMgr.UnsetFinalizer()
}
return ctrl.Result{}, nil
}
. Also, what is the common way to handle the webhooks, seems CAPI also does handle the webhook the same way https://github.com/kubernetes-sigs/cluster-api/blob/main/api/v1beta1/machine_webhook.go#L88-L90?

/cc @schrej if you have other opinions.

@schrej
Copy link
Member

schrej commented Sep 21, 2022

Well, there are only two options (so far) on how to handle deletion: finalizers and webhooks.

Finalizers are the safe way, as they prevent deletion on the apiserver and even work when the webhook isn't deployed.
Webhooks are the user friendly way, as they properly prevent deletion, and the resource doesn't stay in a deleted state for a long time, as is the case with Finalizers (you can't un-delete a resource).
In CAPI this was discussed in kubernetes-sigs/cluster-api#5498 for example.

Either solution, or even a combination of both, is fine. Personally I'd probably prefer the combined approach, as you don't end up with deleted pools that remain in use for a long time that way.

@jessehu
Copy link
Author

jessehu commented Sep 22, 2022

As you can't un-delete a resource in K8s, the webhook approach can prevent IPPool from going into Deleting state when it's in used. In case it's deleted unintentionally.

@furkatgofurov7
Copy link
Member

Right now, the deletion is accepted, but we wait until all addresses are released before actually deleting.
Now #137 would move the responsibility onto the user. I am not sure if that is a good thing. The user won't be able to send a delete on the object and just wait until it is deleted. The user will instead have to retry deleting it as long as addresses are allocated. But then the behavior is a bit more straightforward...

@jessehu
Copy link
Author

jessehu commented Sep 22, 2022

Hi @furkatgofurov7 got your point. When the user got error message that "IPPool is in used so can not be deleted", would he/she release the used IPs in this pool first then delete this pool again?

@furkatgofurov7
Copy link
Member

"IPPool is in used so can not be deleted", would he/she release the used IPs in this pool first then delete this pool again?

Yup, that is how it is now when the delete is issued in the objects

@furkatgofurov7
Copy link
Member

But we are also fine also to have combined handling as @schrej suggested.

@jessehu
Copy link
Author

jessehu commented Sep 23, 2022

Thanks @furkatgofurov7. Could you help proceed #137 ? It's ready for review and CI passed.

@Rozzii
Copy link
Member

Rozzii commented Oct 5, 2022

/triage accepted

1 similar comment
@furkatgofurov7
Copy link
Member

/triage accepted

@furkatgofurov7 furkatgofurov7 added triage/accepted Indicates an issue is ready to be actively worked on. and removed needs-triage Indicates an issue lacks a `triage/foo` label and requires one. triage/accepted Indicates an issue is ready to be actively worked on. labels Oct 5, 2022
@furkatgofurov7
Copy link
Member

triage/accepted

@furkatgofurov7 furkatgofurov7 added the triage/accepted Indicates an issue is ready to be actively worked on. label Oct 5, 2022
@metal3-io-bot
Copy link
Contributor

@jessehu: This issue is currently awaiting triage.
If Metal3.io contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.
The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@metal3-io-bot metal3-io-bot added the needs-triage Indicates an issue lacks a `triage/foo` label and requires one. label Oct 5, 2022
@furkatgofurov7
Copy link
Member

/triage accepted

@furkatgofurov7
Copy link
Member

prow is bit slow for requests but eventually should be able to label this. Otherwise I will do it manually.

@furkatgofurov7
Copy link
Member

/triage accepted

@metal3-io-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues will close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@metal3-io-bot metal3-io-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 4, 2023
@Rozzii
Copy link
Member

Rozzii commented Jan 18, 2023

/remove-lifecycle stale

@metal3-io-bot metal3-io-bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 18, 2023
@Rozzii
Copy link
Member

Rozzii commented Jan 18, 2023

What is the status of this @furkatgofurov7 ?

@furkatgofurov7
Copy link
Member

#137 referring as a fix to this, but that seems to have some issues passing the CI?

@metal3-io-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues will close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@metal3-io-bot metal3-io-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 19, 2023
@Rozzii
Copy link
Member

Rozzii commented Apr 26, 2023

/remove-lifecycle stale

@metal3-io-bot metal3-io-bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 26, 2023
@metal3-io-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues will close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@metal3-io-bot metal3-io-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 25, 2023
@Rozzii Rozzii removed the needs-triage Indicates an issue lacks a `triage/foo` label and requires one. label Aug 2, 2023
@Rozzii
Copy link
Member

Rozzii commented Aug 2, 2023

This is something that would be welcomed but looks like progress has stalled
/lifecycle frozen

@metal3-io-bot metal3-io-bot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 2, 2023
@Rozzii Rozzii added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Aug 2, 2023
@mboukhalfa mboukhalfa moved this from Backlog to IPAM WIP in Metal3 - Roadmap Jun 27, 2024
@mboukhalfa mboukhalfa moved this from IPAM WIP to IPAM on hold / blocked in Metal3 - Roadmap Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. triage/accepted Indicates an issue is ready to be actively worked on.
Projects
Status: IPAM on hold / blocked
Development

Successfully merging a pull request may close this issue.

5 participants