Conversation
This file contains hidden or 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
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.
This adds support for asynchronous background tasks. FastAPI's native support for these is limited: The builtin background tasks are anonymous background workers. They have no identity that can be used to communicate ongoing process, and they are lost on restarts.
Instead, this changeset introduces the use of celery, which is the go-to for these tasks in the Python ecosystem. The deployment includes an additional worker container that picks up tasks. The broker and result backend use the existing postgres database, alternatives are available.
To confirm the new approach works as intended, the resizing is converted to use celery tasks. Future changes will convert other potentially long-running tasks, in particular anything concerning branch lifecycle management, and ideally monitoring and recurring tasks like backup cleanup and scheduled snapshot creation.
The resize operation now starts individual resizes for each of the affected resources, awaits all results and writes the new values to the database. The ID of the ongoing resize task is stored into the database entity, and the
RESIZINGstatus is derived from this. The task itself cleans this up upon completion.