@@ -22,70 +22,12 @@ namespace fs = std::filesystem;
2222
2323namespace DB
2424{
25+
2526namespace ErrorCodes
2627{
2728 extern const int LOGICAL_ERROR;
2829}
2930
30- // / This function compares the authorization methods used to access AzureBlobStorage
31- // / It takes 2 variables of variant type as input and checks if they are the same type and value
32- static bool compareAuthMethod (AzureBlobStorage::AuthMethod auth_method_a, AzureBlobStorage::AuthMethod auth_method_b)
33- {
34- const auto * conn_string_a = std::get_if<AzureBlobStorage::ConnectionString>(&auth_method_a);
35- const auto * conn_string_b = std::get_if<AzureBlobStorage::ConnectionString>(&auth_method_b);
36-
37- if (conn_string_a && conn_string_b)
38- {
39- return *conn_string_a == *conn_string_b;
40- }
41-
42- const auto * shared_key_a = std::get_if<std::shared_ptr<Azure::Storage::StorageSharedKeyCredential>>(&auth_method_a);
43- const auto * shared_key_b = std::get_if<std::shared_ptr<Azure::Storage::StorageSharedKeyCredential>>(&auth_method_b);
44-
45- if (shared_key_a && shared_key_b)
46- {
47- return (shared_key_a->get ()->AccountName == shared_key_b->get ()->AccountName );
48- }
49-
50- try
51- {
52- const auto * workload_identity_a = std::get_if<std::shared_ptr<Azure::Identity::WorkloadIdentityCredential>>(&auth_method_a);
53- const auto * workload_identity_b = std::get_if<std::shared_ptr<Azure::Identity::WorkloadIdentityCredential>>(&auth_method_b);
54-
55- if (workload_identity_a && workload_identity_b)
56- {
57- Azure::Core::Credentials::TokenRequestContext tokenRequestContext;
58- return workload_identity_a->get ()->GetToken (tokenRequestContext, {}).Token == workload_identity_b->get ()->GetToken (tokenRequestContext, {}).Token ;
59- }
60-
61- const auto * managed_identity_a = std::get_if<std::shared_ptr<Azure::Identity::ManagedIdentityCredential>>(&auth_method_a);
62- const auto * managed_identity_b = std::get_if<std::shared_ptr<Azure::Identity::ManagedIdentityCredential>>(&auth_method_b);
63-
64- if (managed_identity_a && managed_identity_b)
65- {
66- Azure::Core::Credentials::TokenRequestContext tokenRequestContext;
67- return managed_identity_a->get ()->GetToken (tokenRequestContext, {}).Token == managed_identity_b->get ()->GetToken (tokenRequestContext, {}).Token ;
68- }
69-
70- const auto * static_credential_a = std::get_if<std::shared_ptr<AzureBlobStorage::StaticCredential>>(&auth_method_a);
71- const auto * static_credential_b = std::get_if<std::shared_ptr<AzureBlobStorage::StaticCredential>>(&auth_method_b);
72-
73- if (static_credential_a && static_credential_b)
74- {
75- Azure::Core::Credentials::TokenRequestContext tokenRequestContext;
76- auto az_context = Azure::Core::Context ();
77- return static_credential_a->get ()->GetToken (tokenRequestContext, az_context).Token == static_credential_b->get ()->GetToken (tokenRequestContext, az_context).Token ;
78- }
79- }
80- catch (const Azure::Core::Credentials::AuthenticationException & e)
81- {
82- // / This is added to catch exception from GetToken. We want to log & fail silently i.e return false so that we can fallback to read & copy (i.e not native copy)
83- LOG_DEBUG (getLogger (" compareAuthMethod" ), " Exception caught while comparing credentials, error = {}" , e.what ());
84- return false ;
85- }
86- return false ;
87- }
88-
8931BackupReaderAzureBlobStorage::BackupReaderAzureBlobStorage (
9032 const AzureBlobStorage::ConnectionParams & connection_params_,
9133 const String & blob_path_,
@@ -166,7 +108,7 @@ void BackupReaderAzureBlobStorage::copyFileToDisk(const String & path_in_backup,
166108 /* dest_path */ dst_blob_path[0 ],
167109 settings,
168110 read_settings,
169- compareAuthMethod (connection_params. auth_method , destination_disk-> getObjectStorage ()-> getAzureBlobStorageAuthMethod () ),
111+ std::optional<ObjectAttributes>( ),
170112 threadPoolCallbackRunnerUnsafe<void >(getBackupsIOThreadPool ().get (), " BackupRDAzure" ));
171113
172114 return file_size;
@@ -233,7 +175,7 @@ void BackupWriterAzureBlobStorage::copyFileFromDisk(
233175 // / In this case we can't use the native copy.
234176 if (auto src_blob_path = src_disk->getBlobPath (src_path); src_blob_path.size () == 2 )
235177 {
236- LOG_TRACE (log, " Copying file {} from disk {} to AzureBlobStorag " , src_path, src_disk->getName ());
178+ LOG_TRACE (log, " Copying file {} from disk {} to AzureBlobStorage " , src_path, src_disk->getName ());
237179 copyAzureBlobStorageFile (
238180 src_disk->getObjectStorage ()->getAzureBlobStorageClient (),
239181 client,
@@ -245,7 +187,7 @@ void BackupWriterAzureBlobStorage::copyFileFromDisk(
245187 fs::path (blob_path) / path_in_backup,
246188 settings,
247189 read_settings,
248- compareAuthMethod (src_disk-> getObjectStorage ()-> getAzureBlobStorageAuthMethod (), connection_params. auth_method ),
190+ std::optional<ObjectAttributes>( ),
249191 threadPoolCallbackRunnerUnsafe<void >(getBackupsIOThreadPool ().get (), " BackupWRAzure" ));
250192 return ; // / copied!
251193 }
@@ -269,7 +211,7 @@ void BackupWriterAzureBlobStorage::copyFile(const String & destination, const St
269211 /* dest_path */ destination,
270212 settings,
271213 read_settings,
272- true ,
214+ std::optional<ObjectAttributes>() ,
273215 threadPoolCallbackRunnerUnsafe<void >(getBackupsIOThreadPool ().get (), " BackupWRAzure" ));
274216}
275217
0 commit comments