Skip to content

Allow to delete routes#1244

Merged
kradalby merged 5 commits intomainfrom
delete-routes
Mar 6, 2023
Merged

Allow to delete routes#1244
kradalby merged 5 commits intomainfrom
delete-routes

Conversation

@juanfont
Copy link
Copy Markdown
Owner

@juanfont juanfont commented Mar 2, 2023

This PR adds support to delete routes from the CLI and the API.

It also deletes the routes of a machine when it is deleted (#1228)

@juanfont juanfont requested a review from kradalby as a code owner March 2, 2023 23:13
@kradalby kradalby closed this Mar 3, 2023
@kradalby kradalby reopened this Mar 3, 2023
@juanfont juanfont force-pushed the delete-routes branch 2 times, most recently from 1d5b3d3 to ee1d7fb Compare March 3, 2023 17:46
Comment thread machine.go
@@ -535,6 +535,11 @@ func (h *Headscale) RefreshMachine(machine *Machine, expiry time.Time) error {

// DeleteMachine softs deletes a Machine from the database.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is the difference between hard and soft? why do we have them?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Hard actually deletes the entry in the DB, soft just sets the deleted_at field. We do hard when deleting ephemeral nodes.

Comment thread machine.go

// DeleteMachine softs deletes a Machine from the database.
func (h *Headscale) DeleteMachine(machine *Machine) error {
err := h.DeleteMachineRoutes(machine)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cant this be done by cascading database deletes?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

If we would use cascade, we would be using soft deleted in the routes https://stackoverflow.com/a/67751408 and I wanted to hard delete them.

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.

2 participants