You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "yupbank (via GitHub)" <gi...@apache.org> on 2023/07/05 19:08:15 UTC

[GitHub] [airflow] yupbank opened a new pull request, #32383: Fix the gcp_gcs_delete_objects operator delete whole bucket on processing empty list of objects

yupbank opened a new pull request, #32383:
URL: https://github.com/apache/airflow/pull/32383

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   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/
   -->
   currently the `GCSDeleteObjectsOperator` operator will delete the whole bucket when accepting an empty list of objects. which is a bug. It should quietly skip when processing an empty list. 
   
   ---
   **^ 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


Re: [PR] Fix the gcp_gcs_delete_objects operator delete whole bucket on processing empty list of objects [airflow]

Posted by "RemyOstyn (via GitHub)" <gi...@apache.org>.
RemyOstyn commented on PR #32383:
URL: https://github.com/apache/airflow/pull/32383#issuecomment-1842065967

   Hello @yupbank,
   
   I found the same issue when using **Airflow Task Group**. If we forget to specify the when pulling files paths from xcoms, the `objects` will be an empty array between double quotes `"[]"` and the **GCSDeleteObjectsOperator** will delete the whole bucket content.
   
   **Example:** (let's assume these tasks are in a task group)
   
   ```
   list_files_from_gcs = GCSListObjectsOperator(
               task_id="list_files_from_gcs",
               bucket="my-bucket",
               match_glob=path + "/*.csv",
           )
   
   remove_files_from_gcs = GCSDeleteObjectsOperator(
               task_id="remove_files_from_gcs",
               bucket_name="my-bucket,
               objects="{{ ti.xcom_pull('list_files_from_gcs') }}",
           )
   ```
   
   Instead of:
   
   ```
   list_files_from_gcs = GCSListObjectsOperator(
               task_id="list_files_from_gcs",
               bucket="my-bucket",
               match_glob=path + "/*.csv",
           )
   
   remove_files_from_gcs = GCSDeleteObjectsOperator(
               task_id="remove_files_from_gcs",
               bucket_name="my-bucket",
               objects="{{ ti.xcom_pull('my_task_group.list_files_from_gcs') }}", // As you can see I have to specify the task group here to avoid deleting the whole bucket
           )
   ```
   
   Is there a way to add protection when using task group?


-- 
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] boring-cyborg[bot] commented on pull request #32383: Fix the gcp_gcs_delete_objects operator delete whole bucket on processing empty list of objects

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #32383:
URL: https://github.com/apache/airflow/pull/32383#issuecomment-1623371241

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
   


-- 
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 #32383: Fix the gcp_gcs_delete_objects operator delete whole bucket on processing empty list of objects

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #32383:
URL: https://github.com/apache/airflow/pull/32383


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