You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/07/19 12:04:19 UTC
[GitHub] [airflow] potiuk opened a new pull request, #32694: Add protection against accidental Providers Manager initialization
potiuk opened a new pull request, #32694:
URL: https://github.com/apache/airflow/pull/32694
ProvidersManager might get accidentally initialized during CLI argument parsing, and if it does, then CLI and arg completion takes huge performance hit - it takes seconds to intialize ProvidersManager when you have many providers packages installed, so initializing ProvidersManager should not happen just when you parse arguments of the CLIs but only when you execute commands.
It's rather easy to trigger ProvidersManager by just importing some package (especially as we move executors to providers).
This PR adds a new CLI command in providers to check status of initialization - this command will fail when provider's initlalization is executed during CLI parsing. It will also show the stack trace of where ProvidersManager has been initialized from.
Test is added to detect such situation by running the new command in a separate subprocess, thus making sure ProvidersManager has not been initialized in another test.
<!--
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.
-->
<!--
Thank you for contributing! 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 committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk merged pull request #32694: Add protection against accidental Providers Manager initialization
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #32694:
URL: https://github.com/apache/airflow/pull/32694
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #32694: Add protection against accidental Providers Manager initialization
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #32694:
URL: https://github.com/apache/airflow/pull/32694#issuecomment-1641974497
Here: more "realistic" one:
<img width="874" alt="Screenshot 2023-07-19 at 14 13 08" src="https://github.com/apache/airflow/assets/595491/dabfc31d-f66b-49bc-aed5-23ffde1db5b9">
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #32694: Add protection against accidental Providers Manager initialization
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #32694:
URL: https://github.com/apache/airflow/pull/32694#issuecomment-1641967986
Another check separated out from the #32604 set of changes. This is also related to our recent disucussion on long running CLI commands @o-nikolas and @uranusjr. While implementing separating the providers configuraiton I've found out that it is all-too-easy to accidentally trigger ProvidersManager initialization when you just parse CLI commands (by importing something that runs the initialization at top level). Usually it is as easy as making imports local (see the celery_app imports moved in this PR) - but you have to know you should do that.
This change adds a command in providers that will detect such a situation and pytest test using it to fail in case we do such accidental mistake.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #32694: Add protection against accidental Providers Manager initialization
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #32694:
URL: https://github.com/apache/airflow/pull/32694#issuecomment-1641972590
Example output of `airflow providers status` when we have such a problem:
<img width="840" alt="Screenshot 2023-07-19 at 14 11 17" src="https://github.com/apache/airflow/assets/595491/f55594c0-ae0c-4d63-943d-373115bc2014">
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org