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

Add suport for forceful project deletion #245

Closed
stgraber opened this issue Nov 28, 2023 · 10 comments
Closed

Add suport for forceful project deletion #245

stgraber opened this issue Nov 28, 2023 · 10 comments
Assignees
Labels
API Changes to the REST API Documentation Documentation needs updating Easy Good for new contributors
Milestone

Comments

@stgraber
Copy link
Member

When dealing with temporary projects, it's a bit annoying having to figure out everything that needs to be removed before being able to delete the project.

It'd be useful to have a force flag which just goes and delete everything in the project instead.

@stgraber stgraber added Documentation Documentation needs updating Feature Easy Good for new contributors API Changes to the REST API labels Nov 28, 2023
@dnegreira
Copy link
Contributor

Can I have a stab at this one?

@stgraber
Copy link
Member Author

stgraber commented Dec 6, 2023

@dnegreira of course!

@stgraber stgraber changed the title Add suport for foreceful project deletion Add suport for forceful project deletion Dec 6, 2023
@stgraber
Copy link
Member Author

stgraber commented Dec 6, 2023

@dnegreira I suspect you're going to want to:

  • Add an API extension string for this in doc/api-extensions.md and internal/version/api.go
  • Add a DeleteProjectForce function to the client package which passes a ?force=true to the API
  • Update the projectDelete API handler to handle the force variable and if set to true, then go through everything the project owns and delete it. You probably want to start with instances, then volumes and buckets, then profiles, then networks (starting with acls, zones, peering before networks themselves).

@stgraber
Copy link
Member Author

Unassigned this one per @dnegreira's request, it's available for anyone who wants it!

@MaheshPunjabi
Copy link
Contributor

Can I try?

@stgraber
Copy link
Member Author

stgraber commented Feb 9, 2024

Of course!

@MaheshPunjabi
Copy link
Contributor

Few follow up questions:

  1. Is it fine to specify force as a query type parameter ? Didn't see any existing query parameters, so I thought its best to check. I assume this is yes coz of use of ?force=true
  2. When deleting artifacts, do we also want to delete images(if features.images is set) ?
  3. Does this need any changes to client/simplestreams ?

Proposed changes:

  • Add an API extension string for this in doc/api-extensions.md and internal/version/api.go. call it "projects_force_delete"

  • Update the projectDelete API handler,in "cmd/incusd/api_project.go" to handle the force variable and if set to true, then go through everything the project owns and delete it. You probably want to start with instances, then volumes and buckets, then profiles, then networks (starting with acls, zones, peering before networks themselves).

  • Re-generate the swagger YAML data (make update-api).

  • Add a DeleteProjectForce function to "client/incus_projects.go" which passes a ?force=true to the API. add that function to the ImageServer interface.

  • Add new "force" argument to "cmd/incus/project.go". when passed, call DeleteProjectForce

  • Re-generate the translation template for the new CLI string.

Proposed commits:
api: projects_force_delete
incusd/api_project: Add support for force delete
doc/rest-api: Refresh swagger YAML
client: Add DeleteProjectForce
incus/projects: add --force flag
i18n: Update translation templates

@stgraber
Copy link
Member Author

Is it fine to specify force as a query type parameter ? Didn't see any existing query parameters, so I thought its best to check. I assume this is yes coz of use of ?force=true

Yeah, I think that's fine. The alternative would have been to support a JSON body in the DELETE request but we've not currently done so for any of our DELETE endpoints, so using a query parameter is likely better.

When deleting artifacts, do we also want to delete images(if features.images is set) ?

Yep, we'll need to delete:

  • All instances (always)
  • All profiles except for default (if features.profiles=true)
  • Empty the default profile
  • All images (if features.images=true)
  • All networks (if features.networks=true)
  • All network zones (if features.networks.zones=true)
  • All network ACLs (if features.networks=true)
  • All storage volumes (if features.storage.volumes=true)
  • All storage buckets (if features.storage.buckets=true)

Does this need any changes to client/simplestreams ?

Nope, no change to the simplestreams logic.

@stgraber
Copy link
Member Author

@MaheshPunjabi how's this one going?

@MaheshPunjabi
Copy link
Contributor

I'm still working on it, sorry, got side tracked. I also just posted some questions in that new PR.

@stgraber stgraber added this to the incus-0.7 milestone Mar 8, 2024
@stgraber stgraber modified the milestones: incus-0.7, incus-6.0 Mar 25, 2024
@stgraber stgraber modified the milestones: incus-6.0, soon Apr 2, 2024
@stgraber stgraber modified the milestones: soon, incus-6.2 May 29, 2024
@hallyn hallyn closed this as completed in 057428d May 30, 2024
stgraber added a commit that referenced this issue Jun 27, 2024
Closes #245

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes to the REST API Documentation Documentation needs updating Easy Good for new contributors
Development

No branches or pull requests

3 participants