ahilashsasidharan opened a new pull request, #65519:
URL: https://github.com/apache/airflow/pull/65519
…error messages matching API
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull
request.
Write a good git commit message following this guide:
http://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the
documentation.
Feel free to ping (in general) for the review if you do not see reaction for
a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we
sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
## Description
This PR adds support to create pools with teams assigned to them when
multi\_team is enabled and raises an error when team\_name is provided when
multi\_team is disabled following the behaviour of the API.
It adds two unique "--team-name" arguments for both the set and import Pool
commands along with support to display team_name values in other commands.
- When used with the set command it will create a pool with the provided
team_name assigned to it.
- When used with the import command it will assign all pools without a
team_name key provided in the JSON file the one provided as an argument.
This same functionality still needs to be added to the connections and
variables CLI. I will be adding these in subsequent PRs once this is merged. I
will also follow up with a doc change after that.
## Motivation
In the case of the Pools CLI it does not currently support adding Pools with
a team_name which differs from the Airflow API which has support for this. This
PR adds a more consistent experience between both.
## Behaviour
**When multi/_team is disabled:**
<img width="821" height="300" alt="Import Help"
src="https://github.com/user-attachments/assets/8cde0383-0631-48e2-ad23-3c00d6af1c29"
/>
<br>
<img width="1262" height="155" alt="Import JSON"
src="https://github.com/user-attachments/assets/ac8e78d1-3d5b-483c-a2b5-816e00825f74"
/>
<br>
<img width="960" height="212" alt="List"
src="https://github.com/user-attachments/assets/da4621c1-9ad5-4040-ab13-5cee769a2dfe"
/>
<br>
**When multi/_team is enabled:**
<img width="915" height="340" alt="Import Help"
src="https://github.com/user-attachments/assets/d0657de3-16a3-4356-b995-628f220e8aa1"
/>
<br>
<img width="980" height="232" alt="List"
src="https://github.com/user-attachments/assets/e374a86a-9174-416f-8285-6e38bca00300"
/>
## Tests
- Added tests under
airflow-core/tests/unit/cli/commands/test_pool_command.py for each respective
API file to validate the error behaviour when submitting a request with
team\-name and multi\-team mode disabled and enabled.
## Questions
When --team-name is provided to the import command, it only applies to pools
where team_name is absent from the JSON. If a pool already has team_name set to
any value (including None/null), the JSON value takes precedence and the
argument is ignored. Is this the right behaviour or should I implement one of
the alternatives?
- team-name acts as an override for all pools without a team_name (including
None/null)
- team-name acts as a strict override for all pools in the JSON
- team-name is removed from the import command entirely
The motivation for the current approach is to make it easier to bulk-import
legacy pool JSON files into a multi-team environment without modifying the
files themselves.
related: #62251, #63994
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR,
please
change below checkbox to `[X]` followed by the name of the tool, uncomment
the "Generated-by".
-->
- [X] Yes (Google Antigravity)
<!--
Generated-by: [Tool Name] following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information. Note: commit author/co-author name and email in commits
become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment:
`{pr_number}.significant.rst`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
You can add this file in a follow-up commit after the PR is created so you
know the PR number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]