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

Upgrade redis #31279

Merged
merged 5 commits into from
May 16, 2023
Merged

Upgrade redis #31279

merged 5 commits into from
May 16, 2023

Conversation

Owen-CH-Leung
Copy link
Contributor

@Owen-CH-Leung Owen-CH-Leung commented May 14, 2023

Upgrade redis to 4.5.5. This PR fixes: #29175

passed all the existing 5 tests for the redis provider

breeze testing tests --test-type "Providers[redis]"
image

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an 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 a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

Upgrade redis to 4.5.5
@boring-cyborg
Copy link

boring-cyborg bot commented May 14, 2023

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 (ruff, 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

- redis~=3.2
- redis~=4.5.5
Copy link
Member

Choose a reason for hiding this comment

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

Can 3.x still be supported? Also ~=4.5.5 limits the version range to only >=4.5.5,<4.6.0, which is likely not the intention?

Copy link
Contributor Author

@Owen-CH-Leung Owen-CH-Leung May 15, 2023

Choose a reason for hiding this comment

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

Thanks for your comment. How does redis>=3.2,<4.5.5 sound to you ?

Copy link
Member

@pankajkoti pankajkoti May 15, 2023

Choose a reason for hiding this comment

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

do we wish to have an upper bound? can we not keep just >=3.2
I do not have enough context on this. Do we know if there was there a reason that we were not able to support redis >= 3.3.0 and now we're able to do so? Do we have enough tests in our provider to test the mixins and unquoting URLS with urllib.parse.unquote as mentioned in the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the existing test suites isn't enough to cover the concerns mentioned in the comment. I'll try to enrich that in this PR

Copy link
Member

@potiuk potiuk May 15, 2023

Choose a reason for hiding this comment

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

Yes `>=3.2.0' is best. As long as we are reasonably sure that our tests are covering basic integraiton, not having an upper-binding is strongly preferred - the automated constraint management and upgrading to latest released version (and our canary builds failing in case of problems detected) work best in this case.

I think the existing test suites isn't enough to cover the concerns mentioned in the comment. I'll try to enrich that in this PR

To be honest - I am not even sure if that comment is relevant. So maybe just checking that it is not relevant is enough. I think it was put there out of abundance of caution. I think our usage of redis in the operators is very limited so just having an actually executed and tested example dag with our current redis would be more than enough to consider this "cool".

Another thing we should consider together with that test is to bring redis server in our tests to later version, https://github.com/apache/airflow/blob/main/scripts/ci/docker-compose/integration-celery.yml#LL32C1-L33C1
Redis 5 we have does not get security fixes any more https://endoflife.date/redis - which means EOL.

I would consider bumping it to at least 6.2 version.

Our integration tests are more of "smoke" tests so we do not comprehensively test integration with multiple versions of the software we run, but theoretically we could even consider running matrix of tests for 6.0, 6.2, 7.0 of redis as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some digging, I can confirm that the use of redis 4 wouldn't break the existing code base and should be safe to upgrade. The fact that it passes the celery integration test is a hint that it should be ok.

For the concerns mentioned in the comment:

  • mixins in redis commands : This has no impact to airflow since RedisHook didn't directly use redis.client. If we are using redis.client, we'd need to switch to redis.command
  • unquoting URLS with urllib.parse.unquote : This has no impact to airflow as well since we are not using the from_url function

I've just revised the doc and added a example dag to illustrate the use of the existing 3 redis Operator / sensor. I ran pytest in breeze environment & can confirm that the DAG is good to go

Comment on lines 38 to 42
# Upgrading redis package >= 4 doesn't require code changes
# Changes in Redis 4 only brings into impact when we are directly importing redis.client
# to execute the commands, which we are not doing.
# The issue with unquoting URLS with `urllib.parse.unquote` is also not applicable
# to airflow, because we are not using the from_url function
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
# Upgrading redis package >= 4 doesn't require code changes
# Changes in Redis 4 only brings into impact when we are directly importing redis.client
# to execute the commands, which we are not doing.
# The issue with unquoting URLS with `urllib.parse.unquote` is also not applicable
# to airflow, because we are not using the from_url function
# Upgrading redis package >= 4 doesn't require code changes
# Changes in Redis 4 only brings into impact when we are directly importing redis.client
# to execute the commands, which we are not doing.
# The issue with unquoting URLS with `urllib.parse.unquote` is also not applicable
# to airflow, because we are not using the from_url function

I think what @eladkal ment (and Also what I think) - you can remove the whole comment now and simply make it part of commit message. There is no point in leaving in the code, but the commit message will carry the trace of this being verified.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah sorry for not being clear.
If version is OK no need to further explain why it's OK.
We explain only things that we need to consider for future work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks all. I removed the comments and make it as part of commit msg. I'm fixing the static check error and the build-doc error that I get from the CI tests. Will let you guys know once they are fixed.

@@ -0,0 +1,97 @@
#
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 cool! Thanks for being receptive :)

Upgrading redis package >= 4 doesn't require code changes. Changes in Redis 4 only brings into impact when we are directly importing redis.client to execute the commands, which we are not doing. The issue with unquoting URLS with urllib.parse.unquote is also not applicable to airflow, because we are not using the from_url function
@potiuk potiuk merged commit 94cad11 into apache:main May 16, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented May 16, 2023

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Redis Time series in Airflow common packages
5 participants