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

Add loggingconfig rule #11132

Merged
merged 6 commits into from
Oct 5, 2020
Merged

Conversation

Sangarshanan
Copy link
Contributor

Closes: #11046

Adds LoggingConfigurationRule rule to upgrade/rules as per:

https://github.com/apache/airflow/blob/master/UPDATING.md#logging-configuration-has-been-moved-to-new-section


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.

@turbaszek turbaszek added the area:upgrade Facilitating migration to a newer version of Airflow label Sep 27, 2020
Comment on lines 32 to 50
"The following configurations have been to moved from [core] to the new [logging] section. \n"
"- base_log_folder \n"
"- remote_logging \n"
"- remote_log_conn_id \n"
"- remote_base_log_folder \n"
"- encrypt_s3_logs \n"
"- logging_level \n"
"- fab_logging_level \n"
"- logging_config_class \n"
"- colored_console_log \n"
"- colored_log_format \n"
"- colored_formatter_class \n"
"- log_format \n"
"- simple_log_format \n"
"- task_log_prefix_template \n"
"- log_filename_template \n"
"- log_processor_filename_template \n"
"- dag_processor_manager_log_location \n"
"- task_log_reader \n"
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest checking if any of this key is used by users (not empty or different than default - this can be tricky) and then print a message for each incompatibility. See #11056 for reference. In this way, the message will be more precise. What do you think?

Copy link
Contributor Author

@Sangarshanan Sangarshanan Sep 28, 2020

Choose a reason for hiding this comment

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

Ah I was not thinking of this cause this change is backwards compatible and not something that can break if not moved but you are right, showing only the incompatibility really helps while taking actions, I can do a comparison and return only the actively used keys but what of the default/ empty keys is it right that they still remain in the old section ?

Copy link
Member

Choose a reason for hiding this comment

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

what of the default/ empty keys is it right that they still remain in the old section ?

I think it will be ok to hardcode them in rule using default values from airflow.cfg of 1.10.x. WDYT @kaxil ?

Copy link
Member

Choose a reason for hiding this comment

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

Yea default values can be hardcoded.

And also agree that showing a precise message for the used config will be better


mismatches = []
for logging_config, default in logging_configs:
if not conf.has_option("logging", logging_config) and conf.has_option(
Copy link
Member

Choose a reason for hiding this comment

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

Will this work if the logging section is not present? Have you tested it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep has_option returns false when the section is not present

Copy link
Member

@turbaszek turbaszek left a comment

Choose a reason for hiding this comment

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

Look good to me 🚀

Logging configuration has been moved to new section
---------------------------------------------------
The logging configurations have been moved from [core] to the new [logging] section.

Problems:
  1.  task_log_prefix_template has been moved from [core] to a the new [logging] section.

@turbaszek
Copy link
Member

Please rebase your PR, we added few changes that should fix the CI issues. Please do rebase and try to avoid merge commits, more information:
https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#id9

@turbaszek
Copy link
Member

@Sangarshanan I think that the Conditional MySQL Client installation (#11174) and Allow overrides for pod_template_file (#11162) should not be part of your change

@github-actions
Copy link

github-actions bot commented Oct 5, 2020

The CI and PROD Docker Images for the build are prepared in a separate "Build Image" workflow,
that you will not see in the list of checks (you will see "Wait for images" jobs instead).

You can checks the status of those images in The workflow run

@turbaszek
Copy link
Member

turbaszek commented Oct 5, 2020

@Sangarshanan it seems that one test is failing:

_______________________________________ TestLoggingConfigurationRule.test_valid_check _______________________________________
/usr/local/lib/python3.7/contextlib.py:73: in inner
    with self._recreate_cm():
/usr/local/lib/python3.7/contextlib.py:112: in __enter__
    return next(self.gen)
tests/test_utils/config.py:45: in conf_vars
    conf.set(section, key, value)
/usr/local/lib/python3.7/site-packages/backports/configparser/__init__.py:1239: in set
    super(ConfigParser, self).set(section, option, value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <airflow.configuration.AirflowConfigParser object at 0x7fa366479bd0>, section = 'logging', option = 'base_log_folder'
value = 'DUMMY'

    def set(self, section, option, value=None):
        """Set an option."""
        if value:
            value = self._interpolation.before_set(self, section, option,
                                                   value)
        if not section or section == self.default_section:
            sectdict = self._defaults
        else:
            try:
                sectdict = self._sections[section]
            except KeyError:
>               raise from_none(NoSectionError(section))
E               backports.configparser.NoSectionError: No section: 'logging'

Personally I would remove the test_valid_check test 👍

@mik-laj
Copy link
Member

mik-laj commented Oct 5, 2020

@turbaszek This is an interesting problem that also occurs in other cases. I think that it is also worth solving separately. If you have a configuration file from Airflow 2 and you run it on Airflow 1.10, then you can't run: ʻairflow config`

@turbaszek
Copy link
Member

@turbaszek This is an interesting problem that also occurs in other cases. I think that it is also worth solving separately. If you have a configuration file from Airflow 2 and you run it on Airflow 1.10, then you can't run: ʻairflow config`

I agree, but as you said, this should be done in separate PR

@github-actions
Copy link

github-actions bot commented Oct 5, 2020

The CI and PROD Docker Images for the build are prepared in a separate "Build Image" workflow,
that you will not see in the list of checks (you will see "Wait for images" jobs instead).

You can checks the status of those images in The workflow run

@turbaszek
Copy link
Member

All upgrade tests passed:

tests/upgrade/test_formattes.py .                                        [ 86%]
706
tests/upgrade/test_problem.py ..                                         [ 86%]
707
tests/upgrade/rules/test_base_rule.py .                                  [ 86%]
708
tests/upgrade/rules/test_conn_id_is_unique.py .                          [ 86%]
709
tests/upgrade/rules/test_conn_type_is_not_nullable.py .                  [ 86%]
710
tests/upgrade/rules/test_fernet_enabled.py ..                            [ 86%]
711
tests/upgrade/rules/test_import_changes.py ...                           [ 86%]
712
tests/upgrade/rules/test_logging_configuration.py .                      [ 86%]
713
tests/upgrade/rules/test_send_grid_moved.py ..                           [ 86%]

@turbaszek turbaszek merged commit 7b99d16 into apache:v1-10-test Oct 5, 2020
@Sangarshanan Sangarshanan deleted the loggingconfig-rule branch October 5, 2020 16:20
turbaszek pushed a commit to PolideaInternal/airflow that referenced this pull request Oct 21, 2020
turbaszek pushed a commit to PolideaInternal/airflow that referenced this pull request Oct 23, 2020
@potiuk potiuk added this to the Airflow 1.10.13 milestone Nov 14, 2020
cfei18 pushed a commit to cfei18/incubator-airflow that referenced this pull request Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:upgrade Facilitating migration to a newer version of Airflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants