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

Make locks expire after or at a user specified time #7

Open
connorads opened this issue May 16, 2020 · 9 comments
Open

Make locks expire after or at a user specified time #7

connorads opened this issue May 16, 2020 · 9 comments
Labels
enhancement New feature or request feedback wanted Extra feedback is needed

Comments

@connorads
Copy link
Owner

connorads commented May 16, 2020

Could use DynamoDB TTL but it has limited time guarantees and wouldn't notify users.

@connorads connorads added the enhancement New feature or request label May 17, 2020
@connorads
Copy link
Owner Author

@connorads connorads added the feedback wanted Extra feedback is needed label Jun 24, 2020
@connorads
Copy link
Owner Author

Would be nice if ...

  • Locks could be set to expire at a particular minute
  • The channel is notified when the lock expires (and unlocks)

1 minute CRON job? 1440 minutes a day ... scan, query for expiry time?
Store the reply URL so that it can reply to channel on deletion. Do these links expire?

@connorads connorads mentioned this issue Sep 9, 2020
1 task
@frshwtr
Copy link

frshwtr commented Sep 13, 2020

If a TTL can trigger a lambda, it's possible that a webhook event could be emitted to notify that a lock has expired. It is possible to trigger lambdas on DynamoDB changes, hopefully the TTL feature can be picked up by that. Though reading the article, it looks like more thought may need to be put into this approach.

Scan is a pretty expensive DynamoDB call. Depending on the size of your database, it can be a pretty read-intensive call.

@connorads
Copy link
Owner Author

The DynamoDB TTL could trigger a lambda according to this and this .
The trouble is that it might not actually get deleted for up to 48 hours which is not very useful for Lockbot where a 1 minute error margin would probably be tolerable 😢

The scan could indeed get expensive! I'm not a DynamoDB expert but we might be able to make use of a secondary index on the expiry time so we could do queries on it.
But indexes aren't free either. I believe they can reduce read costs but increase storage costs. Which might be a reasonable trade off in the case of a polling CRON job.

Hopefully there's a simple solution lurking somewhere 🧐

@floydspace
Copy link

floydspace commented Nov 17, 2020

  • Locks could be set to expire at a particular minute
  1. We could use EventBridge.PutRule to acquire cron scheduled event per Resource, so as soon as we add a resource we PutRule with defined cron, and it will run a lambda on a certain time and delete the Resource from dynamo. we do not need any new indexes, we do not have to scan because the rule can be configured with input, so we exactly know the key.

  2. I suggest using the following interface: /lock dev 1h so it could be h, m or d, or even pattern like 1h30m indicating how much time it will last. or it could be exact time 9:00 - means 9 am

  3. I would love to work on it with my pace

@connorads
Copy link
Owner Author

Hey @floydspace sounds like a great idea!

  1. I'm just reading about this EventBridge.PutRule - sounds very promising! Going to read some more.
  2. The format sounds good. I think one thing to work around with exact times would be timezones. I think this could be helped by using this convenient example provided by the Slack Bolt JS documentation on context.
  3. As you please sir 👍

I've tried to keep the README.md and CONTRIBUTING.md up to date but it may not be entirely clear how to setup a local dev environment or deploy to a dev environment. If you find anything confusing please do ask me and feel free to update the docs.

If you'd like a walkthrough of the project or discuss anything then I'm be happy to jump on a call.

Join the Lockbot Slack Workspace if you'd like to chat.

@connorads connorads changed the title Make locks expire after some time Make locks expire after or at a user specified time Nov 18, 2020
@alpeshvas
Copy link

alpeshvas commented Jan 15, 2022

  • Locks could be set to expire at a particular minute
  1. We could use EventBridge.PutRule to acquire cron scheduled event per Resource, so as soon as we add a resource we PutRule with defined cron, and it will run a lambda on a certain time and delete the Resource from dynamo. we do not need any new indexes, we do not have to scan because the rule can be configured with input, so we exactly know the key.

  2. I suggest using the following interface: /lock dev 1h so it could be h, m or d, or even pattern like 1h30m indicating how much time it will last. or it could be exact time 9:00 - means 9 am

  3. I would love to work on it with my pace

Great solution, but I think there is a limit of 100 rules per account which means with a single aws account, lockbot can have at max 100 resources

@karimzmi
Copy link

karimzmi commented Mar 7, 2024

This would be a good feature to have. Is there a plan to add it? We use the app and it is great but we do want a way to release locks automatically after certain default time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback wanted Extra feedback is needed
Projects
None yet
Development

No branches or pull requests

5 participants