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

Adds migration logic for work pools #8214

Merged
merged 30 commits into from
Jan 25, 2023
Merged

Conversation

desertaxle
Copy link
Member

@desertaxle desertaxle commented Jan 20, 2023

Adds functionality to duplicate existing work queues to corresponding work pool queues. All migration logic is hidden behind the PREFECT_EXPERIMENTAL_ENABLE_WORK_POOL setting (which is added in this PR). The first time that the Orion server is started after enabling the work pool feature a a default agent work pool named default-agent-pool will be created and all existing work queues will be duplicated to work pool queues in that pool. The migration will not run on subsequent server start ups.

Any changes made to work queues after the initial migration will be reflected in their corresponding work pool queue.

The following actions will produce corresponding changes in a work pool queue:

  • Creating a work queue
  • Updating a work queue
  • Deleting a work queue
  • Creating a deployment with a work queue
  • Updating the work queue for a deployment
  • Creating a flow run that is associated with a work queue

As part of this PR work_pool_queue_name is removed from the deployments API and the existing work_queue_name will be used instead.

Additionally, any work queue that is created without a work pool will trigger the creation of the default agent work pool if it does not already exist.

Example

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • This pull request includes tests or only affects documentation.
  • This pull request includes a label categorizing the change e.g. fix, feature, enhancement

@netlify
Copy link

netlify bot commented Jan 20, 2023

Deploy Preview for prefect-orion ready!

Name Link
🔨 Latest commit 5120945
🔍 Latest deploy log https://app.netlify.com/sites/prefect-orion/deploys/63d09e51b4ad6f0008b66276
😎 Deploy Preview https://deploy-preview-8214--prefect-orion.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@desertaxle desertaxle force-pushed the work-pool-deployments-refactor branch from 1b5fb57 to 2d220ea Compare January 20, 2023 15:39
@desertaxle desertaxle changed the title Adds migration logic for work pools Updates deployments for work pools Jan 20, 2023
@desertaxle desertaxle marked this pull request as ready for review January 20, 2023 20:43
@desertaxle desertaxle requested review from a team, cicdw and zangell44 as code owners January 20, 2023 20:43
@desertaxle desertaxle changed the title Updates deployments for work pools Adds migration logic for work pools Jan 21, 2023
Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial pass - I think the DB logic would benefit from a review by @zangell44 if feasible

src/prefect/orion/api/deployments.py Outdated Show resolved Hide resolved
src/prefect/cli/deployment.py Outdated Show resolved Hide resolved
src/prefect/orion/api/deployments.py Show resolved Hide resolved
Can be run at any time to facilitate user-initiated migrations without
waiting for an agent to poll.
"""
for work_queue in await models.work_queues.read_work_queues(session=session):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding some batching here

@desertaxle desertaxle requested a review from pleek91 as a code owner January 24, 2023 19:43
Copy link
Contributor

@pleek91 pleek91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI looks good 👍

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!!! lots of ground to cover in this PR

@desertaxle desertaxle merged commit d3cdcb3 into main Jan 25, 2023
@desertaxle desertaxle deleted the work-pool-deployments-refactor branch January 25, 2023 04:12
@desertaxle desertaxle mentioned this pull request Jan 25, 2023
3 tasks
ddelange added a commit to ddelange/prefect that referenced this pull request Jan 26, 2023
…erm-testing

* 'main' of https://github.com/prefecthq/prefect: (77 commits)
  Update roles and permissions in documentation (PrefectHQ#8263)
  Add Prefect Cloud Quickstart tutorial (PrefectHQ#8227)
  Remove needless log
  Update comment for consistency
  Reorder migrations for clarity
  Refactor cancellation cleanup service
  Uses canonical `CANCELLING` states for run cancellations (PrefectHQ#8245)
  Add cancellation cleanup service (PrefectHQ#8128)
  Improve engine shutdown handling of SIGTERM (PrefectHQ#8127)
  Create a `CANCELLING` state type (PrefectHQ#7794)
  Update KubernetesJob options (PrefectHQ#8261)
  Small work pools UI updates (PrefectHQ#8257)
  Removes migration logic (PrefectHQ#8255)
  Consolidate multi-arch docker builds (PrefectHQ#7902)
  Include nested `pydantic.BaseModel` secret fields in blocks' schema (PrefectHQ#8246)
  Improve contributing documentation with venv instructions (PrefectHQ#8247)
  Update Python tests to use a single test matrix for both databases (PrefectHQ#8171)
  Adds migration logic for work pools (PrefectHQ#8214)
  Add `project_urls` to `setup.py` (PrefectHQ#8224)
  Add `is_schedule_active` to client `Deployment` class (PrefectHQ#7430)
  ...
github-actions bot pushed a commit that referenced this pull request Jan 26, 2023
github-actions bot pushed a commit that referenced this pull request Jan 26, 2023
@zanieb zanieb mentioned this pull request Feb 3, 2023
3 tasks
zanieb pushed a commit that referenced this pull request Feb 3, 2023
zanieb pushed a commit that referenced this pull request Feb 3, 2023
zanieb pushed a commit that referenced this pull request Feb 6, 2023
zanieb pushed a commit that referenced this pull request Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants