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

Fixes #4321 - Cannot delete folders with Azure Multiaccount authentication #4323

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
285 changes: 285 additions & 0 deletions integration-tests/azure/main-0008-create-fill-delete-folder.hwf
Copy link
Author

Choose a reason for hiding this comment

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

I've added this IT for the sake of testing locally, I knew these ITs are temporarily disabled

Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<workflow>
<name>main-0008-create-fill-delete-folder-multi-account</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
<workflow_version/>
<created_user>-</created_user>
<created_date>2024/09/02 16:54:41.597</created_date>
<modified_user>-</modified_user>
<modified_date>2024/09/02 16:54:41.597</modified_date>
<parameters>
</parameters>
<actions>
<action>
<name>[Multiaccount] Copy files</name>
<description/>
<type>COPY_FILES</type>
<attributes/>
<copy_empty_folders>N</copy_empty_folders>
<arg_from_previous>N</arg_from_previous>
<overwrite_files>Y</overwrite_files>
<include_subfolders>N</include_subfolders>
<remove_source_files>N</remove_source_files>
<add_result_filesname>N</add_result_filesname>
<destination_is_a_file>N</destination_is_a_file>
<create_destination_folder>N</create_destination_folder>
<fields>
<field>
<source_filefolder>EMPTY_SOURCE_URL-0-${PROJECT_HOME}/datasets/</source_filefolder>
<source_configuration_name>LOCAL-SOURCE-FILE-0</source_configuration_name>
<destination_filefolder>EMPTY_DEST_URL-0-azit://leavemeempty/multiaccount</destination_filefolder>
<destination_configuration_name>LOCAL-DEST-FILE-0</destination_configuration_name>
<wildcard>ingest-.*.csv</wildcard>
</field>
<field>
<source_filefolder>EMPTY_SOURCE_URL-1-${PROJECT_HOME}/datasets/</source_filefolder>
<source_configuration_name>LOCAL-SOURCE-FILE-1</source_configuration_name>
<destination_filefolder>EMPTY_DEST_URL-1-azit://leavemeempty/multiaccount</destination_filefolder>
<destination_configuration_name>LOCAL-DEST-FILE-1</destination_configuration_name>
<wildcard>input-.*.csv</wildcard>
</field>
</fields>
<parallel>N</parallel>
<xloc>1232</xloc>
<yloc>272</yloc>
<attributes_hac/>
</action>
<action>
<name>[Multiaccount] Delete non-empty folder</name>
<description/>
<type>DELETE_FOLDERS</type>
<attributes/>
<arg_from_previous>N</arg_from_previous>
<success_condition>success_if_no_errors</success_condition>
<limit_folders>10</limit_folders>
<fields>
<field>
<name>azit:///leavemeempty/multiaccount</name>
</field>
</fields>
<parallel>N</parallel>
<xloc>1728</xloc>
<yloc>272</yloc>
<attributes_hac/>
</action>
<action>
<name>[Multiaccount] Create a folder</name>
<description/>
<type>CREATE_FOLDER</type>
<attributes/>
<fail_of_folder_exists>N</fail_of_folder_exists>
<foldername>azit://leavemeempty/multiaccount</foldername>
<parallel>N</parallel>
<xloc>416</xloc>
<yloc>272</yloc>
<attributes_hac/>
</action>
<action>
<name>[multiaccount] Create a folder for the 2nd time should fail</name>
<description/>
<type>CREATE_FOLDER</type>
<attributes/>
<fail_of_folder_exists>Y</fail_of_folder_exists>
<foldername>azit://leavemeempty/multiaccount</foldername>
<parallel>N</parallel>
<xloc>736</xloc>
<yloc>272</yloc>
<attributes_hac/>
</action>
<action>
<name>[Azure scheme] Copy files into dir</name>
<description/>
<type>COPY_FILES</type>
<attributes/>
<copy_empty_folders>N</copy_empty_folders>
<arg_from_previous>N</arg_from_previous>
<overwrite_files>Y</overwrite_files>
<include_subfolders>N</include_subfolders>
<remove_source_files>N</remove_source_files>
<add_result_filesname>N</add_result_filesname>
<destination_is_a_file>N</destination_is_a_file>
<create_destination_folder>N</create_destination_folder>
<fields>
<field>
<source_filefolder>EMPTY_SOURCE_URL-0-${PROJECT_HOME}/datasets/</source_filefolder>
<source_configuration_name>LOCAL-SOURCE-FILE-0</source_configuration_name>
<destination_filefolder>EMPTY_DEST_URL-0-azure://leavemeempty/azure</destination_filefolder>
<destination_configuration_name>LOCAL-DEST-FILE-0</destination_configuration_name>
<wildcard>ingest-.*.csv</wildcard>
</field>
<field>
<source_filefolder>EMPTY_SOURCE_URL-1-${PROJECT_HOME}/datasets/</source_filefolder>
<source_configuration_name>LOCAL-SOURCE-FILE-1</source_configuration_name>
<destination_filefolder>EMPTY_DEST_URL-1-azure://leavemeempty/azure</destination_filefolder>
<destination_configuration_name>LOCAL-DEST-FILE-1</destination_configuration_name>
<wildcard>input-.*.csv</wildcard>
</field>
</fields>
<parallel>N</parallel>
<xloc>1248</xloc>
<yloc>400</yloc>
<attributes_hac/>
</action>
<action>
<name>[Azure scheme] Delete non-empty folder</name>
<description/>
<type>DELETE_FOLDERS</type>
<attributes/>
<arg_from_previous>N</arg_from_previous>
<success_condition>success_if_no_errors</success_condition>
<limit_folders>10</limit_folders>
<fields>
<field>
<name>azure:///leavemeempty/azure</name>
</field>
</fields>
<parallel>N</parallel>
<xloc>1840</xloc>
<yloc>416</yloc>
<attributes_hac/>
</action>
<action>
<name>[Azure scheme] Create a folder</name>
<description/>
<type>CREATE_FOLDER</type>
<attributes/>
<fail_of_folder_exists>N</fail_of_folder_exists>
<foldername>azure://leavemeempty/azure</foldername>
<parallel>N</parallel>
<xloc>400</xloc>
<yloc>400</yloc>
<attributes_hac/>
</action>
<action>
<name>[Azure scheme] Create a folder for the 2nd time should fail</name>
<description/>
<type>CREATE_FOLDER</type>
<attributes/>
<fail_of_folder_exists>Y</fail_of_folder_exists>
<foldername>azure://leavemeempty/azure</foldername>
<parallel>N</parallel>
<xloc>752</xloc>
<yloc>400</yloc>
<attributes_hac/>
</action>
<action>
<name>Start</name>
<description/>
<type>SPECIAL</type>
<attributes/>
<DayOfMonth>1</DayOfMonth>
<hour>12</hour>
<intervalMinutes>60</intervalMinutes>
<intervalSeconds>0</intervalSeconds>
<minutes>0</minutes>
<repeat>N</repeat>
<schedulerType>0</schedulerType>
<weekDay>1</weekDay>
<parallel>N</parallel>
<xloc>128</xloc>
<yloc>256</yloc>
<attributes_hac/>
</action>
<action>
<name>Check if the filesystem root is empty</name>
<description/>
<type>FOLDER_IS_EMPTY</type>
<attributes/>
<foldername>azure://leavemeempty/</foldername>
<include_subfolders>Y</include_subfolders>
<specify_wildcard>N</specify_wildcard>
<parallel>N</parallel>
<xloc>1840</xloc>
<yloc>624</yloc>
<attributes_hac/>
</action>
</actions>
<hops>
<hop>
<from>[Multiaccount] Copy files</from>
<to>[Multiaccount] Delete non-empty folder</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
<hop>
<from>[Multiaccount] Create a folder</from>
<to>[multiaccount] Create a folder for the 2nd time should fail</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
<hop>
<from>[multiaccount] Create a folder for the 2nd time should fail</from>
<to>[Multiaccount] Copy files</to>
<enabled>Y</enabled>
<evaluation>N</evaluation>
<unconditional>N</unconditional>
</hop>
<hop>
<from>[Azure scheme] Copy files into dir</from>
<to>[Azure scheme] Delete non-empty folder</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
<hop>
<from>[Azure scheme] Create a folder</from>
<to>[Azure scheme] Create a folder for the 2nd time should fail</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
<hop>
<from>[Azure scheme] Create a folder for the 2nd time should fail</from>
<to>[Azure scheme] Copy files into dir</to>
<enabled>Y</enabled>
<evaluation>N</evaluation>
<unconditional>N</unconditional>
</hop>
<hop>
<from>[Multiaccount] Delete non-empty folder</from>
<to>[Azure scheme] Create a folder</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
<hop>
<from>Start</from>
<to>[Multiaccount] Create a folder</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>Y</unconditional>
</hop>
<hop>
<from>[Azure scheme] Delete non-empty folder</from>
<to>Check if the filesystem root is empty</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
</hops>
<notepads>
</notepads>
<attributes/>
</workflow>
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"storageAccountEndpoint": "",
"storageAccountName": "${AZURE_ACCOUNT}",
"storageAccountKey": "${AZURE_KEY}"
}
}
Copy link
Author

Choose a reason for hiding this comment

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

with this second argument, this override of the method is able to resolve custom namespaces for picking the right Filesystem provider.
I see @hansva used it all around, instead of the previous version. However I wonder if we should consider to deprecate the old method, which looks the same, for the rest.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are spots where that's not possible because of chicken-egg for example loading the project and metadata can also be done via VFS but can't use the custom locations

Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private boolean deleteFolder(String folderName) {
FileObject filefolder = null;

try {
filefolder = HopVfs.getFileObject(folderName);
filefolder = HopVfs.getFileObject(folderName, getVariables());

if (filefolder.exists()) {
// the file or folder exists
Expand Down
Loading