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

Reusing EUIs of Deleted Gateways #1120

Closed
adamsondelacruz opened this issue Aug 7, 2019 · 7 comments · Fixed by #1843
Closed

Reusing EUIs of Deleted Gateways #1120

adamsondelacruz opened this issue Aug 7, 2019 · 7 comments · Fixed by #1843
Assignees
Labels
c/identity server This is related to the Identity Server in progress We're working on it
Milestone

Comments

@adamsondelacruz
Copy link

adamsondelacruz commented Aug 7, 2019

Summary

When you delete a gateway and then add a new one with the same EUI, if fails because it complains that the gateway already exists.

Steps to Reproduce

  1. Remove an existing gateway
  2. Add it using the CLI or
  3. Add it using the API

What do you see now?

{
    "code": 6,
    "message": "error:pkg/identityserver/store:already_exists (entity already exists)",
    "details": [
        {
            "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
            "namespace": "pkg/identityserver/store",
            "name": "already_exists",
            "message_format": "entity already exists",
            "attributes": {
                "field": "gateway_eui",
                "value": "'3135313749005303'"
            },
            "correlation_id": "c0dc6bb73d714702bd8d0be57e83f369"
        }
    ]
}

What do you want to see instead?

Successfullly create the new gateway

Environment

amazon linux using TTN CLI and Postman using API Call

How do you propose to implement this?

When user try to insert a deleted gateway, update the deleted flag to false

Can you do this yourself and submit a Pull Request?

...

@htdvisser htdvisser added the c/identity server This is related to the Identity Server label Aug 7, 2019
@htdvisser htdvisser added this to the Backlog milestone Aug 7, 2019
@htdvisser
Copy link
Contributor

Related to #1121

@htdvisser
Copy link
Contributor

I updated this issue a bit to have a slightly different scope than #1121, which we can make more about restoring deleted entities in general (instead of only applications).

In the current issue, let's focus more on adding new gateways with the same EUI as a deleted gateway.

@htdvisser htdvisser changed the title Adding back deleted gateway not working Reusing EUIs of Deleted Gateways Aug 7, 2019
@htdvisser
Copy link
Contributor

Related to #604 (releasing IDs/EUIs)

@johanstokking
Copy link
Member

@htdvisser even having #1703 (now in Next Up) is not entirely covering the common use case of being able to create a gateway with an EUI that has been used before. Looping in an administrator to purge an entity is not a nice user experience, plus purging an entity is more destructive than simply releasing the EUI.

Afaik we don't have security issues with releasing the EUI when deleting the gateway. It is optional already. It would, obviously, make recovery partial, i.e. the EUI is gone, but I think that is acceptable and also aligns with how device EUIs are released on deletion immediately.

Can we close this issue with simply releasing the EUI on gateway delete? If not, why not?

@johanstokking johanstokking added the needs/discussion We need to discuss this label Jan 5, 2020
@htdvisser
Copy link
Contributor

Yes, we could update the Gateway EUI field to nil/NULL on delete. Should be as simple as adding a

// AfterDelete releases the EUI of a Gateway after it is deleted.
func (gtw *Gateway) AfterDelete(db *gorm.DB) error {
	return db.Unscoped().Model(gtw).UpdateColumn("gateway_eui", nil).Error
}

in pkg/identityserver/store/hooks.go.

@johanstokking johanstokking modified the milestones: Backlog, January 2020 Jan 9, 2020
@johanstokking johanstokking removed the needs/discussion We need to discuss this label Jan 9, 2020
@johanstokking
Copy link
Member

@bafonins can you pick this up?

@bafonins bafonins added the in progress We're working on it label Jan 13, 2020
@bafonins
Copy link
Contributor

@adamsondelacruz please reopen if #1843 doesnt solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/identity server This is related to the Identity Server in progress We're working on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants