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

Deleting and re-creating a key with the same ID preserves usage information #2081

Open
digitalberd opened this issue Jul 29, 2024 · 4 comments

Comments

@digitalberd
Copy link

Hello!
I created key on server with client.create_key(key_id='123', name=name, data_limit=data_limit_gb)
After that I used some trafic by this key - and have used_bytes = X in key
After that I delete this key with client.delete_key('123')
And after that I created this key again with client.create_key(key_id='123', name=name, data_limit=data_limit_gb)

And I have a problem: new key with id equal old id - '123' - have used_bytes not 0 - it have X used bytes.

@digitalberd
Copy link
Author

digitalberd commented Jul 29, 2024

new_key = client.create_key(key_id='123', name=name, data_limit=data_limit_gb)
new_key.used_bytes = 0
BUT
KEY = client.get_key('123')
KEY.used_bytes = X (can be some gigabytes - what was used by old key, before delete key)

@digitalberd
Copy link
Author

I think, it becouse:
def init(self, response: dict, metrics: dict = None):
self.key_id = response.get("id")
self.name = response.get("name")
self.password = response.get("password")
self.port = response.get("port")
self.method = response.get("method")
self.access_url = response.get("accessUrl")
self.used_bytes = (
metrics.get("bytesTransferredByUserId").get(response.get("id"))
if metrics
else 0
)
self.data_limit = response.get("dataLimit", {}).get("bytes")

@fortuna
Copy link
Collaborator

fortuna commented Jul 30, 2024

If you use the same ID, the server interprets as the same user. If it's a new user, you can use a new id.

@fortuna fortuna transferred this issue from Jigsaw-Code/outline-sdk Jul 30, 2024
@maddyhof maddyhof changed the title Have a error Deleting and re-creating a key with the same ID preserves usage information Aug 13, 2024
@maddyhof
Copy link
Contributor

The open feature request for manually resetting the usage information would help with this #1860.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants