-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
[feature] Store admin actions in the db, prevent conflicting actions #2167
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Think this should be ready to go! |
nice work comrade 🤠 very nice looking PR 👩🍳 👌 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request updates our handing of admin actions (domain block, domain unblock, account suspend, etc) in the following ways:
When an admin action is performed on a domain or an account, store a record of that action in the database.
Previously, we only stored admin account actions.
Now, we can also store domain block / unblock actions (for starters), as well as completion time of said actions, and any errors that occurred while the action was being processed. In future this could be used to allow admins to review a timeline of actions. This is, imo, pretty sick 😎
Don't allow multiple actions that target the same resource to run at the same time.
This is achieved by storing running admin actions in a map keyed by
[TargetCategory]/[TargetID]
, and removing them from the map when they're finished.For example, a domain block for the domain
example.org
would have the keydomain/example.org
. A domain allow for the domainexample.org
would ALSO have the keydomain/example.org
. Same goes for another domain block for that domain. This ensures that these two actions cannot run at the same time. Now, an API request to perform a second action on an existing key will just get a 409 error back that looks something like:AccountAction: an action (account/01H90S1CXQ97J9625C5YBXZWGT) is currently running (duration 25.566746ms) which conflicts with the attempted action: wait until this action is complete and try again
Checklist
Please put an x inside each checkbox to indicate that you've read and followed it:
[ ]
->[x]
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
go fmt ./...
andgolangci-lint run
.