rucio 37.0.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rucio might be problematic. Click here for more details.
- rucio/__init__.py +17 -0
- rucio/alembicrevision.py +15 -0
- rucio/cli/__init__.py +14 -0
- rucio/cli/account.py +216 -0
- rucio/cli/bin_legacy/__init__.py +13 -0
- rucio/cli/bin_legacy/rucio.py +2825 -0
- rucio/cli/bin_legacy/rucio_admin.py +2500 -0
- rucio/cli/command.py +272 -0
- rucio/cli/config.py +72 -0
- rucio/cli/did.py +191 -0
- rucio/cli/download.py +128 -0
- rucio/cli/lifetime_exception.py +33 -0
- rucio/cli/replica.py +162 -0
- rucio/cli/rse.py +293 -0
- rucio/cli/rule.py +158 -0
- rucio/cli/scope.py +40 -0
- rucio/cli/subscription.py +73 -0
- rucio/cli/upload.py +60 -0
- rucio/cli/utils.py +226 -0
- rucio/client/__init__.py +15 -0
- rucio/client/accountclient.py +432 -0
- rucio/client/accountlimitclient.py +183 -0
- rucio/client/baseclient.py +983 -0
- rucio/client/client.py +120 -0
- rucio/client/configclient.py +126 -0
- rucio/client/credentialclient.py +59 -0
- rucio/client/didclient.py +868 -0
- rucio/client/diracclient.py +56 -0
- rucio/client/downloadclient.py +1783 -0
- rucio/client/exportclient.py +44 -0
- rucio/client/fileclient.py +50 -0
- rucio/client/importclient.py +42 -0
- rucio/client/lifetimeclient.py +90 -0
- rucio/client/lockclient.py +109 -0
- rucio/client/metaconventionsclient.py +140 -0
- rucio/client/pingclient.py +44 -0
- rucio/client/replicaclient.py +452 -0
- rucio/client/requestclient.py +125 -0
- rucio/client/richclient.py +317 -0
- rucio/client/rseclient.py +746 -0
- rucio/client/ruleclient.py +294 -0
- rucio/client/scopeclient.py +90 -0
- rucio/client/subscriptionclient.py +173 -0
- rucio/client/touchclient.py +82 -0
- rucio/client/uploadclient.py +969 -0
- rucio/common/__init__.py +13 -0
- rucio/common/bittorrent.py +234 -0
- rucio/common/cache.py +111 -0
- rucio/common/checksum.py +168 -0
- rucio/common/client.py +122 -0
- rucio/common/config.py +788 -0
- rucio/common/constants.py +217 -0
- rucio/common/constraints.py +17 -0
- rucio/common/didtype.py +237 -0
- rucio/common/dumper/__init__.py +342 -0
- rucio/common/dumper/consistency.py +497 -0
- rucio/common/dumper/data_models.py +362 -0
- rucio/common/dumper/path_parsing.py +75 -0
- rucio/common/exception.py +1208 -0
- rucio/common/extra.py +31 -0
- rucio/common/logging.py +420 -0
- rucio/common/pcache.py +1409 -0
- rucio/common/plugins.py +185 -0
- rucio/common/policy.py +93 -0
- rucio/common/schema/__init__.py +200 -0
- rucio/common/schema/generic.py +416 -0
- rucio/common/schema/generic_multi_vo.py +395 -0
- rucio/common/stomp_utils.py +423 -0
- rucio/common/stopwatch.py +55 -0
- rucio/common/test_rucio_server.py +154 -0
- rucio/common/types.py +483 -0
- rucio/common/utils.py +1688 -0
- rucio/core/__init__.py +13 -0
- rucio/core/account.py +496 -0
- rucio/core/account_counter.py +236 -0
- rucio/core/account_limit.py +425 -0
- rucio/core/authentication.py +620 -0
- rucio/core/config.py +437 -0
- rucio/core/credential.py +224 -0
- rucio/core/did.py +3004 -0
- rucio/core/did_meta_plugins/__init__.py +252 -0
- rucio/core/did_meta_plugins/did_column_meta.py +331 -0
- rucio/core/did_meta_plugins/did_meta_plugin_interface.py +165 -0
- rucio/core/did_meta_plugins/elasticsearch_meta.py +407 -0
- rucio/core/did_meta_plugins/filter_engine.py +672 -0
- rucio/core/did_meta_plugins/json_meta.py +240 -0
- rucio/core/did_meta_plugins/mongo_meta.py +229 -0
- rucio/core/did_meta_plugins/postgres_meta.py +352 -0
- rucio/core/dirac.py +237 -0
- rucio/core/distance.py +187 -0
- rucio/core/exporter.py +59 -0
- rucio/core/heartbeat.py +363 -0
- rucio/core/identity.py +301 -0
- rucio/core/importer.py +260 -0
- rucio/core/lifetime_exception.py +377 -0
- rucio/core/lock.py +577 -0
- rucio/core/message.py +288 -0
- rucio/core/meta_conventions.py +203 -0
- rucio/core/monitor.py +448 -0
- rucio/core/naming_convention.py +195 -0
- rucio/core/nongrid_trace.py +136 -0
- rucio/core/oidc.py +1463 -0
- rucio/core/permission/__init__.py +161 -0
- rucio/core/permission/generic.py +1124 -0
- rucio/core/permission/generic_multi_vo.py +1144 -0
- rucio/core/quarantined_replica.py +224 -0
- rucio/core/replica.py +4483 -0
- rucio/core/replica_sorter.py +362 -0
- rucio/core/request.py +3091 -0
- rucio/core/rse.py +2079 -0
- rucio/core/rse_counter.py +185 -0
- rucio/core/rse_expression_parser.py +459 -0
- rucio/core/rse_selector.py +304 -0
- rucio/core/rule.py +4484 -0
- rucio/core/rule_grouping.py +1620 -0
- rucio/core/scope.py +181 -0
- rucio/core/subscription.py +362 -0
- rucio/core/topology.py +490 -0
- rucio/core/trace.py +375 -0
- rucio/core/transfer.py +1531 -0
- rucio/core/vo.py +169 -0
- rucio/core/volatile_replica.py +151 -0
- rucio/daemons/__init__.py +13 -0
- rucio/daemons/abacus/__init__.py +13 -0
- rucio/daemons/abacus/account.py +116 -0
- rucio/daemons/abacus/collection_replica.py +124 -0
- rucio/daemons/abacus/rse.py +117 -0
- rucio/daemons/atropos/__init__.py +13 -0
- rucio/daemons/atropos/atropos.py +242 -0
- rucio/daemons/auditor/__init__.py +289 -0
- rucio/daemons/auditor/hdfs.py +97 -0
- rucio/daemons/auditor/srmdumps.py +355 -0
- rucio/daemons/automatix/__init__.py +13 -0
- rucio/daemons/automatix/automatix.py +304 -0
- rucio/daemons/badreplicas/__init__.py +13 -0
- rucio/daemons/badreplicas/minos.py +322 -0
- rucio/daemons/badreplicas/minos_temporary_expiration.py +171 -0
- rucio/daemons/badreplicas/necromancer.py +196 -0
- rucio/daemons/bb8/__init__.py +13 -0
- rucio/daemons/bb8/bb8.py +353 -0
- rucio/daemons/bb8/common.py +759 -0
- rucio/daemons/bb8/nuclei_background_rebalance.py +153 -0
- rucio/daemons/bb8/t2_background_rebalance.py +153 -0
- rucio/daemons/cache/__init__.py +13 -0
- rucio/daemons/cache/consumer.py +133 -0
- rucio/daemons/common.py +405 -0
- rucio/daemons/conveyor/__init__.py +13 -0
- rucio/daemons/conveyor/common.py +562 -0
- rucio/daemons/conveyor/finisher.py +529 -0
- rucio/daemons/conveyor/poller.py +394 -0
- rucio/daemons/conveyor/preparer.py +205 -0
- rucio/daemons/conveyor/receiver.py +179 -0
- rucio/daemons/conveyor/stager.py +133 -0
- rucio/daemons/conveyor/submitter.py +403 -0
- rucio/daemons/conveyor/throttler.py +532 -0
- rucio/daemons/follower/__init__.py +13 -0
- rucio/daemons/follower/follower.py +101 -0
- rucio/daemons/hermes/__init__.py +13 -0
- rucio/daemons/hermes/hermes.py +534 -0
- rucio/daemons/judge/__init__.py +13 -0
- rucio/daemons/judge/cleaner.py +159 -0
- rucio/daemons/judge/evaluator.py +185 -0
- rucio/daemons/judge/injector.py +162 -0
- rucio/daemons/judge/repairer.py +154 -0
- rucio/daemons/oauthmanager/__init__.py +13 -0
- rucio/daemons/oauthmanager/oauthmanager.py +198 -0
- rucio/daemons/reaper/__init__.py +13 -0
- rucio/daemons/reaper/dark_reaper.py +282 -0
- rucio/daemons/reaper/reaper.py +739 -0
- rucio/daemons/replicarecoverer/__init__.py +13 -0
- rucio/daemons/replicarecoverer/suspicious_replica_recoverer.py +626 -0
- rucio/daemons/rsedecommissioner/__init__.py +13 -0
- rucio/daemons/rsedecommissioner/config.py +81 -0
- rucio/daemons/rsedecommissioner/profiles/__init__.py +24 -0
- rucio/daemons/rsedecommissioner/profiles/atlas.py +60 -0
- rucio/daemons/rsedecommissioner/profiles/generic.py +452 -0
- rucio/daemons/rsedecommissioner/profiles/types.py +93 -0
- rucio/daemons/rsedecommissioner/rse_decommissioner.py +280 -0
- rucio/daemons/storage/__init__.py +13 -0
- rucio/daemons/storage/consistency/__init__.py +13 -0
- rucio/daemons/storage/consistency/actions.py +848 -0
- rucio/daemons/tracer/__init__.py +13 -0
- rucio/daemons/tracer/kronos.py +511 -0
- rucio/daemons/transmogrifier/__init__.py +13 -0
- rucio/daemons/transmogrifier/transmogrifier.py +762 -0
- rucio/daemons/undertaker/__init__.py +13 -0
- rucio/daemons/undertaker/undertaker.py +137 -0
- rucio/db/__init__.py +13 -0
- rucio/db/sqla/__init__.py +52 -0
- rucio/db/sqla/constants.py +206 -0
- rucio/db/sqla/migrate_repo/__init__.py +13 -0
- rucio/db/sqla/migrate_repo/env.py +110 -0
- rucio/db/sqla/migrate_repo/versions/01eaf73ab656_add_new_rule_notification_state_progress.py +70 -0
- rucio/db/sqla/migrate_repo/versions/0437a40dbfd1_add_eol_at_in_rules.py +47 -0
- rucio/db/sqla/migrate_repo/versions/0f1adb7a599a_create_transfer_hops_table.py +59 -0
- rucio/db/sqla/migrate_repo/versions/102efcf145f4_added_stuck_at_column_to_rules.py +43 -0
- rucio/db/sqla/migrate_repo/versions/13d4f70c66a9_introduce_transfer_limits.py +91 -0
- rucio/db/sqla/migrate_repo/versions/140fef722e91_cleanup_distances_table.py +76 -0
- rucio/db/sqla/migrate_repo/versions/14ec5aeb64cf_add_request_external_host.py +43 -0
- rucio/db/sqla/migrate_repo/versions/156fb5b5a14_add_request_type_to_requests_idx.py +50 -0
- rucio/db/sqla/migrate_repo/versions/1677d4d803c8_split_rse_availability_into_multiple.py +68 -0
- rucio/db/sqla/migrate_repo/versions/16a0aca82e12_create_index_on_table_replicas_path.py +40 -0
- rucio/db/sqla/migrate_repo/versions/1803333ac20f_adding_provenance_and_phys_group.py +45 -0
- rucio/db/sqla/migrate_repo/versions/1a29d6a9504c_add_didtype_chck_to_requests.py +60 -0
- rucio/db/sqla/migrate_repo/versions/1a80adff031a_create_index_on_rules_hist_recent.py +40 -0
- rucio/db/sqla/migrate_repo/versions/1c45d9730ca6_increase_identity_length.py +140 -0
- rucio/db/sqla/migrate_repo/versions/1d1215494e95_add_quarantined_replicas_table.py +73 -0
- rucio/db/sqla/migrate_repo/versions/1d96f484df21_asynchronous_rules_and_rule_approval.py +74 -0
- rucio/db/sqla/migrate_repo/versions/1f46c5f240ac_add_bytes_column_to_bad_replicas.py +43 -0
- rucio/db/sqla/migrate_repo/versions/1fc15ab60d43_add_message_history_table.py +50 -0
- rucio/db/sqla/migrate_repo/versions/2190e703eb6e_move_rse_settings_to_rse_attributes.py +134 -0
- rucio/db/sqla/migrate_repo/versions/21d6b9dc9961_add_mismatch_scheme_state_to_requests.py +64 -0
- rucio/db/sqla/migrate_repo/versions/22cf51430c78_add_availability_column_to_table_rses.py +39 -0
- rucio/db/sqla/migrate_repo/versions/22d887e4ec0a_create_sources_table.py +64 -0
- rucio/db/sqla/migrate_repo/versions/25821a8a45a3_remove_unique_constraint_on_requests.py +51 -0
- rucio/db/sqla/migrate_repo/versions/25fc855625cf_added_unique_constraint_to_rules.py +41 -0
- rucio/db/sqla/migrate_repo/versions/269fee20dee9_add_repair_cnt_to_locks.py +43 -0
- rucio/db/sqla/migrate_repo/versions/271a46ea6244_add_ignore_availability_column_to_rules.py +44 -0
- rucio/db/sqla/migrate_repo/versions/277b5fbb41d3_switch_heartbeats_executable.py +53 -0
- rucio/db/sqla/migrate_repo/versions/27e3a68927fb_remove_replicas_tombstone_and_replicas_.py +38 -0
- rucio/db/sqla/migrate_repo/versions/2854cd9e168_added_rule_id_column.py +47 -0
- rucio/db/sqla/migrate_repo/versions/295289b5a800_processed_by_and__at_in_requests.py +45 -0
- rucio/db/sqla/migrate_repo/versions/2962ece31cf4_add_nbaccesses_column_in_the_did_table.py +45 -0
- rucio/db/sqla/migrate_repo/versions/2af3291ec4c_added_replicas_history_table.py +57 -0
- rucio/db/sqla/migrate_repo/versions/2b69addda658_add_columns_for_third_party_copy_read_.py +45 -0
- rucio/db/sqla/migrate_repo/versions/2b8e7bcb4783_add_config_table.py +69 -0
- rucio/db/sqla/migrate_repo/versions/2ba5229cb54c_add_submitted_at_to_requests_table.py +43 -0
- rucio/db/sqla/migrate_repo/versions/2cbee484dcf9_added_column_volume_to_rse_transfer_.py +42 -0
- rucio/db/sqla/migrate_repo/versions/2edee4a83846_add_source_to_requests_and_requests_.py +47 -0
- rucio/db/sqla/migrate_repo/versions/2eef46be23d4_change_tokens_pk.py +46 -0
- rucio/db/sqla/migrate_repo/versions/2f648fc909f3_index_in_rule_history_on_scope_name.py +40 -0
- rucio/db/sqla/migrate_repo/versions/3082b8cef557_add_naming_convention_table_and_closed_.py +67 -0
- rucio/db/sqla/migrate_repo/versions/30d5206e9cad_increase_oauthrequest_redirect_msg_.py +37 -0
- rucio/db/sqla/migrate_repo/versions/30fa38b6434e_add_index_on_service_column_in_the_message_table.py +44 -0
- rucio/db/sqla/migrate_repo/versions/3152492b110b_added_staging_area_column.py +77 -0
- rucio/db/sqla/migrate_repo/versions/32c7d2783f7e_create_bad_replicas_table.py +60 -0
- rucio/db/sqla/migrate_repo/versions/3345511706b8_replicas_table_pk_definition_is_in_.py +72 -0
- rucio/db/sqla/migrate_repo/versions/35ef10d1e11b_change_index_on_table_requests.py +42 -0
- rucio/db/sqla/migrate_repo/versions/379a19b5332d_create_rse_limits_table.py +65 -0
- rucio/db/sqla/migrate_repo/versions/384b96aa0f60_created_rule_history_tables.py +133 -0
- rucio/db/sqla/migrate_repo/versions/3ac1660a1a72_extend_distance_table.py +55 -0
- rucio/db/sqla/migrate_repo/versions/3ad36e2268b0_create_collection_replicas_updates_table.py +76 -0
- rucio/db/sqla/migrate_repo/versions/3c9df354071b_extend_waiting_request_state.py +60 -0
- rucio/db/sqla/migrate_repo/versions/3d9813fab443_add_a_new_state_lost_in_badfilesstatus.py +44 -0
- rucio/db/sqla/migrate_repo/versions/40ad39ce3160_add_transferred_at_to_requests_table.py +43 -0
- rucio/db/sqla/migrate_repo/versions/4207be2fd914_add_notification_column_to_rules.py +64 -0
- rucio/db/sqla/migrate_repo/versions/42db2617c364_create_index_on_requests_external_id.py +40 -0
- rucio/db/sqla/migrate_repo/versions/436827b13f82_added_column_activity_to_table_requests.py +43 -0
- rucio/db/sqla/migrate_repo/versions/44278720f774_update_requests_typ_sta_upd_idx_index.py +44 -0
- rucio/db/sqla/migrate_repo/versions/45378a1e76a8_create_collection_replica_table.py +78 -0
- rucio/db/sqla/migrate_repo/versions/469d262be19_removing_created_at_index.py +41 -0
- rucio/db/sqla/migrate_repo/versions/4783c1f49cb4_create_distance_table.py +59 -0
- rucio/db/sqla/migrate_repo/versions/49a21b4d4357_create_index_on_table_tokens.py +44 -0
- rucio/db/sqla/migrate_repo/versions/4a2cbedda8b9_add_source_replica_expression_column_to_.py +43 -0
- rucio/db/sqla/migrate_repo/versions/4a7182d9578b_added_bytes_length_accessed_at_columns.py +49 -0
- rucio/db/sqla/migrate_repo/versions/4bab9edd01fc_create_index_on_requests_rule_id.py +40 -0
- rucio/db/sqla/migrate_repo/versions/4c3a4acfe006_new_attr_account_table.py +63 -0
- rucio/db/sqla/migrate_repo/versions/4cf0a2e127d4_adding_transient_metadata.py +43 -0
- rucio/db/sqla/migrate_repo/versions/4df2c5ddabc0_remove_temporary_dids.py +55 -0
- rucio/db/sqla/migrate_repo/versions/50280c53117c_add_qos_class_to_rse.py +45 -0
- rucio/db/sqla/migrate_repo/versions/52153819589c_add_rse_id_to_replicas_table.py +43 -0
- rucio/db/sqla/migrate_repo/versions/52fd9f4916fa_added_activity_to_rules.py +43 -0
- rucio/db/sqla/migrate_repo/versions/53b479c3cb0f_fix_did_meta_table_missing_updated_at_.py +45 -0
- rucio/db/sqla/migrate_repo/versions/5673b4b6e843_add_wfms_metadata_to_rule_tables.py +47 -0
- rucio/db/sqla/migrate_repo/versions/575767d9f89_added_source_history_table.py +58 -0
- rucio/db/sqla/migrate_repo/versions/58bff7008037_add_started_at_to_requests.py +45 -0
- rucio/db/sqla/migrate_repo/versions/58c8b78301ab_rename_callback_to_message.py +106 -0
- rucio/db/sqla/migrate_repo/versions/5f139f77382a_added_child_rule_id_column.py +55 -0
- rucio/db/sqla/migrate_repo/versions/688ef1840840_adding_did_meta_table.py +50 -0
- rucio/db/sqla/migrate_repo/versions/6e572a9bfbf3_add_new_split_container_column_to_rules.py +47 -0
- rucio/db/sqla/migrate_repo/versions/70587619328_add_comment_column_for_subscriptions.py +43 -0
- rucio/db/sqla/migrate_repo/versions/739064d31565_remove_history_table_pks.py +41 -0
- rucio/db/sqla/migrate_repo/versions/7541902bf173_add_didsfollowed_and_followevents_table.py +91 -0
- rucio/db/sqla/migrate_repo/versions/7ec22226cdbf_new_replica_state_for_temporary_.py +72 -0
- rucio/db/sqla/migrate_repo/versions/810a41685bc1_added_columns_rse_transfer_limits.py +49 -0
- rucio/db/sqla/migrate_repo/versions/83f991c63a93_correct_rse_expression_length.py +43 -0
- rucio/db/sqla/migrate_repo/versions/8523998e2e76_increase_size_of_extended_attributes_.py +43 -0
- rucio/db/sqla/migrate_repo/versions/8ea9122275b1_adding_missing_function_based_indices.py +53 -0
- rucio/db/sqla/migrate_repo/versions/90f47792bb76_add_clob_payload_to_messages.py +45 -0
- rucio/db/sqla/migrate_repo/versions/914b8f02df38_new_table_for_lifetime_model_exceptions.py +68 -0
- rucio/db/sqla/migrate_repo/versions/94a5961ddbf2_add_estimator_columns.py +45 -0
- rucio/db/sqla/migrate_repo/versions/9a1b149a2044_add_saml_identity_type.py +94 -0
- rucio/db/sqla/migrate_repo/versions/9a45bc4ea66d_add_vp_table.py +54 -0
- rucio/db/sqla/migrate_repo/versions/9eb936a81eb1_true_is_true.py +72 -0
- rucio/db/sqla/migrate_repo/versions/a08fa8de1545_transfer_stats_table.py +55 -0
- rucio/db/sqla/migrate_repo/versions/a118956323f8_added_vo_table_and_vo_col_to_rse.py +76 -0
- rucio/db/sqla/migrate_repo/versions/a193a275255c_add_status_column_in_messages.py +47 -0
- rucio/db/sqla/migrate_repo/versions/a5f6f6e928a7_1_7_0.py +121 -0
- rucio/db/sqla/migrate_repo/versions/a616581ee47_added_columns_to_table_requests.py +59 -0
- rucio/db/sqla/migrate_repo/versions/a6eb23955c28_state_idx_non_functional.py +52 -0
- rucio/db/sqla/migrate_repo/versions/a74275a1ad30_added_global_quota_table.py +54 -0
- rucio/db/sqla/migrate_repo/versions/a93e4e47bda_heartbeats.py +64 -0
- rucio/db/sqla/migrate_repo/versions/ae2a56fcc89_added_comment_column_to_rules.py +49 -0
- rucio/db/sqla/migrate_repo/versions/b0070f3695c8_add_deletedidmeta_table.py +57 -0
- rucio/db/sqla/migrate_repo/versions/b4293a99f344_added_column_identity_to_table_tokens.py +43 -0
- rucio/db/sqla/migrate_repo/versions/b5493606bbf5_fix_primary_key_for_subscription_history.py +41 -0
- rucio/db/sqla/migrate_repo/versions/b7d287de34fd_removal_of_replicastate_source.py +91 -0
- rucio/db/sqla/migrate_repo/versions/b818052fa670_add_index_to_quarantined_replicas.py +40 -0
- rucio/db/sqla/migrate_repo/versions/b8caac94d7f0_add_comments_column_for_subscriptions_.py +43 -0
- rucio/db/sqla/migrate_repo/versions/b96a1c7e1cc4_new_bad_pfns_table_and_bad_replicas_.py +143 -0
- rucio/db/sqla/migrate_repo/versions/bb695f45c04_extend_request_state.py +76 -0
- rucio/db/sqla/migrate_repo/versions/bc68e9946deb_add_staging_timestamps_to_request.py +50 -0
- rucio/db/sqla/migrate_repo/versions/bf3baa1c1474_correct_pk_and_idx_for_history_tables.py +72 -0
- rucio/db/sqla/migrate_repo/versions/c0937668555f_add_qos_policy_map_table.py +55 -0
- rucio/db/sqla/migrate_repo/versions/c129ccdb2d5_add_lumiblocknr_to_dids.py +43 -0
- rucio/db/sqla/migrate_repo/versions/ccdbcd48206e_add_did_type_column_index_on_did_meta_.py +65 -0
- rucio/db/sqla/migrate_repo/versions/cebad904c4dd_new_payload_column_for_heartbeats.py +47 -0
- rucio/db/sqla/migrate_repo/versions/d1189a09c6e0_oauth2_0_and_jwt_feature_support_adding_.py +146 -0
- rucio/db/sqla/migrate_repo/versions/d23453595260_extend_request_state_for_preparer.py +104 -0
- rucio/db/sqla/migrate_repo/versions/d6dceb1de2d_added_purge_column_to_rules.py +44 -0
- rucio/db/sqla/migrate_repo/versions/d6e2c3b2cf26_remove_third_party_copy_column_from_rse.py +43 -0
- rucio/db/sqla/migrate_repo/versions/d91002c5841_new_account_limits_table.py +103 -0
- rucio/db/sqla/migrate_repo/versions/e138c364ebd0_extending_columns_for_filter_and_.py +49 -0
- rucio/db/sqla/migrate_repo/versions/e59300c8b179_support_for_archive.py +104 -0
- rucio/db/sqla/migrate_repo/versions/f1b14a8c2ac1_postgres_use_check_constraints.py +29 -0
- rucio/db/sqla/migrate_repo/versions/f41ffe206f37_oracle_global_temporary_tables.py +74 -0
- rucio/db/sqla/migrate_repo/versions/f85a2962b021_adding_transfertool_column_to_requests_.py +47 -0
- rucio/db/sqla/migrate_repo/versions/fa7a7d78b602_increase_refresh_token_size.py +43 -0
- rucio/db/sqla/migrate_repo/versions/fb28a95fe288_add_replicas_rse_id_tombstone_idx.py +37 -0
- rucio/db/sqla/migrate_repo/versions/fe1a65b176c9_set_third_party_copy_read_and_write_.py +43 -0
- rucio/db/sqla/migrate_repo/versions/fe8ea2fa9788_added_third_party_copy_column_to_rse_.py +43 -0
- rucio/db/sqla/models.py +1743 -0
- rucio/db/sqla/sautils.py +55 -0
- rucio/db/sqla/session.py +529 -0
- rucio/db/sqla/types.py +206 -0
- rucio/db/sqla/util.py +543 -0
- rucio/gateway/__init__.py +13 -0
- rucio/gateway/account.py +345 -0
- rucio/gateway/account_limit.py +363 -0
- rucio/gateway/authentication.py +381 -0
- rucio/gateway/config.py +227 -0
- rucio/gateway/credential.py +70 -0
- rucio/gateway/did.py +987 -0
- rucio/gateway/dirac.py +83 -0
- rucio/gateway/exporter.py +60 -0
- rucio/gateway/heartbeat.py +76 -0
- rucio/gateway/identity.py +189 -0
- rucio/gateway/importer.py +46 -0
- rucio/gateway/lifetime_exception.py +121 -0
- rucio/gateway/lock.py +153 -0
- rucio/gateway/meta_conventions.py +98 -0
- rucio/gateway/permission.py +74 -0
- rucio/gateway/quarantined_replica.py +79 -0
- rucio/gateway/replica.py +538 -0
- rucio/gateway/request.py +330 -0
- rucio/gateway/rse.py +632 -0
- rucio/gateway/rule.py +437 -0
- rucio/gateway/scope.py +100 -0
- rucio/gateway/subscription.py +280 -0
- rucio/gateway/vo.py +126 -0
- rucio/rse/__init__.py +96 -0
- rucio/rse/protocols/__init__.py +13 -0
- rucio/rse/protocols/bittorrent.py +194 -0
- rucio/rse/protocols/cache.py +111 -0
- rucio/rse/protocols/dummy.py +100 -0
- rucio/rse/protocols/gfal.py +708 -0
- rucio/rse/protocols/globus.py +243 -0
- rucio/rse/protocols/http_cache.py +82 -0
- rucio/rse/protocols/mock.py +123 -0
- rucio/rse/protocols/ngarc.py +209 -0
- rucio/rse/protocols/posix.py +250 -0
- rucio/rse/protocols/protocol.py +361 -0
- rucio/rse/protocols/rclone.py +365 -0
- rucio/rse/protocols/rfio.py +145 -0
- rucio/rse/protocols/srm.py +338 -0
- rucio/rse/protocols/ssh.py +414 -0
- rucio/rse/protocols/storm.py +195 -0
- rucio/rse/protocols/webdav.py +594 -0
- rucio/rse/protocols/xrootd.py +302 -0
- rucio/rse/rsemanager.py +881 -0
- rucio/rse/translation.py +260 -0
- rucio/tests/__init__.py +13 -0
- rucio/tests/common.py +280 -0
- rucio/tests/common_server.py +149 -0
- rucio/transfertool/__init__.py +13 -0
- rucio/transfertool/bittorrent.py +200 -0
- rucio/transfertool/bittorrent_driver.py +50 -0
- rucio/transfertool/bittorrent_driver_qbittorrent.py +134 -0
- rucio/transfertool/fts3.py +1600 -0
- rucio/transfertool/fts3_plugins.py +152 -0
- rucio/transfertool/globus.py +201 -0
- rucio/transfertool/globus_library.py +181 -0
- rucio/transfertool/mock.py +89 -0
- rucio/transfertool/transfertool.py +221 -0
- rucio/vcsversion.py +11 -0
- rucio/version.py +45 -0
- rucio/web/__init__.py +13 -0
- rucio/web/rest/__init__.py +13 -0
- rucio/web/rest/flaskapi/__init__.py +13 -0
- rucio/web/rest/flaskapi/authenticated_bp.py +27 -0
- rucio/web/rest/flaskapi/v1/__init__.py +13 -0
- rucio/web/rest/flaskapi/v1/accountlimits.py +236 -0
- rucio/web/rest/flaskapi/v1/accounts.py +1103 -0
- rucio/web/rest/flaskapi/v1/archives.py +102 -0
- rucio/web/rest/flaskapi/v1/auth.py +1644 -0
- rucio/web/rest/flaskapi/v1/common.py +426 -0
- rucio/web/rest/flaskapi/v1/config.py +304 -0
- rucio/web/rest/flaskapi/v1/credentials.py +213 -0
- rucio/web/rest/flaskapi/v1/dids.py +2340 -0
- rucio/web/rest/flaskapi/v1/dirac.py +116 -0
- rucio/web/rest/flaskapi/v1/export.py +75 -0
- rucio/web/rest/flaskapi/v1/heartbeats.py +127 -0
- rucio/web/rest/flaskapi/v1/identities.py +285 -0
- rucio/web/rest/flaskapi/v1/import.py +132 -0
- rucio/web/rest/flaskapi/v1/lifetime_exceptions.py +312 -0
- rucio/web/rest/flaskapi/v1/locks.py +358 -0
- rucio/web/rest/flaskapi/v1/main.py +91 -0
- rucio/web/rest/flaskapi/v1/meta_conventions.py +241 -0
- rucio/web/rest/flaskapi/v1/metrics.py +36 -0
- rucio/web/rest/flaskapi/v1/nongrid_traces.py +97 -0
- rucio/web/rest/flaskapi/v1/ping.py +88 -0
- rucio/web/rest/flaskapi/v1/redirect.py +366 -0
- rucio/web/rest/flaskapi/v1/replicas.py +1894 -0
- rucio/web/rest/flaskapi/v1/requests.py +998 -0
- rucio/web/rest/flaskapi/v1/rses.py +2250 -0
- rucio/web/rest/flaskapi/v1/rules.py +854 -0
- rucio/web/rest/flaskapi/v1/scopes.py +159 -0
- rucio/web/rest/flaskapi/v1/subscriptions.py +650 -0
- rucio/web/rest/flaskapi/v1/templates/auth_crash.html +80 -0
- rucio/web/rest/flaskapi/v1/templates/auth_granted.html +82 -0
- rucio/web/rest/flaskapi/v1/traces.py +137 -0
- rucio/web/rest/flaskapi/v1/types.py +20 -0
- rucio/web/rest/flaskapi/v1/vos.py +278 -0
- rucio/web/rest/main.py +18 -0
- rucio/web/rest/metrics.py +27 -0
- rucio/web/rest/ping.py +27 -0
- rucio-37.0.0rc1.data/data/rucio/etc/alembic.ini.template +71 -0
- rucio-37.0.0rc1.data/data/rucio/etc/alembic_offline.ini.template +74 -0
- rucio-37.0.0rc1.data/data/rucio/etc/globus-config.yml.template +5 -0
- rucio-37.0.0rc1.data/data/rucio/etc/ldap.cfg.template +30 -0
- rucio-37.0.0rc1.data/data/rucio/etc/mail_templates/rule_approval_request.tmpl +38 -0
- rucio-37.0.0rc1.data/data/rucio/etc/mail_templates/rule_approved_admin.tmpl +4 -0
- rucio-37.0.0rc1.data/data/rucio/etc/mail_templates/rule_approved_user.tmpl +17 -0
- rucio-37.0.0rc1.data/data/rucio/etc/mail_templates/rule_denied_admin.tmpl +6 -0
- rucio-37.0.0rc1.data/data/rucio/etc/mail_templates/rule_denied_user.tmpl +17 -0
- rucio-37.0.0rc1.data/data/rucio/etc/mail_templates/rule_ok_notification.tmpl +19 -0
- rucio-37.0.0rc1.data/data/rucio/etc/rse-accounts.cfg.template +25 -0
- rucio-37.0.0rc1.data/data/rucio/etc/rucio.cfg.atlas.client.template +43 -0
- rucio-37.0.0rc1.data/data/rucio/etc/rucio.cfg.template +241 -0
- rucio-37.0.0rc1.data/data/rucio/etc/rucio_multi_vo.cfg.template +217 -0
- rucio-37.0.0rc1.data/data/rucio/requirements.server.txt +297 -0
- rucio-37.0.0rc1.data/data/rucio/tools/bootstrap.py +34 -0
- rucio-37.0.0rc1.data/data/rucio/tools/merge_rucio_configs.py +144 -0
- rucio-37.0.0rc1.data/data/rucio/tools/reset_database.py +40 -0
- rucio-37.0.0rc1.data/scripts/rucio +133 -0
- rucio-37.0.0rc1.data/scripts/rucio-abacus-account +74 -0
- rucio-37.0.0rc1.data/scripts/rucio-abacus-collection-replica +46 -0
- rucio-37.0.0rc1.data/scripts/rucio-abacus-rse +78 -0
- rucio-37.0.0rc1.data/scripts/rucio-admin +97 -0
- rucio-37.0.0rc1.data/scripts/rucio-atropos +60 -0
- rucio-37.0.0rc1.data/scripts/rucio-auditor +206 -0
- rucio-37.0.0rc1.data/scripts/rucio-automatix +50 -0
- rucio-37.0.0rc1.data/scripts/rucio-bb8 +57 -0
- rucio-37.0.0rc1.data/scripts/rucio-cache-client +141 -0
- rucio-37.0.0rc1.data/scripts/rucio-cache-consumer +42 -0
- rucio-37.0.0rc1.data/scripts/rucio-conveyor-finisher +58 -0
- rucio-37.0.0rc1.data/scripts/rucio-conveyor-poller +66 -0
- rucio-37.0.0rc1.data/scripts/rucio-conveyor-preparer +37 -0
- rucio-37.0.0rc1.data/scripts/rucio-conveyor-receiver +44 -0
- rucio-37.0.0rc1.data/scripts/rucio-conveyor-stager +76 -0
- rucio-37.0.0rc1.data/scripts/rucio-conveyor-submitter +139 -0
- rucio-37.0.0rc1.data/scripts/rucio-conveyor-throttler +104 -0
- rucio-37.0.0rc1.data/scripts/rucio-dark-reaper +53 -0
- rucio-37.0.0rc1.data/scripts/rucio-dumper +160 -0
- rucio-37.0.0rc1.data/scripts/rucio-follower +44 -0
- rucio-37.0.0rc1.data/scripts/rucio-hermes +54 -0
- rucio-37.0.0rc1.data/scripts/rucio-judge-cleaner +89 -0
- rucio-37.0.0rc1.data/scripts/rucio-judge-evaluator +137 -0
- rucio-37.0.0rc1.data/scripts/rucio-judge-injector +44 -0
- rucio-37.0.0rc1.data/scripts/rucio-judge-repairer +44 -0
- rucio-37.0.0rc1.data/scripts/rucio-kronos +44 -0
- rucio-37.0.0rc1.data/scripts/rucio-minos +53 -0
- rucio-37.0.0rc1.data/scripts/rucio-minos-temporary-expiration +50 -0
- rucio-37.0.0rc1.data/scripts/rucio-necromancer +120 -0
- rucio-37.0.0rc1.data/scripts/rucio-oauth-manager +63 -0
- rucio-37.0.0rc1.data/scripts/rucio-reaper +83 -0
- rucio-37.0.0rc1.data/scripts/rucio-replica-recoverer +248 -0
- rucio-37.0.0rc1.data/scripts/rucio-rse-decommissioner +66 -0
- rucio-37.0.0rc1.data/scripts/rucio-storage-consistency-actions +74 -0
- rucio-37.0.0rc1.data/scripts/rucio-transmogrifier +77 -0
- rucio-37.0.0rc1.data/scripts/rucio-undertaker +76 -0
- rucio-37.0.0rc1.dist-info/METADATA +92 -0
- rucio-37.0.0rc1.dist-info/RECORD +487 -0
- rucio-37.0.0rc1.dist-info/WHEEL +5 -0
- rucio-37.0.0rc1.dist-info/licenses/AUTHORS.rst +100 -0
- rucio-37.0.0rc1.dist-info/licenses/LICENSE +201 -0
- rucio-37.0.0rc1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1600 @@
|
|
|
1
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import datetime
|
|
16
|
+
import json
|
|
17
|
+
import logging
|
|
18
|
+
import pathlib
|
|
19
|
+
import traceback
|
|
20
|
+
import uuid
|
|
21
|
+
from configparser import NoOptionError, NoSectionError
|
|
22
|
+
from json import loads
|
|
23
|
+
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
24
|
+
from urllib.parse import urlparse
|
|
25
|
+
|
|
26
|
+
import requests
|
|
27
|
+
from dogpile.cache.api import NoValue
|
|
28
|
+
from requests.adapters import ReadTimeout
|
|
29
|
+
from requests.packages.urllib3 import disable_warnings # pylint: disable=import-error
|
|
30
|
+
|
|
31
|
+
from rucio.common.cache import MemcacheRegion
|
|
32
|
+
from rucio.common.checksum import PREFERRED_CHECKSUM
|
|
33
|
+
from rucio.common.config import config_get, config_get_bool, config_get_int, config_get_list
|
|
34
|
+
from rucio.common.constants import FTS_COMPLETE_STATE, FTS_JOB_TYPE, FTS_STATE, RseAttr
|
|
35
|
+
from rucio.common.exception import DuplicateFileTransferSubmission, TransferToolTimeout, TransferToolWrongAnswer
|
|
36
|
+
from rucio.common.policy import get_policy
|
|
37
|
+
from rucio.common.stopwatch import Stopwatch
|
|
38
|
+
from rucio.common.utils import APIEncoder, chunks, deep_merge_dict
|
|
39
|
+
from rucio.core.monitor import MetricManager
|
|
40
|
+
from rucio.core.oidc import request_token
|
|
41
|
+
from rucio.core.request import get_source_rse, get_transfer_error
|
|
42
|
+
from rucio.core.rse import determine_audience_for_rse, determine_scope_for_rse, get_rse_supported_checksums_from_attributes
|
|
43
|
+
from rucio.db.sqla.constants import RequestState
|
|
44
|
+
from rucio.transfertool.fts3_plugins import FTS3TapeMetadataPlugin
|
|
45
|
+
from rucio.transfertool.transfertool import TransferStatusReport, Transfertool, TransferToolBuilder
|
|
46
|
+
|
|
47
|
+
if TYPE_CHECKING:
|
|
48
|
+
from collections.abc import Iterable, Sequence
|
|
49
|
+
|
|
50
|
+
from sqlalchemy.orm import Session
|
|
51
|
+
|
|
52
|
+
from rucio.common.types import LoggerFunction
|
|
53
|
+
from rucio.core.request import DirectTransfer
|
|
54
|
+
from rucio.core.rse import RseData
|
|
55
|
+
|
|
56
|
+
logging.getLogger("requests").setLevel(logging.CRITICAL)
|
|
57
|
+
disable_warnings()
|
|
58
|
+
|
|
59
|
+
REGION_SHORT = MemcacheRegion(expiration_time=900)
|
|
60
|
+
METRICS = MetricManager(module=__name__)
|
|
61
|
+
|
|
62
|
+
SUBMISSION_COUNTER = METRICS.counter(name='{host}.submission.{state}',
|
|
63
|
+
documentation='Number of transfers submitted', labelnames=('state', 'host'))
|
|
64
|
+
CANCEL_COUNTER = METRICS.counter(name='{host}.cancel.{state}',
|
|
65
|
+
documentation='Number of cancelled transfers', labelnames=('state', 'host'))
|
|
66
|
+
UPDATE_PRIORITY_COUNTER = METRICS.counter(name='{host}.update_priority.{state}',
|
|
67
|
+
documentation='Number of priority updates', labelnames=('state', 'host'))
|
|
68
|
+
QUERY_COUNTER = METRICS.counter(name='{host}.query.{state}',
|
|
69
|
+
documentation='Number of queried transfers', labelnames=('state', 'host'))
|
|
70
|
+
WHOAMI_COUNTER = METRICS.counter(name='{host}.whoami.{state}',
|
|
71
|
+
documentation='Number of whoami requests', labelnames=('state', 'host'))
|
|
72
|
+
VERSION_COUNTER = METRICS.counter(name='{host}.version.{state}',
|
|
73
|
+
documentation='Number of version requests', labelnames=('state', 'host'))
|
|
74
|
+
BULK_QUERY_COUNTER = METRICS.counter(name='{host}.bulk_query.{state}',
|
|
75
|
+
documentation='Number of bulk queries', labelnames=('state', 'host'))
|
|
76
|
+
QUERY_DETAILS_COUNTER = METRICS.counter(name='{host}.query_details.{state}',
|
|
77
|
+
documentation='Number of detailed status queries', labelnames=('state', 'host'))
|
|
78
|
+
|
|
79
|
+
REWRITE_HTTPS_TO_DAVS = config_get_bool('transfers', 'rewrite_https_to_davs', default=False)
|
|
80
|
+
VO_CERTS_PATH = config_get('conveyor', 'vo_certs_path', False, None)
|
|
81
|
+
|
|
82
|
+
# https://fts3-docs.web.cern.ch/fts3-docs/docs/state_machine.html
|
|
83
|
+
FINAL_FTS_JOB_STATES = (FTS_STATE.FAILED, FTS_STATE.CANCELED, FTS_STATE.FINISHED, FTS_STATE.FINISHEDDIRTY)
|
|
84
|
+
FINAL_FTS_FILE_STATES = (FTS_STATE.FAILED, FTS_STATE.CANCELED, FTS_STATE.FINISHED, FTS_STATE.NOT_USED)
|
|
85
|
+
|
|
86
|
+
# In a multi-hop transfer, we must compute a checksum validation strategy valid for the whole path.
|
|
87
|
+
# This state-machine defines how strategies of hops are merged into a path-wide strategy.
|
|
88
|
+
# For example, if HOP1 supports only validation of checksum at source while HOP2 only
|
|
89
|
+
# supports validation at destination, the strategy for the whole path MUST be "none". Otherwise,
|
|
90
|
+
# transfers will fail when FTS will try to validate the checksum.
|
|
91
|
+
PATH_CHECKSUM_VALIDATION_STRATEGY: dict[tuple[str, str], str] = {
|
|
92
|
+
('both', 'both'): 'both',
|
|
93
|
+
('both', 'target'): 'target',
|
|
94
|
+
('both', 'source'): 'source',
|
|
95
|
+
('both', 'none'): 'none',
|
|
96
|
+
('target', 'both'): 'target',
|
|
97
|
+
('target', 'target'): 'target',
|
|
98
|
+
('target', 'source'): 'none',
|
|
99
|
+
('target', 'none'): 'none',
|
|
100
|
+
('source', 'both'): 'source',
|
|
101
|
+
('source', 'target'): 'none',
|
|
102
|
+
('source', 'source'): 'source',
|
|
103
|
+
('source', 'none'): 'none',
|
|
104
|
+
('none', 'both'): 'none',
|
|
105
|
+
('none', 'target'): 'none',
|
|
106
|
+
('none', 'source'): 'none',
|
|
107
|
+
('none', 'none'): 'none',
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_SCITAGS_NEXT_REFRESH = datetime.datetime.utcnow()
|
|
111
|
+
_SCITAGS_EXP_ID = None
|
|
112
|
+
_SCITAGS_ACTIVITY_IDS = {}
|
|
113
|
+
|
|
114
|
+
FTS_FILE_EXISTS_ERROR_MSG = 'Destination file exists and is on tape' # used in FTS >= 3.12.12
|
|
115
|
+
FTS_FILE_EXISTS_ERROR_MSG_LEGACY = 'Destination file exists and overwrite is not enabled' # Error message used in FTS < 3.12.12, checked in Rucio for backwards compatibility
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _scitags_ids(logger: "LoggerFunction" = logging.log) -> "tuple[int | None, dict[str, int]]":
|
|
119
|
+
"""
|
|
120
|
+
Re-fetch if needed and return the scitags ids
|
|
121
|
+
"""
|
|
122
|
+
enabled = config_get_bool('packet-marking', 'enabled', default=False)
|
|
123
|
+
if not enabled:
|
|
124
|
+
return None, {}
|
|
125
|
+
|
|
126
|
+
now = datetime.datetime.utcnow()
|
|
127
|
+
global _SCITAGS_ACTIVITY_IDS
|
|
128
|
+
global _SCITAGS_EXP_ID
|
|
129
|
+
global _SCITAGS_NEXT_REFRESH
|
|
130
|
+
if _SCITAGS_NEXT_REFRESH < now:
|
|
131
|
+
exp_name = config_get('packet-marking', 'exp_name', default='')
|
|
132
|
+
fetch_url = config_get('packet-marking', 'fetch_url', default='https://www.scitags.org/api.json')
|
|
133
|
+
fetch_interval = config_get_int('packet-marking', 'fetch_interval', default=int(datetime.timedelta(hours=48).total_seconds()))
|
|
134
|
+
fetch_timeout = config_get_int('packet-marking', 'fetch_timeout', default=5)
|
|
135
|
+
|
|
136
|
+
_SCITAGS_NEXT_REFRESH = now + datetime.timedelta(seconds=fetch_interval)
|
|
137
|
+
|
|
138
|
+
if exp_name:
|
|
139
|
+
had_exception = False
|
|
140
|
+
exp_id = None
|
|
141
|
+
activity_ids = {}
|
|
142
|
+
try:
|
|
143
|
+
result = requests.get(fetch_url, timeout=fetch_timeout)
|
|
144
|
+
if result and result.status_code == 200:
|
|
145
|
+
marks = result.json()
|
|
146
|
+
for experiment in marks.get('experiments', []):
|
|
147
|
+
if experiment.get('expName') == exp_name:
|
|
148
|
+
exp_id = experiment.get('expId')
|
|
149
|
+
for activity_dict in experiment.get('activities', []):
|
|
150
|
+
activity_name = activity_dict.get('activityName')
|
|
151
|
+
activity_id = activity_dict.get('activityId')
|
|
152
|
+
if activity_name and activity_id:
|
|
153
|
+
activity_ids[activity_name] = int(activity_id)
|
|
154
|
+
break
|
|
155
|
+
except (requests.exceptions.RequestException, TypeError, ValueError):
|
|
156
|
+
had_exception = True
|
|
157
|
+
logger(logging.WARNING, 'Failed to fetch the scitags markings', exc_info=True)
|
|
158
|
+
|
|
159
|
+
if had_exception:
|
|
160
|
+
# Retry quicker after fetch errors
|
|
161
|
+
_SCITAGS_NEXT_REFRESH = min(_SCITAGS_NEXT_REFRESH, now + datetime.timedelta(minutes=5))
|
|
162
|
+
else:
|
|
163
|
+
_SCITAGS_EXP_ID = exp_id
|
|
164
|
+
_SCITAGS_ACTIVITY_IDS = activity_ids
|
|
165
|
+
|
|
166
|
+
return _SCITAGS_EXP_ID, _SCITAGS_ACTIVITY_IDS
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _pick_cert_file(vo: Optional[str]) -> Optional[str]:
|
|
170
|
+
cert = None
|
|
171
|
+
if vo:
|
|
172
|
+
vo_cert = config_get('vo_certs', vo, False, None)
|
|
173
|
+
if vo_cert:
|
|
174
|
+
cert = vo_cert
|
|
175
|
+
elif VO_CERTS_PATH:
|
|
176
|
+
vo_cert = pathlib.Path(VO_CERTS_PATH) / vo
|
|
177
|
+
if vo_cert.exists():
|
|
178
|
+
cert = str(vo_cert)
|
|
179
|
+
if not cert:
|
|
180
|
+
usercert = config_get('conveyor', 'usercert', False, None)
|
|
181
|
+
if usercert:
|
|
182
|
+
cert = usercert
|
|
183
|
+
return cert
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _configured_source_strategy(activity: str, logger: "LoggerFunction") -> str:
|
|
187
|
+
"""
|
|
188
|
+
Retrieve from the configuration the source selection strategy for the given activity
|
|
189
|
+
"""
|
|
190
|
+
try:
|
|
191
|
+
default_source_strategy = config_get(section='conveyor', option='default-source-strategy')
|
|
192
|
+
except (NoOptionError, NoSectionError, RuntimeError):
|
|
193
|
+
default_source_strategy = 'orderly'
|
|
194
|
+
|
|
195
|
+
try:
|
|
196
|
+
activity_source_strategy = config_get(section='conveyor', option='activity-source-strategy')
|
|
197
|
+
activity_source_strategy = loads(activity_source_strategy)
|
|
198
|
+
except (NoOptionError, NoSectionError, RuntimeError):
|
|
199
|
+
activity_source_strategy = {}
|
|
200
|
+
except ValueError:
|
|
201
|
+
logger(logging.WARNING, 'activity_source_strategy not properly defined')
|
|
202
|
+
activity_source_strategy = {}
|
|
203
|
+
|
|
204
|
+
return activity_source_strategy.get(str(activity), default_source_strategy)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _available_checksums(
|
|
208
|
+
transfer: "DirectTransfer",
|
|
209
|
+
) -> tuple[set[str], set[str]]:
|
|
210
|
+
"""
|
|
211
|
+
Get checksums which can be used for file validation on the source and the destination RSE
|
|
212
|
+
"""
|
|
213
|
+
src_attributes = transfer.src.rse.attributes
|
|
214
|
+
if src_attributes.get(RseAttr.VERIFY_CHECKSUM, True):
|
|
215
|
+
src_checksums = set(get_rse_supported_checksums_from_attributes(src_attributes))
|
|
216
|
+
else:
|
|
217
|
+
src_checksums = set()
|
|
218
|
+
|
|
219
|
+
dst_attributes = transfer.dst.rse.attributes
|
|
220
|
+
if dst_attributes.get(RseAttr.VERIFY_CHECKSUM, True):
|
|
221
|
+
dst_checksums = set(get_rse_supported_checksums_from_attributes(dst_attributes))
|
|
222
|
+
else:
|
|
223
|
+
dst_checksums = set()
|
|
224
|
+
|
|
225
|
+
return src_checksums, dst_checksums
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _hop_checksum_validation_strategy(
|
|
229
|
+
transfer: "DirectTransfer",
|
|
230
|
+
logger: "LoggerFunction",
|
|
231
|
+
) -> tuple[str, set[str]]:
|
|
232
|
+
"""
|
|
233
|
+
Compute the checksum validation strategy (none, source, destination or both) depending
|
|
234
|
+
on available source and destination checksums for a single hop transfer
|
|
235
|
+
"""
|
|
236
|
+
src_checksums, dst_checksums = _available_checksums(transfer)
|
|
237
|
+
intersection = src_checksums.intersection(dst_checksums)
|
|
238
|
+
|
|
239
|
+
if intersection:
|
|
240
|
+
strategy, possible_checksums = 'both', intersection
|
|
241
|
+
elif dst_checksums:
|
|
242
|
+
# The prioritization of destination over source here is desired, not random
|
|
243
|
+
logger(logging.INFO, f'No common checksum method for {transfer}. Verifying destination only.')
|
|
244
|
+
strategy, possible_checksums = 'target', dst_checksums
|
|
245
|
+
elif src_checksums:
|
|
246
|
+
logger(logging.INFO, f'No common checksum method for {transfer}. Verifying source only.')
|
|
247
|
+
strategy, possible_checksums = 'source', src_checksums
|
|
248
|
+
else:
|
|
249
|
+
logger(logging.INFO, f'No common checksum method for {transfer}. Not verifying source nor destination.')
|
|
250
|
+
strategy, possible_checksums = 'none', set()
|
|
251
|
+
return strategy, possible_checksums
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _path_checksum_validation_strategy(
|
|
255
|
+
transfer_path: "list[DirectTransfer]",
|
|
256
|
+
logger: "LoggerFunction",
|
|
257
|
+
) -> str:
|
|
258
|
+
"""
|
|
259
|
+
Compute the checksum validation strategy for the whole transfer path.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
path_strategy = 'both'
|
|
263
|
+
for transfer_hop in transfer_path:
|
|
264
|
+
hop_strategy, _ = _hop_checksum_validation_strategy(transfer_hop, logger)
|
|
265
|
+
|
|
266
|
+
path_strategy = PATH_CHECKSUM_VALIDATION_STRATEGY.get((path_strategy, hop_strategy), 'none')
|
|
267
|
+
|
|
268
|
+
return path_strategy
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def _pick_fts_checksum(
|
|
272
|
+
transfer: "DirectTransfer",
|
|
273
|
+
path_strategy: "str",
|
|
274
|
+
) -> Optional[str]:
|
|
275
|
+
"""
|
|
276
|
+
Pick the checksum to use for validating file integrity on this particular transfer hop.
|
|
277
|
+
This function will only work correctly for values of 'path_strategy' which are
|
|
278
|
+
valid for the englobing multi-hop transfer path.
|
|
279
|
+
|
|
280
|
+
Returns the checksum as a string in the format expected by the FTS bulks submission API.
|
|
281
|
+
"""
|
|
282
|
+
src_checksums, dst_checksums = _available_checksums(transfer)
|
|
283
|
+
|
|
284
|
+
if path_strategy == 'both':
|
|
285
|
+
possible_checksums = src_checksums.intersection(dst_checksums)
|
|
286
|
+
elif path_strategy == 'target':
|
|
287
|
+
possible_checksums = dst_checksums
|
|
288
|
+
elif path_strategy == 'source':
|
|
289
|
+
possible_checksums = src_checksums
|
|
290
|
+
else:
|
|
291
|
+
possible_checksums = set()
|
|
292
|
+
|
|
293
|
+
checksum_to_use = None
|
|
294
|
+
for checksum_name in possible_checksums:
|
|
295
|
+
checksum_value = getattr(transfer.rws, checksum_name, '')
|
|
296
|
+
if not checksum_value:
|
|
297
|
+
continue
|
|
298
|
+
|
|
299
|
+
checksum_to_use = '%s:%s' % (checksum_name.upper(), checksum_value)
|
|
300
|
+
if checksum_name == PREFERRED_CHECKSUM:
|
|
301
|
+
break
|
|
302
|
+
|
|
303
|
+
return checksum_to_use
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def _use_tokens(transfer_hop: "DirectTransfer"):
|
|
307
|
+
"""Whether a transfer can be performed with tokens.
|
|
308
|
+
|
|
309
|
+
In order to be so, all the involved RSEs must have it explicitly enabled
|
|
310
|
+
and the protocol being used must be WebDAV.
|
|
311
|
+
"""
|
|
312
|
+
for endpoint in [*transfer_hop.sources, transfer_hop.dst]:
|
|
313
|
+
if (endpoint.rse.attributes.get(RseAttr.OIDC_SUPPORT) is not True
|
|
314
|
+
or endpoint.scheme != 'davs'):
|
|
315
|
+
return False
|
|
316
|
+
return True
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def build_job_params(
|
|
320
|
+
transfer_path: list["DirectTransfer"],
|
|
321
|
+
bring_online: Optional[int] = None,
|
|
322
|
+
default_lifetime: Optional[int] = None,
|
|
323
|
+
archive_timeout_override: Optional[int] = None,
|
|
324
|
+
max_time_in_queue: Optional[dict] = None,
|
|
325
|
+
logger: "LoggerFunction" = logging.log
|
|
326
|
+
) -> dict[str, Any]:
|
|
327
|
+
"""
|
|
328
|
+
Prepare the job parameters which will be passed to FTS transfertool
|
|
329
|
+
Please refer to https://fts3-docs.web.cern.ch/fts3-docs/fts-rest/docs/bulk.html#parameters
|
|
330
|
+
for the list of parameters.
|
|
331
|
+
"""
|
|
332
|
+
|
|
333
|
+
# The last hop is the main request (the one which triggered the whole transfer),
|
|
334
|
+
# so most attributes will come from it
|
|
335
|
+
last_hop = transfer_path[-1]
|
|
336
|
+
first_hop = transfer_path[0]
|
|
337
|
+
|
|
338
|
+
# Overwriting by default is set to True for non TAPE RSEs.
|
|
339
|
+
# Tape RSEs can force overwrite by setting the "overwrite" attribute to True.
|
|
340
|
+
# There is yet another configuration option: transfers->overwrite_corrupted_files that when is set to True
|
|
341
|
+
# it will retry failed requests with overwrite flag set to True
|
|
342
|
+
overwrite, overwrite_when_only_on_disk, bring_online_local = True, False, None
|
|
343
|
+
|
|
344
|
+
if first_hop.src.rse.is_tape_or_staging_required():
|
|
345
|
+
# Activate bring_online if it was requested by first hop
|
|
346
|
+
# We don't allow multihop via a tape, so bring_online should not be set on any other hop
|
|
347
|
+
bring_online_local = bring_online
|
|
348
|
+
|
|
349
|
+
if last_hop.dst.rse.is_tape():
|
|
350
|
+
# FTS v3.12.12 introduced a new boolean parameter "overwrite_when_only_on_disk" that controls if the file can be overwritten
|
|
351
|
+
# in TAPE enabled RSEs ONLY IF the file is on the disk buffer and not yet committed to tape media.
|
|
352
|
+
# This functionality should reduce the number of stuck files in the disk buffer that are not migrated to tape media (for whatever reason).
|
|
353
|
+
# Please be aware that FTS does not guarantee an atomic operation from the time it checks for existence of the file on disk and tape and
|
|
354
|
+
# the moment the file is overwritten, so there is a race condition that could overwrite the file on the tape media
|
|
355
|
+
|
|
356
|
+
# Setting both flags is incompatible, so we opt in for the safest approach: "overwrite_when_only_on_disk"
|
|
357
|
+
# this is aligned with FTS implementation: see (internal access only): https://its.cern.ch/jira/browse/FTS-2007
|
|
358
|
+
|
|
359
|
+
overwrite_when_only_on_disk = last_hop.dst.rse.attributes.get('overwrite_when_only_on_disk', False)
|
|
360
|
+
overwrite = False if overwrite_when_only_on_disk else last_hop.dst.rse.attributes.get('overwrite', False)
|
|
361
|
+
|
|
362
|
+
# We still need to check for the
|
|
363
|
+
# "transfers -> overwrite_corrupted_files setting. The logic behind this flag is that
|
|
364
|
+
# it will update the rws (RequestWithSources) with the "overwrite" attribute set to True
|
|
365
|
+
# after finding an 'Destination file exists and overwrite is not enabled' error message
|
|
366
|
+
overwrite_corrupted_files = last_hop.rws.attributes.get('overwrite', False)
|
|
367
|
+
if overwrite_corrupted_files:
|
|
368
|
+
overwrite = True # both for DISK and TAPE
|
|
369
|
+
|
|
370
|
+
logger(logging.DEBUG, 'RSE:%s Is it Tape? %s overwrite_when_only_on_disk:%s overwrite:%s overwrite_corrupted_files=%s' % (
|
|
371
|
+
last_hop.dst.rse.name,
|
|
372
|
+
last_hop.dst.rse.is_tape(),
|
|
373
|
+
overwrite_when_only_on_disk,
|
|
374
|
+
overwrite,
|
|
375
|
+
overwrite_corrupted_files))
|
|
376
|
+
|
|
377
|
+
logger(logging.DEBUG, 'RSE attributes are: %s' % (last_hop.dst.rse.attributes))
|
|
378
|
+
|
|
379
|
+
# Get dest space token
|
|
380
|
+
dest_protocol = last_hop.protocol_factory.protocol(last_hop.dst.rse, last_hop.dst.scheme, last_hop.operation_dest)
|
|
381
|
+
dest_spacetoken = None
|
|
382
|
+
if dest_protocol.attributes and 'extended_attributes' in dest_protocol.attributes and \
|
|
383
|
+
dest_protocol.attributes['extended_attributes'] and 'space_token' in dest_protocol.attributes['extended_attributes']:
|
|
384
|
+
dest_spacetoken = dest_protocol.attributes['extended_attributes']['space_token']
|
|
385
|
+
|
|
386
|
+
strict_copy = last_hop.dst.rse.attributes.get(RseAttr.STRICT_COPY, False)
|
|
387
|
+
archive_timeout = last_hop.dst.rse.attributes.get(RseAttr.ARCHIVE_TIMEOUT, None)
|
|
388
|
+
|
|
389
|
+
job_params = {'account': last_hop.rws.account,
|
|
390
|
+
'verify_checksum': _path_checksum_validation_strategy(transfer_path, logger=logger),
|
|
391
|
+
'copy_pin_lifetime': last_hop.rws.attributes.get('lifetime', default_lifetime),
|
|
392
|
+
'bring_online': bring_online_local,
|
|
393
|
+
'job_metadata': {
|
|
394
|
+
'issuer': 'rucio',
|
|
395
|
+
'multi_sources': False,
|
|
396
|
+
'overwrite_when_only_on_disk': overwrite_when_only_on_disk,
|
|
397
|
+
},
|
|
398
|
+
'overwrite': overwrite,
|
|
399
|
+
'overwrite_when_only_on_disk': overwrite_when_only_on_disk,
|
|
400
|
+
'priority': last_hop.rws.priority}
|
|
401
|
+
|
|
402
|
+
if len(transfer_path) > 1:
|
|
403
|
+
job_params['multihop'] = True
|
|
404
|
+
job_params['job_metadata']['multihop'] = True
|
|
405
|
+
elif len(last_hop.sources) > 1:
|
|
406
|
+
job_params['job_metadata']['multi_sources'] = True
|
|
407
|
+
if strict_copy:
|
|
408
|
+
job_params['strict_copy'] = strict_copy
|
|
409
|
+
if dest_spacetoken:
|
|
410
|
+
job_params['spacetoken'] = dest_spacetoken
|
|
411
|
+
if (last_hop.dst.rse.attributes.get(RseAttr.USE_IPV4, False)
|
|
412
|
+
or any(src.rse.attributes.get(RseAttr.USE_IPV4, False) for src in last_hop.sources)):
|
|
413
|
+
job_params['ipv4'] = True
|
|
414
|
+
job_params['ipv6'] = False
|
|
415
|
+
|
|
416
|
+
# assume s3alternate True (path-style URL S3 RSEs)
|
|
417
|
+
job_params['s3alternate'] = True
|
|
418
|
+
src_rse_s3_url_style = first_hop.src.rse.attributes.get(RseAttr.S3_URL_STYLE, None)
|
|
419
|
+
if src_rse_s3_url_style == "host":
|
|
420
|
+
job_params['s3alternate'] = False
|
|
421
|
+
dst_rse_s3_url_style = last_hop.dst.rse.attributes.get(RseAttr.S3_URL_STYLE, None)
|
|
422
|
+
if dst_rse_s3_url_style == "host":
|
|
423
|
+
job_params['s3alternate'] = False
|
|
424
|
+
|
|
425
|
+
if archive_timeout and last_hop.dst.rse.is_tape():
|
|
426
|
+
try:
|
|
427
|
+
archive_timeout = int(archive_timeout)
|
|
428
|
+
if archive_timeout_override is None:
|
|
429
|
+
job_params['archive_timeout'] = archive_timeout
|
|
430
|
+
elif archive_timeout_override != 0:
|
|
431
|
+
job_params['archive_timeout'] = archive_timeout_override
|
|
432
|
+
# FTS only supports dst_file metadata if archive_timeout is set
|
|
433
|
+
job_params['dst_file_report'] = True
|
|
434
|
+
logger(logging.DEBUG, 'Added archive timeout to transfer.')
|
|
435
|
+
except ValueError:
|
|
436
|
+
logger(logging.WARNING, 'Could not set archive_timeout for %s. Must be integer.', last_hop)
|
|
437
|
+
pass
|
|
438
|
+
if max_time_in_queue:
|
|
439
|
+
if last_hop.rws.activity in max_time_in_queue:
|
|
440
|
+
job_params['max_time_in_queue'] = max_time_in_queue[last_hop.rws.activity]
|
|
441
|
+
elif 'default' in max_time_in_queue:
|
|
442
|
+
job_params['max_time_in_queue'] = max_time_in_queue['default']
|
|
443
|
+
|
|
444
|
+
# Refer to https://its.cern.ch/jira/browse/FTS-1749 for full details (login needed), extract below:
|
|
445
|
+
# Why the overwrite_hop parameter is needed?
|
|
446
|
+
# Rucio decides that a multihop transfer is needed DISK1 --> DISK2 --> TAPE1 in order to put the file on tape. For some reason, the file already exists on DISK2.
|
|
447
|
+
# Rucio doesn't know about this file on DISK2. It could be either a correct or corrupted file. This can be due to a previous issue on Rucio side, FTS side, network side, etc (many possible reasons).
|
|
448
|
+
# Normally, Rucio allows overwrite towards any disk destination, but denies overwrite towards a tape destination. However, in this case, because the destination of the multihop is a tape, DISK2 cannot be overwritten.
|
|
449
|
+
# Proposed solution
|
|
450
|
+
# Provide an --overwrite-hop submission option, which instructs FTS to overwrite all transfers except for the destination within a multihop submission.
|
|
451
|
+
|
|
452
|
+
# direct transfers, is not multihop
|
|
453
|
+
if len(transfer_path) == 1:
|
|
454
|
+
overwrite_hop = False
|
|
455
|
+
|
|
456
|
+
else:
|
|
457
|
+
# Set `overwrite_hop` to `True` only if all hops allow it
|
|
458
|
+
overwrite_hop = all(transfer_hop.rws.attributes.get('overwrite', True) for transfer_hop in transfer_path[:-1])
|
|
459
|
+
job_params['overwrite'] = overwrite_hop and job_params['overwrite']
|
|
460
|
+
|
|
461
|
+
if not job_params['overwrite'] and overwrite_hop:
|
|
462
|
+
job_params['overwrite_hop'] = overwrite_hop
|
|
463
|
+
|
|
464
|
+
logger(logging.DEBUG, 'Job parameters are : %s' % (job_params))
|
|
465
|
+
return job_params
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def bulk_group_transfers(
|
|
469
|
+
transfer_paths: "Iterable[list[DirectTransfer]]",
|
|
470
|
+
policy: str = 'rule',
|
|
471
|
+
group_bulk: int = 200,
|
|
472
|
+
source_strategy: Optional[str] = None,
|
|
473
|
+
max_time_in_queue: Optional[dict] = None,
|
|
474
|
+
logger: "LoggerFunction" = logging.log,
|
|
475
|
+
archive_timeout_override: Optional[int] = None,
|
|
476
|
+
bring_online: Optional[int] = None,
|
|
477
|
+
default_lifetime: Optional[int] = None) -> list[dict[str, Any]]:
|
|
478
|
+
"""
|
|
479
|
+
Group transfers in bulk based on certain criteria
|
|
480
|
+
|
|
481
|
+
:param transfer_paths: List of transfer paths to group. Each path is a list of single-hop transfers.
|
|
482
|
+
:param policy: Policy to use to group.
|
|
483
|
+
:param group_bulk: Bulk sizes.
|
|
484
|
+
:param source_strategy: Strategy to group sources
|
|
485
|
+
:param max_time_in_queue: Maximum time in queue
|
|
486
|
+
:param archive_timeout_override: Override the archive_timeout parameter for any transfers with it set (0 to unset)
|
|
487
|
+
:param logger: Optional decorated logger that can be passed from the calling daemons or servers.
|
|
488
|
+
:return: List of grouped transfers.
|
|
489
|
+
"""
|
|
490
|
+
|
|
491
|
+
grouped_transfers = {}
|
|
492
|
+
fts_jobs = []
|
|
493
|
+
|
|
494
|
+
for transfer_path in transfer_paths:
|
|
495
|
+
job_params = build_job_params(
|
|
496
|
+
transfer_path=transfer_path,
|
|
497
|
+
bring_online=bring_online,
|
|
498
|
+
default_lifetime=default_lifetime,
|
|
499
|
+
archive_timeout_override=archive_timeout_override,
|
|
500
|
+
max_time_in_queue=max_time_in_queue,
|
|
501
|
+
logger=logger
|
|
502
|
+
)
|
|
503
|
+
logger(logging.DEBUG, 'bulk_group_transfers: Job parameters are: %s' % (job_params))
|
|
504
|
+
if job_params['job_metadata'].get('multi_sources') or job_params['job_metadata'].get('multihop'):
|
|
505
|
+
# for multi-hop and multi-source transfers, no bulk submission.
|
|
506
|
+
fts_jobs.append({'transfers': transfer_path[0:group_bulk], 'job_params': job_params})
|
|
507
|
+
else:
|
|
508
|
+
# it's a single-hop, single-source, transfer. Hence, a candidate for bulk submission.
|
|
509
|
+
transfer = transfer_path[0]
|
|
510
|
+
|
|
511
|
+
# we cannot group transfers together if their job_key differ
|
|
512
|
+
job_key = '%s,%s,%s,%s,%s,%s,%s,%s' % (
|
|
513
|
+
job_params['verify_checksum'],
|
|
514
|
+
job_params.get('spacetoken', ''),
|
|
515
|
+
job_params['copy_pin_lifetime'],
|
|
516
|
+
job_params['bring_online'],
|
|
517
|
+
job_params['job_metadata'],
|
|
518
|
+
job_params['overwrite'],
|
|
519
|
+
job_params['priority'],
|
|
520
|
+
job_params.get('max_time_in_queue', '')
|
|
521
|
+
)
|
|
522
|
+
|
|
523
|
+
# Additionally, we don't want to group transfers together if their policy_key differ
|
|
524
|
+
policy_key = ''
|
|
525
|
+
if policy == 'rule':
|
|
526
|
+
policy_key = '%s' % transfer.rws.rule_id
|
|
527
|
+
if policy == 'dest':
|
|
528
|
+
policy_key = '%s' % transfer.dst.rse.name
|
|
529
|
+
if policy == 'src_dest':
|
|
530
|
+
policy_key = '%s,%s' % (transfer.src.rse.name, transfer.dst.rse.name)
|
|
531
|
+
if policy == 'rule_src_dest':
|
|
532
|
+
policy_key = '%s,%s,%s' % (transfer.rws.rule_id, transfer.src.rse.name, transfer.dst.rse.name)
|
|
533
|
+
if policy == 'activity_dest':
|
|
534
|
+
policy_key = '%s %s' % (transfer.rws.activity, transfer.dst.rse.name)
|
|
535
|
+
policy_key = "_".join(policy_key.split(' '))
|
|
536
|
+
if policy == 'activity_src_dest':
|
|
537
|
+
policy_key = '%s %s %s' % (transfer.rws.activity, transfer.src.rse.name, transfer.dst.rse.name)
|
|
538
|
+
policy_key = "_".join(policy_key.split(' '))
|
|
539
|
+
# maybe here we need to hash the key if it's too long
|
|
540
|
+
|
|
541
|
+
group_key = "%s_%s" % (job_key, policy_key)
|
|
542
|
+
if group_key not in grouped_transfers:
|
|
543
|
+
grouped_transfers[group_key] = {'transfers': [], 'job_params': job_params}
|
|
544
|
+
grouped_transfers[group_key]['transfers'].append(transfer)
|
|
545
|
+
|
|
546
|
+
# split transfer groups to have at most group_bulk elements in each one
|
|
547
|
+
for group in grouped_transfers.values():
|
|
548
|
+
job_params = group['job_params']
|
|
549
|
+
logger(logging.DEBUG, 'bulk_group_transfers: grouped_transfers.values(): Job parameters are: %s' % (job_params))
|
|
550
|
+
for transfer_paths in chunks(group['transfers'], group_bulk):
|
|
551
|
+
fts_jobs.append({'transfers': transfer_paths, 'job_params': job_params})
|
|
552
|
+
|
|
553
|
+
return fts_jobs
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
class Fts3TransferStatusReport(TransferStatusReport):
|
|
557
|
+
|
|
558
|
+
supported_db_fields = [
|
|
559
|
+
'state',
|
|
560
|
+
'external_id',
|
|
561
|
+
'started_at',
|
|
562
|
+
'transferred_at',
|
|
563
|
+
'staging_started_at',
|
|
564
|
+
'staging_finished_at',
|
|
565
|
+
'source_rse_id',
|
|
566
|
+
'err_msg',
|
|
567
|
+
'attributes',
|
|
568
|
+
]
|
|
569
|
+
|
|
570
|
+
def __init__(self, external_host: str, request_id: str, request: Optional[dict] = None):
|
|
571
|
+
super().__init__(request_id, request=request)
|
|
572
|
+
self.external_host = external_host
|
|
573
|
+
|
|
574
|
+
# Initialized in child class constructors:
|
|
575
|
+
self._transfer_id = None
|
|
576
|
+
self._file_metadata = {}
|
|
577
|
+
self._multi_sources = None
|
|
578
|
+
self._src_url = None
|
|
579
|
+
self._dst_url = None
|
|
580
|
+
# Initialized in child class initialize():
|
|
581
|
+
self._reason = None
|
|
582
|
+
self._src_rse = None
|
|
583
|
+
self._fts_address = self.external_host
|
|
584
|
+
# Supported db fields below:
|
|
585
|
+
self.state = None
|
|
586
|
+
self.external_id = None
|
|
587
|
+
self.started_at = None
|
|
588
|
+
self.transferred_at = None
|
|
589
|
+
self.staging_started_at = None
|
|
590
|
+
self.staging_finished_at = None
|
|
591
|
+
self.source_rse_id = None
|
|
592
|
+
self.err_msg = None
|
|
593
|
+
self.attributes = None
|
|
594
|
+
|
|
595
|
+
def __str__(self):
|
|
596
|
+
return f'Transfer {self._transfer_id} of {self._file_metadata["scope"]}:{self._file_metadata["name"]} ' \
|
|
597
|
+
f'{self._file_metadata["src_rse"]} --({self._file_metadata["request_id"]})-> {self._file_metadata["dst_rse"]}'
|
|
598
|
+
|
|
599
|
+
def initialize(self, session: "Session", logger: "LoggerFunction" = logging.log) -> None:
|
|
600
|
+
raise NotImplementedError(f"{self.__class__.__name__} is abstract and shouldn't be used directly")
|
|
601
|
+
|
|
602
|
+
def get_monitor_msg_fields(self, session: "Session", logger: "LoggerFunction" = logging.log) -> dict[str, Any]:
|
|
603
|
+
self.ensure_initialized(session, logger)
|
|
604
|
+
fields = {
|
|
605
|
+
'transfer_link': self._transfer_link(),
|
|
606
|
+
'reason': self._reason,
|
|
607
|
+
'src-type': self._file_metadata.get('src_type'),
|
|
608
|
+
'src-rse': self._src_rse,
|
|
609
|
+
'src-url': self._src_url,
|
|
610
|
+
'dst-type': self._file_metadata.get('src_type'),
|
|
611
|
+
'dst-rse': self._file_metadata.get('dst_rse'),
|
|
612
|
+
'dst-url': self._dst_url,
|
|
613
|
+
'started_at': self.started_at,
|
|
614
|
+
'transferred_at': self.transferred_at,
|
|
615
|
+
}
|
|
616
|
+
return fields
|
|
617
|
+
|
|
618
|
+
def _transfer_link(self) -> str:
|
|
619
|
+
return '%s/fts3/ftsmon/#/job/%s' % (self._fts_address.replace('8446', '8449'), self._transfer_id)
|
|
620
|
+
|
|
621
|
+
def _find_attribute_updates(self, request: dict, new_state: RequestState, reason: Optional[str], overwrite_corrupted_files: Optional[bool] = None) -> Optional[dict[str, Any]]:
|
|
622
|
+
attributes = None
|
|
623
|
+
if new_state == RequestState.FAILED and (reason and any(s in reason for s in (FTS_FILE_EXISTS_ERROR_MSG, FTS_FILE_EXISTS_ERROR_MSG_LEGACY))):
|
|
624
|
+
dst_file = self._file_metadata.get('dst_file', {})
|
|
625
|
+
if self._dst_file_set_and_file_corrupted(request, dst_file):
|
|
626
|
+
if overwrite_corrupted_files:
|
|
627
|
+
attributes = request['attributes']
|
|
628
|
+
attributes['overwrite'] = True
|
|
629
|
+
return attributes
|
|
630
|
+
|
|
631
|
+
def _find_used_source_rse(self, session: "Session", logger: "LoggerFunction") -> tuple[Optional[str], Optional[str]]:
|
|
632
|
+
"""
|
|
633
|
+
For multi-source transfers, FTS has a choice between multiple sources.
|
|
634
|
+
Find which of the possible sources FTS actually used for the transfer.
|
|
635
|
+
"""
|
|
636
|
+
meta_rse_name = self._file_metadata.get('src_rse', None)
|
|
637
|
+
meta_rse_id = self._file_metadata.get('src_rse_id', None)
|
|
638
|
+
request_id = self._file_metadata.get('request_id', None)
|
|
639
|
+
|
|
640
|
+
if self._multi_sources and self._src_url:
|
|
641
|
+
rse_name, rse_id = get_source_rse(request_id, self._src_url, session=session)
|
|
642
|
+
if rse_name and rse_name != meta_rse_name:
|
|
643
|
+
logger(logging.DEBUG, 'Correct RSE: %s for source surl: %s' % (rse_name, self._src_url))
|
|
644
|
+
return rse_name, rse_id
|
|
645
|
+
|
|
646
|
+
return meta_rse_name, meta_rse_id
|
|
647
|
+
|
|
648
|
+
@staticmethod
|
|
649
|
+
def _dst_file_set_and_file_corrupted(request: dict, dst_file: dict) -> bool:
|
|
650
|
+
"""
|
|
651
|
+
Returns True if the `dst_file` dict returned by fts was filled and its content allows to
|
|
652
|
+
affirm that the file is corrupted.
|
|
653
|
+
"""
|
|
654
|
+
if (request and dst_file and (
|
|
655
|
+
dst_file.get('file_size') is not None and dst_file['file_size'] != request.get('bytes')
|
|
656
|
+
or dst_file.get('checksum_type', '').lower() == 'adler32' and dst_file.get('checksum_value') != request.get('adler32')
|
|
657
|
+
or dst_file.get('checksum_type', '').lower() == 'md5' and dst_file.get('checksum_value') != request.get('md5'))):
|
|
658
|
+
return True
|
|
659
|
+
return False
|
|
660
|
+
|
|
661
|
+
@staticmethod
|
|
662
|
+
def _dst_file_set_and_file_correct(request: dict, dst_file: dict) -> bool:
|
|
663
|
+
"""
|
|
664
|
+
Returns True if the `dst_file` dict returned by fts was filled and its content allows to
|
|
665
|
+
affirm that the file is correct.
|
|
666
|
+
"""
|
|
667
|
+
if (request and dst_file
|
|
668
|
+
and dst_file.get('file_size')
|
|
669
|
+
and dst_file.get('file_size') == request.get('bytes')
|
|
670
|
+
and (dst_file.get('checksum_type', '').lower() == 'adler32' and dst_file.get('checksum_value') == request.get('adler32')
|
|
671
|
+
or dst_file.get('checksum_type', '').lower() == 'md5' and dst_file.get('checksum_value') == request.get('md5'))):
|
|
672
|
+
return True
|
|
673
|
+
return False
|
|
674
|
+
|
|
675
|
+
@classmethod
|
|
676
|
+
def _is_recoverable_fts_overwrite_error(cls, request: dict[str, Any], reason: Optional[str],
|
|
677
|
+
file_metadata: dict[str, Any]) -> bool:
|
|
678
|
+
"""
|
|
679
|
+
Verify the special case when FTS cannot copy a file because destination exists and overwrite is disabled,
|
|
680
|
+
but the destination file is actually correct.
|
|
681
|
+
|
|
682
|
+
This can happen when some transitory error happened during a previous submission attempt.
|
|
683
|
+
Hence, the transfer is correctly executed by FTS, but rucio doesn't know about it.
|
|
684
|
+
|
|
685
|
+
Returns true when the request must be marked as successful even if it was reported failed by FTS.
|
|
686
|
+
"""
|
|
687
|
+
if not request or not file_metadata:
|
|
688
|
+
return False
|
|
689
|
+
dst_file = file_metadata.get('dst_file', {})
|
|
690
|
+
dst_type = file_metadata.get('dst_type', None)
|
|
691
|
+
METRICS.counter('overwrite.check.{rsetype}.{rse}').labels(rse=file_metadata["dst_rse"], rsetype=dst_type).inc()
|
|
692
|
+
|
|
693
|
+
if reason and any(s in reason for s in (FTS_FILE_EXISTS_ERROR_MSG, FTS_FILE_EXISTS_ERROR_MSG_LEGACY)):
|
|
694
|
+
if cls._dst_file_set_and_file_correct(request, dst_file):
|
|
695
|
+
if dst_type == 'DISK' or dst_file.get('file_on_tape'):
|
|
696
|
+
METRICS.counter('overwrite.ok.{rsetype}.{rse}').labels(rse=file_metadata["dst_rse"], rsetype=dst_type).inc()
|
|
697
|
+
return True
|
|
698
|
+
|
|
699
|
+
METRICS.counter('overwrite.fail.{rsetype}.{rse}').labels(rse=file_metadata["dst_rse"], rsetype=dst_type).inc()
|
|
700
|
+
return False
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
class FTS3CompletionMessageTransferStatusReport(Fts3TransferStatusReport):
|
|
704
|
+
"""
|
|
705
|
+
Parses FTS Completion messages received via the message queue
|
|
706
|
+
"""
|
|
707
|
+
def __init__(self, external_host: str, request_id: str, fts_message: dict[str, Any]):
|
|
708
|
+
super().__init__(external_host=external_host, request_id=request_id)
|
|
709
|
+
|
|
710
|
+
self.fts_message = fts_message
|
|
711
|
+
|
|
712
|
+
transfer_id = fts_message.get('tr_id')
|
|
713
|
+
if transfer_id is not None:
|
|
714
|
+
self._transfer_id = transfer_id.split("__")[-1]
|
|
715
|
+
|
|
716
|
+
self._file_metadata = fts_message['file_metadata']
|
|
717
|
+
self._multi_sources = str(fts_message.get('job_metadata', {}).get('multi_sources', '')).lower() == 'true'
|
|
718
|
+
self._src_url = fts_message.get('src_url', None)
|
|
719
|
+
self._dst_url = fts_message.get('dst_url', None)
|
|
720
|
+
|
|
721
|
+
def initialize(self, session: "Session", logger: "LoggerFunction" = logging.log) -> None:
|
|
722
|
+
|
|
723
|
+
fts_message = self.fts_message
|
|
724
|
+
request_id = self.request_id
|
|
725
|
+
|
|
726
|
+
reason = fts_message.get('t__error_message', None)
|
|
727
|
+
# job_state = fts_message.get('t_final_transfer_state', None)
|
|
728
|
+
new_state = None
|
|
729
|
+
if str(fts_message['t_final_transfer_state']) == FTS_COMPLETE_STATE.OK and not fts_message.get('is_archiving'): # pylint:disable=no-member
|
|
730
|
+
new_state = RequestState.DONE
|
|
731
|
+
elif str(fts_message['t_final_transfer_state']) == FTS_COMPLETE_STATE.ERROR:
|
|
732
|
+
request = self.request(session)
|
|
733
|
+
if request is not None:
|
|
734
|
+
if self._is_recoverable_fts_overwrite_error(request, reason, self._file_metadata): # pylint:disable=no-member
|
|
735
|
+
new_state = RequestState.DONE
|
|
736
|
+
else:
|
|
737
|
+
new_state = RequestState.FAILED
|
|
738
|
+
|
|
739
|
+
transfer_id = self._transfer_id
|
|
740
|
+
if new_state:
|
|
741
|
+
request = self.request(session)
|
|
742
|
+
if not request:
|
|
743
|
+
logger(logging.WARNING, '%s: no request with this id in the database. Skipping. external_id: %s (%s). new_state: %s', request_id, transfer_id, self.external_host, new_state)
|
|
744
|
+
return
|
|
745
|
+
if request and request['external_id'] == transfer_id and request['state'] != new_state:
|
|
746
|
+
src_rse_name, src_rse_id = self._find_used_source_rse(session, logger)
|
|
747
|
+
|
|
748
|
+
self._reason = reason
|
|
749
|
+
self._src_rse = src_rse_name
|
|
750
|
+
self._fts_address = request['external_host'] or self._fts_address
|
|
751
|
+
|
|
752
|
+
self.state = new_state
|
|
753
|
+
self.external_id = transfer_id
|
|
754
|
+
self.started_at = datetime.datetime.utcfromtimestamp(float(fts_message.get('tr_timestamp_start', 0)) / 1000)
|
|
755
|
+
self.transferred_at = datetime.datetime.utcfromtimestamp(float(fts_message.get('tr_timestamp_complete', 0)) / 1000)
|
|
756
|
+
self.staging_started_at = None
|
|
757
|
+
self.staging_finished_at = None
|
|
758
|
+
self.source_rse_id = src_rse_id
|
|
759
|
+
self.err_msg = get_transfer_error(self.state, reason)
|
|
760
|
+
if self.err_msg and self._file_metadata.get('src_type') == "TAPE":
|
|
761
|
+
self.err_msg = '[TAPE SOURCE] ' + self.err_msg
|
|
762
|
+
self.attributes = self._find_attribute_updates(
|
|
763
|
+
request=request,
|
|
764
|
+
new_state=new_state,
|
|
765
|
+
reason=reason,
|
|
766
|
+
overwrite_corrupted_files=config_get_bool('transfers', 'overwrite_corrupted_files', default=False, session=session),
|
|
767
|
+
)
|
|
768
|
+
elif request['external_id'] != transfer_id:
|
|
769
|
+
logger(logging.WARNING, "Response %s with transfer id %s is different from the request transfer id %s, will not update" % (request_id, transfer_id, request['external_id']))
|
|
770
|
+
else:
|
|
771
|
+
logger(logging.DEBUG, "Request %s is already in %s state, will not update" % (request_id, new_state))
|
|
772
|
+
else:
|
|
773
|
+
logger(logging.DEBUG, "No state change computed for %s. Skipping request update." % request_id)
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
class FTS3ApiTransferStatusReport(Fts3TransferStatusReport):
|
|
777
|
+
"""
|
|
778
|
+
Parses FTS api response
|
|
779
|
+
"""
|
|
780
|
+
def __init__(self, external_host: str, request_id: str, job_response: dict[str, Any], file_response: dict[str, Any], request: Optional[dict[str, Any]] = None):
|
|
781
|
+
super().__init__(external_host=external_host, request_id=request_id, request=request)
|
|
782
|
+
|
|
783
|
+
self.job_response = job_response
|
|
784
|
+
self.file_response = file_response
|
|
785
|
+
|
|
786
|
+
self._transfer_id = job_response.get('job_id')
|
|
787
|
+
|
|
788
|
+
self._file_metadata = file_response['file_metadata']
|
|
789
|
+
self._multi_sources = str(job_response['job_metadata'].get('multi_sources', '')).lower() == 'true'
|
|
790
|
+
self._src_url = file_response.get('source_surl', None)
|
|
791
|
+
self._dst_url = file_response.get('dest_surl', None)
|
|
792
|
+
self.logger = logging.log
|
|
793
|
+
|
|
794
|
+
def initialize(self, session: "Session", logger=logging.log) -> None:
|
|
795
|
+
|
|
796
|
+
self.logger = logger
|
|
797
|
+
job_response = self.job_response
|
|
798
|
+
file_response = self.file_response
|
|
799
|
+
request_id = self.request_id
|
|
800
|
+
|
|
801
|
+
file_state = file_response['file_state']
|
|
802
|
+
reason = file_response.get('reason', None)
|
|
803
|
+
|
|
804
|
+
new_state = None
|
|
805
|
+
job_state = job_response.get('job_state', None)
|
|
806
|
+
multi_hop = job_response.get('job_type') == FTS_JOB_TYPE.MULTI_HOP
|
|
807
|
+
job_state_is_final = job_state in FINAL_FTS_JOB_STATES
|
|
808
|
+
file_state_is_final = file_state in FINAL_FTS_FILE_STATES
|
|
809
|
+
if file_state_is_final:
|
|
810
|
+
if file_state == FTS_STATE.FINISHED:
|
|
811
|
+
new_state = RequestState.DONE
|
|
812
|
+
elif file_state == FTS_STATE.FAILED and job_state_is_final or \
|
|
813
|
+
file_state == FTS_STATE.FAILED and not self._multi_sources: # for multi-source transfers we must wait for the job to be in a final state
|
|
814
|
+
request = self.request(session)
|
|
815
|
+
if request is not None:
|
|
816
|
+
if self._is_recoverable_fts_overwrite_error(request, reason, self._file_metadata):
|
|
817
|
+
new_state = RequestState.DONE
|
|
818
|
+
else:
|
|
819
|
+
new_state = RequestState.FAILED
|
|
820
|
+
elif job_state_is_final and file_state == FTS_STATE.CANCELED:
|
|
821
|
+
new_state = RequestState.FAILED
|
|
822
|
+
elif job_state_is_final and file_state == FTS_STATE.NOT_USED:
|
|
823
|
+
if job_state == FTS_STATE.FINISHED:
|
|
824
|
+
# it is a multi-source transfer. This source wasn't used, but another one was successful
|
|
825
|
+
new_state = RequestState.DONE
|
|
826
|
+
else:
|
|
827
|
+
# failed multi-source or multi-hop (you cannot have unused sources in a successful multi-hop)
|
|
828
|
+
new_state = RequestState.FAILED
|
|
829
|
+
if not reason and multi_hop:
|
|
830
|
+
reason = 'Unused hop in multi-hop'
|
|
831
|
+
|
|
832
|
+
transfer_id = self._transfer_id
|
|
833
|
+
if new_state:
|
|
834
|
+
request = self.request(session)
|
|
835
|
+
if not request:
|
|
836
|
+
logger(logging.WARNING, '%s: no request with this id in the database. Skipping. external_id: %s (%s). new_state: %s', request_id, transfer_id, self.external_host, new_state)
|
|
837
|
+
return
|
|
838
|
+
if request['external_id'] == transfer_id and request['state'] != new_state:
|
|
839
|
+
src_rse_name, src_rse_id = self._find_used_source_rse(session, logger)
|
|
840
|
+
|
|
841
|
+
self._reason = reason
|
|
842
|
+
self._src_rse = src_rse_name
|
|
843
|
+
|
|
844
|
+
self.state = new_state
|
|
845
|
+
self.external_id = transfer_id
|
|
846
|
+
self.started_at = datetime.datetime.strptime(file_response['start_time'], '%Y-%m-%dT%H:%M:%S') if file_response['start_time'] else None
|
|
847
|
+
self.transferred_at = datetime.datetime.strptime(file_response['finish_time'], '%Y-%m-%dT%H:%M:%S') if file_response['finish_time'] else None
|
|
848
|
+
self.staging_started_at = datetime.datetime.strptime(file_response['staging_start'], '%Y-%m-%dT%H:%M:%S') if file_response['staging_start'] else None
|
|
849
|
+
self.staging_finished_at = datetime.datetime.strptime(file_response['staging_finished'], '%Y-%m-%dT%H:%M:%S') if file_response['staging_finished'] else None
|
|
850
|
+
self.source_rse_id = src_rse_id
|
|
851
|
+
self.err_msg = get_transfer_error(self.state, reason)
|
|
852
|
+
if self.err_msg and self._file_metadata.get('src_type') == "TAPE":
|
|
853
|
+
self.err_msg = '[TAPE SOURCE] ' + self.err_msg
|
|
854
|
+
self.attributes = self._find_attribute_updates(
|
|
855
|
+
request=request,
|
|
856
|
+
new_state=new_state,
|
|
857
|
+
reason=reason,
|
|
858
|
+
overwrite_corrupted_files=config_get_bool('transfers', 'overwrite_corrupted_files', default=False, session=session),
|
|
859
|
+
)
|
|
860
|
+
elif request['external_id'] != transfer_id:
|
|
861
|
+
logger(logging.WARNING, "Response %s with transfer id %s is different from the request transfer id %s, will not update" % (request_id, transfer_id, request['external_id']))
|
|
862
|
+
else:
|
|
863
|
+
logger(logging.DEBUG, "Request %s is already in %s state, will not update" % (request_id, new_state))
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
class FTS3Transfertool(Transfertool):
|
|
867
|
+
"""
|
|
868
|
+
FTS3 implementation of a Rucio transfertool
|
|
869
|
+
"""
|
|
870
|
+
|
|
871
|
+
external_name = 'fts3'
|
|
872
|
+
required_rse_attrs = (RseAttr.FTS, )
|
|
873
|
+
supported_schemes = Transfertool.supported_schemes.union(('mock', ))
|
|
874
|
+
|
|
875
|
+
def __init__(self,
|
|
876
|
+
external_host: str,
|
|
877
|
+
oidc_support: bool = False,
|
|
878
|
+
vo: Optional[str] = None,
|
|
879
|
+
group_bulk: int = 1,
|
|
880
|
+
group_policy: str = 'rule',
|
|
881
|
+
source_strategy: Optional[str] = None,
|
|
882
|
+
max_time_in_queue: Optional[dict[str, Any]] = None,
|
|
883
|
+
bring_online: Optional[int] = 43200,
|
|
884
|
+
default_lifetime: Optional[int] = 172800,
|
|
885
|
+
archive_timeout_override: Optional[int] = None,
|
|
886
|
+
logger: "LoggerFunction" = logging.log
|
|
887
|
+
):
|
|
888
|
+
"""
|
|
889
|
+
Initializes the transfertool
|
|
890
|
+
|
|
891
|
+
:param external_host: The external host where the transfertool API is running
|
|
892
|
+
"""
|
|
893
|
+
super().__init__(external_host, logger)
|
|
894
|
+
|
|
895
|
+
self.group_policy = group_policy
|
|
896
|
+
self.group_bulk = group_bulk
|
|
897
|
+
self.source_strategy = source_strategy
|
|
898
|
+
self.max_time_in_queue = max_time_in_queue or {}
|
|
899
|
+
self.bring_online = bring_online
|
|
900
|
+
self.default_lifetime = default_lifetime
|
|
901
|
+
self.archive_timeout_override = archive_timeout_override
|
|
902
|
+
|
|
903
|
+
try:
|
|
904
|
+
tape_plugins = config_get_list("transfers", "fts3tape_metadata_plugins", raise_exception=True)
|
|
905
|
+
self.tape_metadata_plugins = [FTS3TapeMetadataPlugin(plugin.strip(" ")) for plugin in tape_plugins]
|
|
906
|
+
except (NoOptionError, NoSectionError, ValueError) as e:
|
|
907
|
+
self.logger(logging.DEBUG, f"Failed to set up any fts3 archive-metadata plugins: {e}")
|
|
908
|
+
self.tape_metadata_plugins = []
|
|
909
|
+
|
|
910
|
+
self.token = None
|
|
911
|
+
if oidc_support:
|
|
912
|
+
fts_hostname = urlparse(external_host).hostname
|
|
913
|
+
if fts_hostname is not None:
|
|
914
|
+
token = request_token(audience=fts_hostname, scope='fts')
|
|
915
|
+
if token is not None:
|
|
916
|
+
self.logger(logging.INFO, 'Using a token to authenticate with FTS instance %s', fts_hostname)
|
|
917
|
+
self.token = token
|
|
918
|
+
else:
|
|
919
|
+
self.logger(logging.WARNING, 'Failed to procure a token to authenticate with FTS instance %s', fts_hostname)
|
|
920
|
+
|
|
921
|
+
self.deterministic_id = config_get_bool('conveyor', 'use_deterministic_id', False, False)
|
|
922
|
+
self.headers = {'Content-Type': 'application/json'}
|
|
923
|
+
if self.external_host.startswith('https://'):
|
|
924
|
+
if self.token:
|
|
925
|
+
self.cert = None
|
|
926
|
+
self.verify = False
|
|
927
|
+
self.headers['Authorization'] = 'Bearer ' + self.token
|
|
928
|
+
else:
|
|
929
|
+
cert = _pick_cert_file(vo=vo)
|
|
930
|
+
self.cert = (cert, cert)
|
|
931
|
+
self.verify = False
|
|
932
|
+
else:
|
|
933
|
+
self.cert = None
|
|
934
|
+
self.verify = True # True is the default setting of a requests.* method
|
|
935
|
+
|
|
936
|
+
self.scitags_exp_id, self.scitags_activity_ids = _scitags_ids(logger=logger)
|
|
937
|
+
|
|
938
|
+
@classmethod
|
|
939
|
+
def _pick_fts_servers(cls, source_rse: "RseData", dest_rse: "RseData") -> Optional[list[str]]:
|
|
940
|
+
"""
|
|
941
|
+
Pick fts servers to use for submission between the two given rse
|
|
942
|
+
"""
|
|
943
|
+
source_servers = source_rse.attributes.get(RseAttr.FTS, None)
|
|
944
|
+
dest_servers = dest_rse.attributes.get(RseAttr.FTS, None)
|
|
945
|
+
if source_servers is None or dest_servers is None:
|
|
946
|
+
return None
|
|
947
|
+
|
|
948
|
+
servers_to_use = dest_servers
|
|
949
|
+
if source_rse.attributes.get(RseAttr.SIGN_URL, None) == 'gcs':
|
|
950
|
+
servers_to_use = source_servers
|
|
951
|
+
|
|
952
|
+
return servers_to_use.split(',')
|
|
953
|
+
|
|
954
|
+
@classmethod
|
|
955
|
+
def can_perform_transfer(cls, source_rse: "RseData", dest_rse: "RseData") -> bool:
|
|
956
|
+
if cls._pick_fts_servers(source_rse, dest_rse):
|
|
957
|
+
return True
|
|
958
|
+
return False
|
|
959
|
+
|
|
960
|
+
@classmethod
|
|
961
|
+
def submission_builder_for_path(cls, transfer_path: "list[DirectTransfer]", logger: "LoggerFunction" = logging.log):
|
|
962
|
+
vo = None
|
|
963
|
+
if config_get_bool('common', 'multi_vo', False, None):
|
|
964
|
+
vo = transfer_path[-1].rws.scope.vo
|
|
965
|
+
|
|
966
|
+
sub_path = []
|
|
967
|
+
fts_hosts = []
|
|
968
|
+
for hop in transfer_path:
|
|
969
|
+
hosts = cls._pick_fts_servers(hop.src.rse, hop.dst.rse)
|
|
970
|
+
if hosts:
|
|
971
|
+
fts_hosts = hosts
|
|
972
|
+
sub_path.append(hop)
|
|
973
|
+
else:
|
|
974
|
+
break
|
|
975
|
+
|
|
976
|
+
if len(sub_path) < len(transfer_path):
|
|
977
|
+
logger(logging.INFO, 'FTS3Transfertool can only submit {} hops from {}'.format(len(sub_path), [str(hop) for hop in transfer_path]))
|
|
978
|
+
|
|
979
|
+
if sub_path:
|
|
980
|
+
oidc_support = False
|
|
981
|
+
if all(_use_tokens(t) for t in sub_path):
|
|
982
|
+
logger(logging.DEBUG, 'OAuth2/OIDC available for transfer {}'.format([str(hop) for hop in sub_path]))
|
|
983
|
+
oidc_support = True
|
|
984
|
+
return sub_path, TransferToolBuilder(cls, external_host=fts_hosts[0], oidc_support=oidc_support, vo=vo)
|
|
985
|
+
else:
|
|
986
|
+
return [], None
|
|
987
|
+
|
|
988
|
+
def group_into_submit_jobs(self, transfer_paths: "list[list[DirectTransfer]]") -> list[dict[str, Any]]:
|
|
989
|
+
jobs = bulk_group_transfers(
|
|
990
|
+
transfer_paths,
|
|
991
|
+
policy=self.group_policy,
|
|
992
|
+
group_bulk=self.group_bulk,
|
|
993
|
+
source_strategy=self.source_strategy,
|
|
994
|
+
max_time_in_queue=self.max_time_in_queue,
|
|
995
|
+
bring_online=self.bring_online,
|
|
996
|
+
default_lifetime=self.default_lifetime,
|
|
997
|
+
archive_timeout_override=self.archive_timeout_override,
|
|
998
|
+
logger=self.logger,
|
|
999
|
+
)
|
|
1000
|
+
return jobs
|
|
1001
|
+
|
|
1002
|
+
def _file_from_transfer(self, transfer: "DirectTransfer", job_params: dict[str, str]) -> dict[str, Any]:
|
|
1003
|
+
rws = transfer.rws
|
|
1004
|
+
checksum_to_use = _pick_fts_checksum(transfer, path_strategy=job_params['verify_checksum'])
|
|
1005
|
+
t_file = {
|
|
1006
|
+
'sources': [transfer.source_url(s) for s in transfer.sources],
|
|
1007
|
+
'destinations': [transfer.dest_url],
|
|
1008
|
+
'metadata': {
|
|
1009
|
+
'request_id': rws.request_id,
|
|
1010
|
+
'scope': rws.scope,
|
|
1011
|
+
'name': rws.name,
|
|
1012
|
+
'activity': rws.activity,
|
|
1013
|
+
'request_type': rws.request_type,
|
|
1014
|
+
'src_type': "TAPE" if transfer.src.rse.is_tape_or_staging_required() else 'DISK',
|
|
1015
|
+
'dst_type': "TAPE" if transfer.dst.rse.is_tape() else 'DISK',
|
|
1016
|
+
'src_rse': transfer.src.rse.name,
|
|
1017
|
+
'dst_rse': transfer.dst.rse.name,
|
|
1018
|
+
'src_rse_id': transfer.src.rse.id,
|
|
1019
|
+
'dest_rse_id': transfer.dst.rse.id,
|
|
1020
|
+
'filesize': rws.byte_count,
|
|
1021
|
+
'md5': rws.md5,
|
|
1022
|
+
'adler32': rws.adler32
|
|
1023
|
+
},
|
|
1024
|
+
'filesize': rws.byte_count,
|
|
1025
|
+
'checksum': checksum_to_use,
|
|
1026
|
+
'selection_strategy': self.source_strategy if self.source_strategy else _configured_source_strategy(transfer.rws.activity, logger=self.logger),
|
|
1027
|
+
'activity': rws.activity
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
if self.token:
|
|
1031
|
+
t_file['source_tokens'] = []
|
|
1032
|
+
for source in transfer.sources:
|
|
1033
|
+
src_audience = determine_audience_for_rse(rse_id=source.rse.id)
|
|
1034
|
+
src_scope = determine_scope_for_rse(rse_id=source.rse.id, scopes=['storage.read'], extra_scopes=['offline_access'])
|
|
1035
|
+
t_file['source_tokens'].append(request_token(src_audience, src_scope))
|
|
1036
|
+
|
|
1037
|
+
dst_audience = determine_audience_for_rse(transfer.dst.rse.id)
|
|
1038
|
+
# FIXME: At the time of writing, StoRM requires `storage.read` in
|
|
1039
|
+
# order to perform a stat operation.
|
|
1040
|
+
dst_scope = determine_scope_for_rse(transfer.dst.rse.id, scopes=['storage.modify', 'storage.read'], extra_scopes=['offline_access'])
|
|
1041
|
+
t_file['destination_tokens'] = [request_token(dst_audience, dst_scope)]
|
|
1042
|
+
|
|
1043
|
+
if isinstance(self.scitags_exp_id, int):
|
|
1044
|
+
activity_id = self.scitags_activity_ids.get(rws.activity)
|
|
1045
|
+
if isinstance(activity_id, int):
|
|
1046
|
+
t_file['scitag'] = self.scitags_exp_id << 6 | activity_id
|
|
1047
|
+
|
|
1048
|
+
if t_file['metadata']['dst_type'] == 'TAPE':
|
|
1049
|
+
for plugin in self.tape_metadata_plugins:
|
|
1050
|
+
t_file = deep_merge_dict(source=plugin.hints(t_file['metadata']), destination=t_file)
|
|
1051
|
+
|
|
1052
|
+
if t_file['metadata']['src_type'] == 'TAPE':
|
|
1053
|
+
t_file['staging_metadata'] = {"default": {"activity": rws.activity}}
|
|
1054
|
+
|
|
1055
|
+
return t_file
|
|
1056
|
+
|
|
1057
|
+
def submit(self, transfers: "Sequence[DirectTransfer]", job_params: dict[str, str], timeout: Optional[int] = None) -> str:
|
|
1058
|
+
"""
|
|
1059
|
+
Submit transfers to FTS3 via JSON.
|
|
1060
|
+
|
|
1061
|
+
:param files: List of dictionaries describing the file transfers.
|
|
1062
|
+
:param job_params: Dictionary containing key/value pairs, for all transfers.
|
|
1063
|
+
:param timeout: Timeout in seconds.
|
|
1064
|
+
:returns: FTS transfer identifier.
|
|
1065
|
+
"""
|
|
1066
|
+
files = []
|
|
1067
|
+
for transfer in transfers:
|
|
1068
|
+
files.append(self._file_from_transfer(transfer, job_params))
|
|
1069
|
+
|
|
1070
|
+
# FTS3 expects 'davs' as the scheme identifier instead of https
|
|
1071
|
+
for transfer_file in files:
|
|
1072
|
+
if not transfer_file['sources'] or transfer_file['sources'] == []:
|
|
1073
|
+
raise Exception('No sources defined')
|
|
1074
|
+
|
|
1075
|
+
# TODO: remove the following logic in rucio 1.31
|
|
1076
|
+
if REWRITE_HTTPS_TO_DAVS:
|
|
1077
|
+
new_src_urls = []
|
|
1078
|
+
new_dst_urls = []
|
|
1079
|
+
for url in transfer_file['sources']:
|
|
1080
|
+
if url.startswith('https'):
|
|
1081
|
+
new_src_urls.append(':'.join(['davs'] + url.split(':')[1:]))
|
|
1082
|
+
else:
|
|
1083
|
+
new_src_urls.append(url)
|
|
1084
|
+
for url in transfer_file['destinations']:
|
|
1085
|
+
if url.startswith('https'):
|
|
1086
|
+
new_dst_urls.append(':'.join(['davs'] + url.split(':')[1:]))
|
|
1087
|
+
else:
|
|
1088
|
+
new_dst_urls.append(url)
|
|
1089
|
+
|
|
1090
|
+
transfer_file['sources'] = new_src_urls
|
|
1091
|
+
transfer_file['destinations'] = new_dst_urls
|
|
1092
|
+
|
|
1093
|
+
transfer_id = None
|
|
1094
|
+
expected_transfer_id = None
|
|
1095
|
+
if self.deterministic_id:
|
|
1096
|
+
job_params = job_params.copy()
|
|
1097
|
+
job_params["id_generator"] = "deterministic"
|
|
1098
|
+
job_params["sid"] = files[0]['metadata']['request_id']
|
|
1099
|
+
expected_transfer_id = self.__get_deterministic_id(job_params["sid"])
|
|
1100
|
+
self.logger(logging.DEBUG, "Submit bulk transfers in deterministic mode, sid %s, expected transfer id: %s", job_params["sid"], expected_transfer_id)
|
|
1101
|
+
|
|
1102
|
+
# bulk submission
|
|
1103
|
+
params_dict = {'files': files, 'params': job_params}
|
|
1104
|
+
params_str = json.dumps(params_dict, cls=APIEncoder)
|
|
1105
|
+
|
|
1106
|
+
post_result = None
|
|
1107
|
+
stopwatch = Stopwatch()
|
|
1108
|
+
try:
|
|
1109
|
+
post_result = requests.post('%s/jobs' % self.external_host,
|
|
1110
|
+
verify=self.verify,
|
|
1111
|
+
cert=self.cert,
|
|
1112
|
+
data=params_str,
|
|
1113
|
+
headers=self.headers,
|
|
1114
|
+
timeout=timeout)
|
|
1115
|
+
labels = {'host': self.__extract_host(self.external_host)}
|
|
1116
|
+
METRICS.timer('submit_transfer.{host}').labels(**labels).observe(stopwatch.elapsed / (len(files) or 1))
|
|
1117
|
+
except ReadTimeout as error:
|
|
1118
|
+
raise TransferToolTimeout(error)
|
|
1119
|
+
except json.JSONDecodeError as error:
|
|
1120
|
+
raise TransferToolWrongAnswer(error)
|
|
1121
|
+
except Exception as error:
|
|
1122
|
+
self.logger(logging.WARNING, 'Could not submit transfer to %s - %s' % (self.external_host, str(error)))
|
|
1123
|
+
|
|
1124
|
+
if post_result and post_result.status_code == 200:
|
|
1125
|
+
SUBMISSION_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc(len(files))
|
|
1126
|
+
transfer_id = str(post_result.json()['job_id'])
|
|
1127
|
+
elif post_result and post_result.status_code == 409:
|
|
1128
|
+
SUBMISSION_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc(len(files))
|
|
1129
|
+
raise DuplicateFileTransferSubmission()
|
|
1130
|
+
else:
|
|
1131
|
+
if expected_transfer_id:
|
|
1132
|
+
transfer_id = expected_transfer_id
|
|
1133
|
+
self.logger(logging.WARNING, "Failed to submit transfer to %s, will use expected transfer id %s, error: %s", self.external_host, transfer_id, post_result.text if post_result is not None else post_result)
|
|
1134
|
+
else:
|
|
1135
|
+
self.logger(logging.WARNING, "Failed to submit transfer to %s, error: %s", self.external_host, post_result.text if post_result is not None else post_result)
|
|
1136
|
+
SUBMISSION_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc(len(files))
|
|
1137
|
+
|
|
1138
|
+
if not transfer_id:
|
|
1139
|
+
raise TransferToolWrongAnswer('No transfer id returned by %s' % self.external_host)
|
|
1140
|
+
METRICS.timer('submit_transfers_fts3').observe(stopwatch.elapsed / (len(transfers) or 1))
|
|
1141
|
+
return transfer_id
|
|
1142
|
+
|
|
1143
|
+
def cancel(self, transfer_ids: "Sequence[str]", timeout: Optional[int] = None) -> dict[str, Any]:
|
|
1144
|
+
"""
|
|
1145
|
+
Cancel transfers that have been submitted to FTS3.
|
|
1146
|
+
|
|
1147
|
+
:param transfer_ids: FTS transfer identifiers as list of strings.
|
|
1148
|
+
:param timeout: Timeout in seconds.
|
|
1149
|
+
:returns: True if cancellation was successful.
|
|
1150
|
+
"""
|
|
1151
|
+
|
|
1152
|
+
if len(transfer_ids) > 1:
|
|
1153
|
+
raise NotImplementedError('Bulk cancelling not implemented')
|
|
1154
|
+
transfer_id = transfer_ids[0]
|
|
1155
|
+
|
|
1156
|
+
job = None
|
|
1157
|
+
|
|
1158
|
+
job = requests.delete('%s/jobs/%s' % (self.external_host, transfer_id),
|
|
1159
|
+
verify=self.verify,
|
|
1160
|
+
cert=self.cert,
|
|
1161
|
+
headers=self.headers,
|
|
1162
|
+
timeout=timeout)
|
|
1163
|
+
|
|
1164
|
+
if job and job.status_code == 200:
|
|
1165
|
+
CANCEL_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc()
|
|
1166
|
+
return job.json()
|
|
1167
|
+
|
|
1168
|
+
CANCEL_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1169
|
+
raise Exception('Could not cancel transfer: %s', job.content)
|
|
1170
|
+
|
|
1171
|
+
def update_priority(self, transfer_id: str, priority: int, timeout: Optional[int] = None) -> dict[str, Any]:
|
|
1172
|
+
"""
|
|
1173
|
+
Update the priority of a transfer that has been submitted to FTS via JSON.
|
|
1174
|
+
|
|
1175
|
+
:param transfer_id: FTS transfer identifier as a string.
|
|
1176
|
+
:param priority: FTS job priority as an integer from 1 to 5.
|
|
1177
|
+
:param timeout: Timeout in seconds.
|
|
1178
|
+
:returns: True if update was successful.
|
|
1179
|
+
"""
|
|
1180
|
+
|
|
1181
|
+
job = None
|
|
1182
|
+
params_dict = {"params": {"priority": priority}}
|
|
1183
|
+
params_str = json.dumps(params_dict, cls=APIEncoder)
|
|
1184
|
+
|
|
1185
|
+
job = requests.post('%s/jobs/%s' % (self.external_host, transfer_id),
|
|
1186
|
+
verify=self.verify,
|
|
1187
|
+
data=params_str,
|
|
1188
|
+
cert=self.cert,
|
|
1189
|
+
headers=self.headers,
|
|
1190
|
+
timeout=timeout) # TODO set to 3 in conveyor
|
|
1191
|
+
|
|
1192
|
+
if job and job.status_code == 200:
|
|
1193
|
+
UPDATE_PRIORITY_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc()
|
|
1194
|
+
return job.json()
|
|
1195
|
+
|
|
1196
|
+
UPDATE_PRIORITY_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1197
|
+
raise Exception('Could not update priority of transfer: %s', job.content)
|
|
1198
|
+
|
|
1199
|
+
def query(self, transfer_ids: "Sequence[str]", details: bool = False, timeout: Optional[int] = None) -> Union[Optional[dict[str, Any]], list[dict[str, Any]]]:
|
|
1200
|
+
"""
|
|
1201
|
+
Query the status of a transfer in FTS3 via JSON.
|
|
1202
|
+
|
|
1203
|
+
:param transfer_ids: FTS transfer identifiers as list of strings.
|
|
1204
|
+
:param details: Switch if detailed information should be listed.
|
|
1205
|
+
:param timeout: Timeout in seconds.
|
|
1206
|
+
:returns: Transfer status information as a list of dictionaries.
|
|
1207
|
+
"""
|
|
1208
|
+
|
|
1209
|
+
if len(transfer_ids) > 1:
|
|
1210
|
+
raise NotImplementedError('FTS3 transfertool query not bulk ready')
|
|
1211
|
+
|
|
1212
|
+
transfer_id = transfer_ids[0]
|
|
1213
|
+
if details:
|
|
1214
|
+
return self.__query_details(transfer_id=transfer_id)
|
|
1215
|
+
|
|
1216
|
+
job = None
|
|
1217
|
+
|
|
1218
|
+
job = requests.get('%s/jobs/%s' % (self.external_host, transfer_id),
|
|
1219
|
+
verify=self.verify,
|
|
1220
|
+
cert=self.cert,
|
|
1221
|
+
headers=self.headers,
|
|
1222
|
+
timeout=timeout) # TODO Set to 5 in conveyor
|
|
1223
|
+
if job and job.status_code == 200:
|
|
1224
|
+
QUERY_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc()
|
|
1225
|
+
return [job.json()]
|
|
1226
|
+
|
|
1227
|
+
QUERY_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1228
|
+
raise Exception('Could not retrieve transfer information: %s', job.content)
|
|
1229
|
+
|
|
1230
|
+
# Public methods, not part of the common interface specification (FTS3 specific)
|
|
1231
|
+
|
|
1232
|
+
def whoami(self) -> dict[str, Any]:
|
|
1233
|
+
"""
|
|
1234
|
+
Returns credential information from the FTS3 server.
|
|
1235
|
+
|
|
1236
|
+
:returns: Credentials as stored by the FTS3 server as a dictionary.
|
|
1237
|
+
"""
|
|
1238
|
+
|
|
1239
|
+
get_result = None
|
|
1240
|
+
|
|
1241
|
+
get_result = requests.get('%s/whoami' % self.external_host,
|
|
1242
|
+
verify=self.verify,
|
|
1243
|
+
cert=self.cert,
|
|
1244
|
+
headers=self.headers)
|
|
1245
|
+
|
|
1246
|
+
if get_result and get_result.status_code == 200:
|
|
1247
|
+
WHOAMI_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc()
|
|
1248
|
+
return get_result.json()
|
|
1249
|
+
|
|
1250
|
+
WHOAMI_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1251
|
+
raise Exception('Could not retrieve credentials: %s', get_result.content)
|
|
1252
|
+
|
|
1253
|
+
def version(self) -> dict[str, Any]:
|
|
1254
|
+
"""
|
|
1255
|
+
Returns FTS3 server information.
|
|
1256
|
+
|
|
1257
|
+
:returns: FTS3 server information as a dictionary.
|
|
1258
|
+
"""
|
|
1259
|
+
|
|
1260
|
+
get_result = None
|
|
1261
|
+
|
|
1262
|
+
get_result = requests.get('%s/' % self.external_host,
|
|
1263
|
+
verify=self.verify,
|
|
1264
|
+
cert=self.cert,
|
|
1265
|
+
headers=self.headers)
|
|
1266
|
+
|
|
1267
|
+
if get_result and get_result.status_code == 200:
|
|
1268
|
+
VERSION_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc()
|
|
1269
|
+
return get_result.json()
|
|
1270
|
+
|
|
1271
|
+
VERSION_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1272
|
+
raise Exception('Could not retrieve version: %s', get_result.content)
|
|
1273
|
+
|
|
1274
|
+
def bulk_query(self, requests_by_eid: dict[str, dict[str, dict[str, Any]]], timeout: Optional[int] = None) -> dict[str, Any]:
|
|
1275
|
+
"""
|
|
1276
|
+
Query the status of a bulk of transfers in FTS3 via JSON.
|
|
1277
|
+
|
|
1278
|
+
:param requests_by_eid: dictionary {external_id1: {request_id1: request1, ...}, ...} of request to be queried
|
|
1279
|
+
:returns: Transfer status information as a dictionary.
|
|
1280
|
+
"""
|
|
1281
|
+
|
|
1282
|
+
responses = {}
|
|
1283
|
+
fts_session = requests.Session()
|
|
1284
|
+
xfer_ids = ','.join(requests_by_eid)
|
|
1285
|
+
jobs = fts_session.get('%s/jobs/%s?files=file_state,dest_surl,finish_time,start_time,staging_start,staging_finished,reason,source_surl,file_metadata' % (self.external_host, xfer_ids),
|
|
1286
|
+
verify=self.verify,
|
|
1287
|
+
cert=self.cert,
|
|
1288
|
+
headers=self.headers,
|
|
1289
|
+
timeout=timeout)
|
|
1290
|
+
|
|
1291
|
+
if jobs is None:
|
|
1292
|
+
BULK_QUERY_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1293
|
+
for transfer_id in requests_by_eid:
|
|
1294
|
+
responses[transfer_id] = Exception('Transfer information returns None: %s' % jobs)
|
|
1295
|
+
elif jobs.status_code in (200, 207, 404):
|
|
1296
|
+
try:
|
|
1297
|
+
BULK_QUERY_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc()
|
|
1298
|
+
jobs_response = jobs.json()
|
|
1299
|
+
responses = self.__bulk_query_responses(jobs_response, requests_by_eid)
|
|
1300
|
+
except ReadTimeout as error:
|
|
1301
|
+
raise TransferToolTimeout(error)
|
|
1302
|
+
except json.JSONDecodeError as error:
|
|
1303
|
+
raise TransferToolWrongAnswer(error)
|
|
1304
|
+
except Exception as error:
|
|
1305
|
+
raise Exception("Failed to parse the job response: %s, error: %s" % (str(jobs), str(error)))
|
|
1306
|
+
else:
|
|
1307
|
+
BULK_QUERY_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1308
|
+
for transfer_id in requests_by_eid:
|
|
1309
|
+
responses[transfer_id] = Exception('Could not retrieve transfer information: %s', jobs.content)
|
|
1310
|
+
|
|
1311
|
+
return responses
|
|
1312
|
+
|
|
1313
|
+
def list_se_status(self) -> dict[str, Any]:
|
|
1314
|
+
"""
|
|
1315
|
+
Get the list of banned Storage Elements.
|
|
1316
|
+
|
|
1317
|
+
:returns: Detailed dictionary of banned Storage Elements.
|
|
1318
|
+
"""
|
|
1319
|
+
|
|
1320
|
+
try:
|
|
1321
|
+
result = requests.get('%s/ban/se' % self.external_host,
|
|
1322
|
+
verify=self.verify,
|
|
1323
|
+
cert=self.cert,
|
|
1324
|
+
headers=self.headers,
|
|
1325
|
+
timeout=None)
|
|
1326
|
+
except Exception as error:
|
|
1327
|
+
raise Exception('Could not retrieve transfer information: %s', error)
|
|
1328
|
+
if result and result.status_code == 200:
|
|
1329
|
+
return result.json()
|
|
1330
|
+
raise Exception('Could not retrieve transfer information: %s', result.content)
|
|
1331
|
+
|
|
1332
|
+
def get_se_config(self, storage_element: str) -> dict[str, Any]:
|
|
1333
|
+
"""
|
|
1334
|
+
Get the Json response for the configuration of a storage element.
|
|
1335
|
+
:returns: a Json result for the configuration of a storage element.
|
|
1336
|
+
:param storage_element: the storage element you want the configuration for.
|
|
1337
|
+
"""
|
|
1338
|
+
|
|
1339
|
+
try:
|
|
1340
|
+
result = requests.get('%s/config/se' % (self.external_host),
|
|
1341
|
+
verify=self.verify,
|
|
1342
|
+
cert=self.cert,
|
|
1343
|
+
headers=self.headers,
|
|
1344
|
+
timeout=None)
|
|
1345
|
+
except Exception:
|
|
1346
|
+
self.logger(logging.WARNING, 'Could not get config of %s on %s - %s', storage_element, self.external_host, str(traceback.format_exc()))
|
|
1347
|
+
if result and result.status_code == 200:
|
|
1348
|
+
result_json = result.json()
|
|
1349
|
+
config_se = result_json[storage_element]
|
|
1350
|
+
return config_se
|
|
1351
|
+
raise Exception('Could not get the configuration of %s , status code returned : %s', (storage_element, result.status_code if result else None))
|
|
1352
|
+
|
|
1353
|
+
def set_se_config(
|
|
1354
|
+
self,
|
|
1355
|
+
storage_element: str,
|
|
1356
|
+
inbound_max_active: Optional[int] = None,
|
|
1357
|
+
outbound_max_active: Optional[int] = None,
|
|
1358
|
+
inbound_max_throughput: Optional[float] = None,
|
|
1359
|
+
outbound_max_throughput: Optional[float] = None,
|
|
1360
|
+
staging: Optional[int] = None
|
|
1361
|
+
) -> dict[str, Any]:
|
|
1362
|
+
"""
|
|
1363
|
+
Set the configuration for a storage element. Used for alleviating transfer failures due to timeout.
|
|
1364
|
+
|
|
1365
|
+
:param storage_element: The storage element to be configured
|
|
1366
|
+
:param inbound_max_active: the integer to set the inbound_max_active for the SE.
|
|
1367
|
+
:param outbound_max_active: the integer to set the outbound_max_active for the SE.
|
|
1368
|
+
:param inbound_max_throughput: the float to set the inbound_max_throughput for the SE.
|
|
1369
|
+
:param outbound_max_throughput: the float to set the outbound_max_throughput for the SE.
|
|
1370
|
+
:param staging: the integer to set the staging for the operation of a SE.
|
|
1371
|
+
:returns: JSON post response in case of success, otherwise raise Exception.
|
|
1372
|
+
"""
|
|
1373
|
+
|
|
1374
|
+
params_dict = {storage_element: {'operations': {}, 'se_info': {}}}
|
|
1375
|
+
if staging is not None:
|
|
1376
|
+
policy = get_policy()
|
|
1377
|
+
params_dict[storage_element]['operations'] = {policy: {'staging': staging}}
|
|
1378
|
+
# A lot of try-excepts to avoid dictionary overwrite's,
|
|
1379
|
+
# see https://stackoverflow.com/questions/27118687/updating-nested-dictionaries-when-data-has-existing-key/27118776
|
|
1380
|
+
if inbound_max_active is not None:
|
|
1381
|
+
try:
|
|
1382
|
+
params_dict[storage_element]['se_info']['inbound_max_active'] = inbound_max_active
|
|
1383
|
+
except KeyError:
|
|
1384
|
+
params_dict[storage_element]['se_info'] = {'inbound_max_active': inbound_max_active}
|
|
1385
|
+
if outbound_max_active is not None:
|
|
1386
|
+
try:
|
|
1387
|
+
params_dict[storage_element]['se_info']['outbound_max_active'] = outbound_max_active
|
|
1388
|
+
except KeyError:
|
|
1389
|
+
params_dict[storage_element]['se_info'] = {'outbound_max_active': outbound_max_active}
|
|
1390
|
+
if inbound_max_throughput is not None:
|
|
1391
|
+
try:
|
|
1392
|
+
params_dict[storage_element]['se_info']['inbound_max_throughput'] = inbound_max_throughput
|
|
1393
|
+
except KeyError:
|
|
1394
|
+
params_dict[storage_element]['se_info'] = {'inbound_max_throughput': inbound_max_throughput}
|
|
1395
|
+
if outbound_max_throughput is not None:
|
|
1396
|
+
try:
|
|
1397
|
+
params_dict[storage_element]['se_info']['outbound_max_throughput'] = outbound_max_throughput
|
|
1398
|
+
except KeyError:
|
|
1399
|
+
params_dict[storage_element]['se_info'] = {'outbound_max_throughput': outbound_max_throughput}
|
|
1400
|
+
|
|
1401
|
+
params_str = json.dumps(params_dict, cls=APIEncoder)
|
|
1402
|
+
|
|
1403
|
+
try:
|
|
1404
|
+
result = requests.post('%s/config/se' % (self.external_host),
|
|
1405
|
+
verify=self.verify,
|
|
1406
|
+
cert=self.cert,
|
|
1407
|
+
data=params_str,
|
|
1408
|
+
headers=self.headers,
|
|
1409
|
+
timeout=None)
|
|
1410
|
+
|
|
1411
|
+
except Exception:
|
|
1412
|
+
self.logger(logging.WARNING, 'Could not set the config of %s on %s - %s', storage_element, self.external_host, str(traceback.format_exc()))
|
|
1413
|
+
if result and result.status_code == 200:
|
|
1414
|
+
config_se = result.json()
|
|
1415
|
+
return config_se
|
|
1416
|
+
raise Exception('Could not set the configuration of %s , status code returned : %s', (storage_element, result.status_code if result else None))
|
|
1417
|
+
|
|
1418
|
+
def set_se_status(self, storage_element: str, message: str, ban: bool = True, timeout: Optional[int] = None) -> int:
|
|
1419
|
+
"""
|
|
1420
|
+
Ban a Storage Element. Used when a site is in downtime.
|
|
1421
|
+
One can use a timeout in seconds. In that case the jobs will wait before being cancel.
|
|
1422
|
+
If no timeout is specified, the jobs are canceled immediately
|
|
1423
|
+
|
|
1424
|
+
:param storage_element: The Storage Element that will be banned.
|
|
1425
|
+
:param message: The reason of the ban.
|
|
1426
|
+
:param ban: Boolean. If set to True, ban the SE, if set to False unban the SE.
|
|
1427
|
+
:param timeout: if None, send to FTS status 'cancel' else 'waiting' + the corresponding timeout.
|
|
1428
|
+
|
|
1429
|
+
:returns: 0 in case of success, otherwise raise Exception
|
|
1430
|
+
"""
|
|
1431
|
+
|
|
1432
|
+
params_dict: dict[str, Any] = {'storage': storage_element, 'message': message}
|
|
1433
|
+
status = 'CANCEL'
|
|
1434
|
+
if timeout:
|
|
1435
|
+
params_dict['timeout'] = timeout
|
|
1436
|
+
status = 'WAIT'
|
|
1437
|
+
params_dict['status'] = status
|
|
1438
|
+
params_str = json.dumps(params_dict, cls=APIEncoder)
|
|
1439
|
+
|
|
1440
|
+
result = None
|
|
1441
|
+
if ban:
|
|
1442
|
+
try:
|
|
1443
|
+
result = requests.post('%s/ban/se' % self.external_host,
|
|
1444
|
+
verify=self.verify,
|
|
1445
|
+
cert=self.cert,
|
|
1446
|
+
data=params_str,
|
|
1447
|
+
headers=self.headers,
|
|
1448
|
+
timeout=None)
|
|
1449
|
+
except Exception:
|
|
1450
|
+
self.logger(logging.WARNING, 'Could not ban %s on %s - %s', storage_element, self.external_host, str(traceback.format_exc()))
|
|
1451
|
+
if result and result.status_code == 200:
|
|
1452
|
+
return 0
|
|
1453
|
+
raise Exception('Could not ban the storage %s , status code returned : %s', (storage_element, result.status_code if result else None))
|
|
1454
|
+
else:
|
|
1455
|
+
|
|
1456
|
+
try:
|
|
1457
|
+
result = requests.delete('%s/ban/se?storage=%s' % (self.external_host, storage_element),
|
|
1458
|
+
verify=self.verify,
|
|
1459
|
+
cert=self.cert,
|
|
1460
|
+
data=params_str,
|
|
1461
|
+
headers=self.headers,
|
|
1462
|
+
timeout=None)
|
|
1463
|
+
except Exception:
|
|
1464
|
+
self.logger(logging.WARNING, 'Could not unban %s on %s - %s', storage_element, self.external_host, str(traceback.format_exc()))
|
|
1465
|
+
if result and result.status_code == 204:
|
|
1466
|
+
return 0
|
|
1467
|
+
raise Exception('Could not unban the storage %s , status code returned : %s', (storage_element, result.status_code if result else None))
|
|
1468
|
+
|
|
1469
|
+
# Private methods unique to the FTS3 Transfertool
|
|
1470
|
+
|
|
1471
|
+
@staticmethod
|
|
1472
|
+
def __extract_host(external_host: str) -> Optional[str]:
|
|
1473
|
+
# graphite does not like the dots in the FQDN
|
|
1474
|
+
parsed_url = urlparse(external_host)
|
|
1475
|
+
if parsed_url.hostname:
|
|
1476
|
+
return parsed_url.hostname.replace('.', '_')
|
|
1477
|
+
|
|
1478
|
+
def __get_transfer_baseid_voname(self) -> tuple[Optional[str], Optional[str]]:
|
|
1479
|
+
"""
|
|
1480
|
+
Get transfer VO name from the external host.
|
|
1481
|
+
|
|
1482
|
+
:returns base id as a string and VO name as a string.
|
|
1483
|
+
"""
|
|
1484
|
+
result = (None, None)
|
|
1485
|
+
try:
|
|
1486
|
+
key = 'voname:%s' % self.external_host
|
|
1487
|
+
result = REGION_SHORT.get(key)
|
|
1488
|
+
if isinstance(result, NoValue):
|
|
1489
|
+
self.logger(logging.DEBUG, "Refresh transfer baseid and voname for %s", self.external_host)
|
|
1490
|
+
|
|
1491
|
+
get_result = None
|
|
1492
|
+
try:
|
|
1493
|
+
get_result = requests.get('%s/whoami' % self.external_host,
|
|
1494
|
+
verify=self.verify,
|
|
1495
|
+
cert=self.cert,
|
|
1496
|
+
headers=self.headers,
|
|
1497
|
+
timeout=5)
|
|
1498
|
+
except ReadTimeout as error:
|
|
1499
|
+
raise TransferToolTimeout(error)
|
|
1500
|
+
except json.JSONDecodeError as error:
|
|
1501
|
+
raise TransferToolWrongAnswer(error)
|
|
1502
|
+
except Exception as error:
|
|
1503
|
+
self.logger(logging.WARNING, 'Could not get baseid and voname from %s - %s' % (self.external_host, str(error)))
|
|
1504
|
+
|
|
1505
|
+
if get_result and get_result.status_code == 200:
|
|
1506
|
+
baseid = str(get_result.json()['base_id'])
|
|
1507
|
+
voname = str(get_result.json()['vos'][0])
|
|
1508
|
+
result = (baseid, voname)
|
|
1509
|
+
|
|
1510
|
+
REGION_SHORT.set(key, result)
|
|
1511
|
+
|
|
1512
|
+
self.logger(logging.DEBUG, "Get baseid %s and voname %s from %s", baseid, voname, self.external_host)
|
|
1513
|
+
else:
|
|
1514
|
+
self.logger(logging.WARNING, "Failed to get baseid and voname from %s, error: %s", self.external_host, get_result.text if get_result is not None else get_result)
|
|
1515
|
+
result = (None, None)
|
|
1516
|
+
except Exception as error:
|
|
1517
|
+
self.logger(logging.WARNING, "Failed to get baseid and voname from %s: %s" % (self.external_host, str(error)))
|
|
1518
|
+
result = (None, None)
|
|
1519
|
+
return result
|
|
1520
|
+
|
|
1521
|
+
def __get_deterministic_id(self, sid: str) -> Optional[str]:
|
|
1522
|
+
"""
|
|
1523
|
+
Get deterministic FTS job id.
|
|
1524
|
+
|
|
1525
|
+
:param sid: FTS seed id.
|
|
1526
|
+
:returns: FTS transfer identifier.
|
|
1527
|
+
"""
|
|
1528
|
+
baseid, voname = self.__get_transfer_baseid_voname()
|
|
1529
|
+
if baseid is None or voname is None:
|
|
1530
|
+
return None
|
|
1531
|
+
root = uuid.UUID(baseid)
|
|
1532
|
+
atlas = uuid.uuid5(root, voname)
|
|
1533
|
+
jobid = uuid.uuid5(atlas, sid)
|
|
1534
|
+
return str(jobid)
|
|
1535
|
+
|
|
1536
|
+
def __bulk_query_responses(self, jobs_response: list[dict[str, Any]], requests_by_eid: dict[str, dict[str, dict[str, Any]]]) -> dict[str, Any]:
|
|
1537
|
+
if not isinstance(jobs_response, list):
|
|
1538
|
+
jobs_response = [jobs_response]
|
|
1539
|
+
|
|
1540
|
+
responses = {}
|
|
1541
|
+
for job_response in jobs_response:
|
|
1542
|
+
transfer_id = job_response['job_id']
|
|
1543
|
+
if job_response['http_status'] == '200 Ok':
|
|
1544
|
+
files_response = job_response['files']
|
|
1545
|
+
multi_sources = job_response['job_metadata'].get('multi_sources', False)
|
|
1546
|
+
if multi_sources and job_response['job_state'] not in [FTS_STATE.FAILED,
|
|
1547
|
+
FTS_STATE.FINISHEDDIRTY,
|
|
1548
|
+
FTS_STATE.CANCELED,
|
|
1549
|
+
FTS_STATE.FINISHED]:
|
|
1550
|
+
# multiple source replicas jobs is still running. should wait
|
|
1551
|
+
responses[transfer_id] = {}
|
|
1552
|
+
continue
|
|
1553
|
+
|
|
1554
|
+
resps = {}
|
|
1555
|
+
for file_resp in files_response:
|
|
1556
|
+
file_state = file_resp['file_state']
|
|
1557
|
+
# for multiple source replicas jobs, the file_metadata(request_id) will be the same.
|
|
1558
|
+
# The next used file will overwrite the current used one. Only the last used file will return.
|
|
1559
|
+
if multi_sources and file_state == FTS_STATE.NOT_USED:
|
|
1560
|
+
continue
|
|
1561
|
+
|
|
1562
|
+
request_id = file_resp['file_metadata']['request_id']
|
|
1563
|
+
request = requests_by_eid.get(transfer_id, {}).get(request_id)
|
|
1564
|
+
if request is not None:
|
|
1565
|
+
resps[request_id] = FTS3ApiTransferStatusReport(self.external_host, request_id=request_id, request=request,
|
|
1566
|
+
job_response=job_response, file_response=file_resp)
|
|
1567
|
+
|
|
1568
|
+
# multiple source replicas jobs and we found the successful one, it's the final state.
|
|
1569
|
+
if multi_sources and file_state == FTS_STATE.FINISHED:
|
|
1570
|
+
break
|
|
1571
|
+
responses[transfer_id] = resps
|
|
1572
|
+
elif job_response['http_status'] == '404 Not Found':
|
|
1573
|
+
# Lost transfer
|
|
1574
|
+
responses[transfer_id] = None
|
|
1575
|
+
else:
|
|
1576
|
+
responses[transfer_id] = Exception('Could not retrieve transfer information(http_status: %s, http_message: %s)' % (job_response['http_status'],
|
|
1577
|
+
job_response['http_message'] if 'http_message' in job_response else None))
|
|
1578
|
+
return responses
|
|
1579
|
+
|
|
1580
|
+
def __query_details(self, transfer_id: str) -> Optional[dict[str, Any]]:
|
|
1581
|
+
"""
|
|
1582
|
+
Query the detailed status of a transfer in FTS3 via JSON.
|
|
1583
|
+
|
|
1584
|
+
:param transfer_id: FTS transfer identifier as a string.
|
|
1585
|
+
:returns: Detailed transfer status information as a dictionary.
|
|
1586
|
+
"""
|
|
1587
|
+
|
|
1588
|
+
files = None
|
|
1589
|
+
|
|
1590
|
+
files = requests.get('%s/jobs/%s/files' % (self.external_host, transfer_id),
|
|
1591
|
+
verify=self.verify,
|
|
1592
|
+
cert=self.cert,
|
|
1593
|
+
headers=self.headers,
|
|
1594
|
+
timeout=5)
|
|
1595
|
+
if files and (files.status_code == 200 or files.status_code == 207):
|
|
1596
|
+
QUERY_DETAILS_COUNTER.labels(state='success', host=self.__extract_host(self.external_host)).inc()
|
|
1597
|
+
return files.json()
|
|
1598
|
+
|
|
1599
|
+
QUERY_DETAILS_COUNTER.labels(state='failure', host=self.__extract_host(self.external_host)).inc()
|
|
1600
|
+
return
|