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

Allow to delete routes #1244

Merged
merged 5 commits into from
Mar 6, 2023
Merged

Allow to delete routes #1244

merged 5 commits into from
Mar 6, 2023

Conversation

juanfont
Copy link
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
@@ -535,6 +535,11 @@ func (h *Headscale) RefreshMachine(machine *Machine, expiry time.Time) error {

// DeleteMachine softs deletes a Machine from the database.
Copy link
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
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.

@@ -535,6 +535,11 @@ func (h *Headscale) RefreshMachine(machine *Machine, expiry time.Time) error {

// DeleteMachine softs deletes a Machine from the database.
func (h *Headscale) DeleteMachine(machine *Machine) error {
err := h.DeleteMachineRoutes(machine)
Copy link
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
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