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

Move the database configuration to a new section #22284

Merged
merged 23 commits into from
Apr 11, 2022
Merged

Move the database configuration to a new section #22284

merged 23 commits into from
Apr 11, 2022

Conversation

gitstart-airflow
Copy link
Contributor

closes: 15930

This PR moves the following configurations from [core] to the new [database] section.

  • sql_alchemy_conn
  • sql_engine_encoding
  • sql_engine_collation_for_ids
  • sql_alchemy_pool_enabled
  • sql_alchemy_pool_size
  • sql_alchemy_max_overflow
  • sql_alchemy_pool_recycle
  • sql_alchemy_pool_pre_ping
  • sql_alchemy_schema
  • sql_alchemy_connect_args
  • load_default_connections
  • max_db_retries

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@boring-cyborg boring-cyborg bot added area:CLI area:dev-tools area:helm-chart Airflow Helm Chart provider:cncf-kubernetes Kubernetes provider related issues area:production-image Production image improvements and fixes area:Scheduler Scheduler or dag parsing Issues area:webserver Webserver related Issues kind:documentation labels Mar 15, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 15, 2022

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@potiuk
Copy link
Member

potiuk commented Mar 15, 2022

This one will need much more. It's not enough to move the sections. And (unless I missed it) the change should handle deprecation - this is a very intrusive change and whoever has the current configurationm (either via config or environment variable) it should continue to work but raise a deprecation warning.

@gitstart-airflow
Copy link
Contributor Author

Thanks @potiuk . Will make the necessary change.

### Database configuration moved to new section

The following configurations have been moved from `[core]` to the new `[database]` section.

Copy link
Member

Choose a reason for hiding this comment

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

Information that they can still be accessed via "core" section but will raise a deprecation warning would be useful to add here.

Copy link
Member

Choose a reason for hiding this comment

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

This is NIT. And it is good without it - feel free ot add it if you want though.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Cool. One nit

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Mar 24, 2022
@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@potiuk
Copy link
Member

potiuk commented Mar 27, 2022

Need rebase unfortunately.

Comment on lines 56 to 57
- name: AIRFLOW__DATABASE__SQL_ALCHEMY_CONN
valueFrom:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- name: AIRFLOW__DATABASE__SQL_ALCHEMY_CONN
valueFrom:
- name: AIRFLOW__DATABASE__SQL_ALCHEMY_CONN
valueFrom:

Copy link
Member

Choose a reason for hiding this comment

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

This should help.

@mik-laj mik-laj merged commit d8889da into apache:main Apr 11, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 11, 2022

Awesome work, congrats on your first merged pull request!

@pingzh
Copy link
Contributor

pingzh commented May 13, 2022

@gitstart-airflow it looks like this pr has caused this bug #23679

@pingzh
Copy link
Contributor

pingzh commented May 13, 2022

@potiuk i am not quite sure about the expected behavior here for deprecating section.

def _get_option_from_config_file(self, deprecated_key, deprecated_section, key, kwargs, section):
# ...then the config file
if super().has_option(section, key):
# Use the parent's methods to get the actual config here to be able to
# separate the config from default config.
return expand_env_var(super().get(section, key, **kwargs))
if deprecated_section:
if super().has_option(deprecated_section, deprecated_key):
self._warn_deprecate(section, key, deprecated_section, deprecated_key)
return expand_env_var(super().get(deprecated_section, deprecated_key, **kwargs))
return None

for the deprecation_section and key, for the above ^^ method, for database, sql_alchemy_conn, should it use the value from database.sql_alchemy_conn or core.sql_alchemy_conn?

the current behavior for my case #23679 (comment) is airflow tasks run --local process uses the value from core.sql_alchemy_conn, but airflow tasks run --raw process uses the value from database.sql_alchemy_conn

@potiuk
Copy link
Member

potiuk commented May 14, 2022

Yes. I looked at it already and I could confirm that conf.as_dict() will work wrongly in this case (and this is the root cause). Currently when you run conf.as_dict(), the "database" entries will get the "defaults" (sqlite://) for MySQL and "core" will get the one that is set in the config. Which will effective replace the configuration specified in "defaults" when --raw is used.

I am not the author of this part, but after looking there I think simply conf.as_dict has not been written with such deprecations in mind (and likely some users could have some problems before because of other deprecations).

I think - "logically" speaking I think when the "new" value has a corresponding non-default "deprecated" value in the conf - it just should not be exported by the "as_dict()" (when it is taken from default) - but otherwise it should. i am looking at fixing it in an upcoming pr - but I have to learn how the system works first.

@potiuk
Copy link
Member

potiuk commented May 14, 2022

If you want @pingzh you can try to learn it too, and come up with a good solution - maybe we can eventually compare ours and choose the better one.

@pingzh
Copy link
Contributor

pingzh commented May 16, 2022

If you want @pingzh you can try to learn it too, and come up with a good solution - maybe we can eventually compare ours and choose the better one.

thanks @potiuk i definitely love to learn more about it. will keep you posted.

@potiuk
Copy link
Member

potiuk commented May 16, 2022

thanks @potiuk i definitely love to learn more about it. will keep you posted.

The typing in #23716 would definitely make it easier :D. I've learned quite a lot while adding it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI area:dev-tools area:helm-chart Airflow Helm Chart area:production-image Production image improvements and fixes area:Scheduler Scheduler or dag parsing Issues area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge kind:documentation provider:cncf-kubernetes Kubernetes provider related issues type:new-feature Changelog: New Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move the database configuration to a new section
7 participants