You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/18 21:06:19 UTC

[GitHub] [airflow] o-nikolas opened a new pull request, #25805: Improve error handling/messaging around bucket exist check

o-nikolas opened a new pull request, #25805:
URL: https://github.com/apache/airflow/pull/25805

   This PR was brought about by the confusion caused by the current code (see thread [here](https://apache-airflow.slack.com/archives/CQ9QHSFQX/p1660782744639849?thread_ts=1660781402.798729&cid=CQ9QHSFQX)).
   `S3Hook.check_for_bucket()` method uses the boto3 s3 client method `head_bucket` ([docs](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.head_bucket)) to check for bucket existence. This client method does not work like most boto3 APIs, it only returns a small subset of error codes with very little context.
   
   Manual examples/testing of the updated code:
   ```python
   In [1]: from  airflow.providers.amazon.aws.hooks.s3 import S3Hook
   <omitted airflow init logging>
   
   In [2]: s3hook = S3Hook()
   
   In [3]: s3hook.check_for_bucket('test')  # Exists but not owned by this account
   
   [2022-08-18 14:01:15,677] {s3.py:215} ERROR - Access to bucket "test" is forbidden or there was an error with the request
   [2022-08-18 14:01:15,677] {s3.py:218} ERROR - An error occurred (403) when calling the HeadBucket operation: Forbidden
   Out[3]: False
   
   In [4]: s3hook.check_for_bucket('asdfasdfgfdsagfdsfaasdlkjlkdsajflsad')  # Does not exist
   
   [2022-08-18 14:01:39,237] {s3.py:213} ERROR - Bucket "asdfasdfgfdsagfdsfaasdlkjlkdsajflsad" does not exist
   Out[4]: False
   
   In [5]: s3hook.check_for_bucket('env6a7fbbff-athena-bucket')  # Exists in the account
   Out[5]: True
   ```
   
   <!--
   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 #25805: Improve error handling/messaging around bucket exist check

Posted by GitBox <gi...@apache.org>.
potiuk merged PR #25805:
URL: https://github.com/apache/airflow/pull/25805


-- 
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] o-nikolas commented on pull request #25805: Improve error handling/messaging around bucket exist check

Posted by GitBox <gi...@apache.org>.
o-nikolas commented on PR #25805:
URL: https://github.com/apache/airflow/pull/25805#issuecomment-1221167827

   If anything, I might be inclined to make the log message for the 404/does-not-exist case to be INFO level or remove it altogether. It is a perfectly reasonable state for that thing to be in. I.e. we're checking if a bucket exists, if it doesn't, that's not really an _error_ or Exception IMHO. Seeing a scary red error message for the bucket not existing could mislead people.


-- 
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] uranusjr commented on pull request #25805: Improve error handling/messaging around bucket exist check

Posted by GitBox <gi...@apache.org>.
uranusjr commented on PR #25805:
URL: https://github.com/apache/airflow/pull/25805#issuecomment-1220226511

   Should something still be printed if the return code is 200?


-- 
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 #25805: Improve error handling/messaging around bucket exist check

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25805:
URL: https://github.com/apache/airflow/pull/25805#issuecomment-1221146537

   > > Should something still be printed if the return code is 200?
   > 
   > Thanks for the review TP!
   > 
   > I'm generally not a huge fan of success case logging, usually it's superfluous IMHO. I think maintaining the behaviour of no logging on success makes the most sense here and is less invasive. We could perhaps put a DEBUG level message for the success case if people really want something to trace in that case?
   
   Agree. not to print anything. I think 200 is not an interesting one and printing it in the logs adds no value. I think debug is not really needed - if someone is interested in seeing such details for DEBUG, they are likely better off by enabling some debug levels in boto ?


-- 
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] o-nikolas commented on pull request #25805: Improve error handling/messaging around bucket exist check

Posted by GitBox <gi...@apache.org>.
o-nikolas commented on PR #25805:
URL: https://github.com/apache/airflow/pull/25805#issuecomment-1220874361

   > Should something still be printed if the return code is 200?
   
   Thanks for the review TP!
   
   I'm generally not a huge fan of success case logging, usually it's superfluous IMHO. I think maintaining the behaviour of no logging on success makes the most sense here and is less invasive. We could perhaps put a DEBUG level message for the success case if people really want something to trace in that case?


-- 
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