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

Convert hard-coded allowlist error code to be argument of HttpSensor #33717

Merged
merged 8 commits into from
Aug 26, 2023

Conversation

okayhooni
Copy link
Contributor

@okayhooni okayhooni commented Aug 25, 2023

I tried to use HttpSensor to roll out our Trino cluster(each with single coordinator) groups periodically with Airflow. In my use case, the 503 error has to be in the allowlist, same as 404 Not Found.

But, I noticed that HttpSensor raise AirflowException when the target responds with 503 Service Temporarily Unavailable.

How about converting hard-coded 404 to list-typed argument response_error_codes_allowlist?

There is already the alternative option with extra_option={'check_response': False}, but the all or nothing method doesn't seem very fancy for covering all the use cases.

@potiuk
Copy link
Member

potiuk commented Aug 25, 2023

Sure. Good idea. But you need fix static checks (I recommend pre-commit install that will fix most of them for you (see our docs) and unit tests for the sensor need to be updated to cover the case.

@@ -62,6 +64,9 @@ def response_check(response, task_instance):
:param endpoint: The relative part of the full url
:param request_params: The parameters to be added to the GET url
:param headers: The HTTP headers to be added to the GET request
:param response_error_codes_whitelist: An whitelist to return False on poke(), not to raise exception.
Copy link
Contributor

Choose a reason for hiding this comment

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

please change variable name from response_error_codes_whitelist to response_error_codes_allowlist

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..! I'll be more careful in naming variable..! 🙇

@okayhooni
Copy link
Contributor Author

Sure. Good idea. But you need fix static checks (I recommend pre-commit install that will fix most of them for you (see our docs) and unit tests for the sensor need to be updated to cover the case.

Thank you for guiding me..! I reflected your feedbacks..!

@okayhooni okayhooni changed the title Convert hard-coded whitelist error code to be argument of HttpSensor Convert hard-coded allowlist error code to be argument of HttpSensor Aug 26, 2023
@potiuk
Copy link
Member

potiuk commented Aug 26, 2023

You need to add allowlist to spelling.txt :)

@potiuk potiuk modified the milestone: Airflow 2.7.1 Aug 26, 2023
@potiuk potiuk merged commit b1f2a16 into apache:main Aug 26, 2023
42 checks passed
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.

None yet

3 participants