-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Enable pools to consider deferred tasks #32709
Merged
potiuk
merged 16 commits into
apache:main
from
Usiel:usiel/allow-pools-to-consider-deferrable
Aug 9, 2023
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
52e9250
Makes pools respect deferrable tasks (with extra setting)
Usiel 8a2df49
Adds UI for include_deferrable field on Pool
Usiel 198b7df
Adds documentation for deferrable tasks and pools
Usiel 3b23dcb
Adds new metric for deferred tasks in pool
Usiel d93112f
Ensures PoolSlotsAvailableDep is met for tasks in deferred state
Usiel e6cdc50
Adds link for deferred slots in Pool list
Usiel 2b99343
Simplifies Pool task filtering
Usiel 13003b7
Sets include_deferred for all Pool constructor calls
Usiel 98c0465
Keep deprecated pool API as is
Usiel fc228ab
Establishes backwards compatibility for v1 pool API
Usiel bf67bf8
Adds deferred slots to Pool v1 API
Usiel 350e4b7
Updates OpenAPI spec to reflect changes to Pool
Usiel 9ad0b90
Makes include_deferred non-required for v1 API
Usiel a458044
Removes deprecation handling for include_deferred and makes import/ex…
Usiel 7692756
Cleanup: Removes unused function
Usiel 260d51e
Refactors tests to clean up generated files via tmp_path fixture
Usiel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
50 changes: 50 additions & 0 deletions
50
airflow/migrations/versions/0128_2_7_0_add_include_deferred_column_to_pool.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
"""add include_deferred column to pool | ||
|
||
Revision ID: 405de8318b3a | ||
Revises: 788397e78828 | ||
Create Date: 2023-07-20 04:22:21.007342 | ||
|
||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "405de8318b3a" | ||
down_revision = "788397e78828" | ||
branch_labels = None | ||
depends_on = None | ||
airflow_version = "2.7.0" | ||
|
||
|
||
def upgrade(): | ||
"""Apply add include_deferred column to pool""" | ||
with op.batch_alter_table("slot_pool") as batch_op: | ||
batch_op.add_column( | ||
sa.Column("include_deferred", sa.Boolean, nullable=False, server_default=sa.false()) | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Unapply add include_deferred column to pool""" | ||
with op.batch_alter_table("slot_pool") as batch_op: | ||
batch_op.drop_column("include_deferred") |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure, I think this needs a default
False
for backward compatibility.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internally we cover all our bases upstream of the client, unless I'm missing something. The
pool_command
module is the only consumer and in both usages we handle a missinginclude_deferred
:False
(https://github.com/apache/airflow/pull/32709/files#diff-b16c716393f690332e062e25defef0da5ac27e282553040b4b4dee223f1d169fR131)airflow pools set ...
) we have an optional flag for the CLI command (so the default isFalse
) (https://github.com/apache/airflow/pull/32709/files#diff-6e938311edf46fbd7341cc3f151407931322af0121acbfca9885b9f3aa0a8565R516-R518)Is
get_current_api_client()
(airflow.api.client
) something that is meant to be used to interact with Airflow? If yes, then yes, I agree we should change the signature as you said. I couldn't find much on this topic, Public Interface of Airflow docs only makes mention of the stable REST API and CLI.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is old, deprecated, experimental API client that we don't use for years. As such I'd argue that we just should not change it at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove those changes from "airflow/api/client" packages @Usiel please? I am eyeing to add that change to 2.7.0 if possible, so if there is a way to do it quickly that would be fantastic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty to add a fixup to remove the "experimental api" changes and rebase the change on top of latest main. I will try to convince the release manager to include that one in 2.7.0 - it would be a pity to wait till 2.8 for that one as there is clearly a need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that'd be great!
Unfortunately the
pool_command
makes use ofairflow.api.client
. So if we don't want any changes to the API client, we'd also have to undo the changes for the CLI pool commands (specifically theairflow pool set ...
cmd). I can do that now, if that's what we're going for.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. just realied taht. My bad. Actually - this was fine how it was before. I realized that the CLI command is still using tha API (Historical reason) but it is NOT the experimental API- it was internal API used in the past by the clients and we moved away from it in newer CLIs. There are absolutely no guarantees about this API that we give - so your change was good as it was.
resetting my change.