@@ -139,7 +139,7 @@ class TS3FileWriteActor : public TActorBootstrapped<TS3FileWriteActor> {
139
139
const TString& token)
140
140
: TxId(txId)
141
141
, Gateway(std::move(gateway))
142
- , AuthInfo(crdentials.GetAuthInfo( ))
142
+ , Credentials(std::move(crdentials ))
143
143
, RetryPolicy(retryPolicy)
144
144
, ActorSystem(TActivationContext::ActorSystem())
145
145
, Key(key)
@@ -155,6 +155,9 @@ class TS3FileWriteActor : public TActorBootstrapped<TS3FileWriteActor> {
155
155
void Bootstrap (const TActorId& parentId) {
156
156
ParentId = parentId;
157
157
LOG_D (" TS3FileWriteActor" , " Bootstrap by " << ParentId << " for Key: [" << Key << " ], Url: [" << Url << " ], request id: [" << RequestId << " ]" );
158
+ if (!UpdateAuthInfo ()) {
159
+ return ;
160
+ }
158
161
if (DirtyWrite && Parts->IsSealed () && Parts->Size () <= 1 ) {
159
162
Become (&TS3FileWriteActor::SinglepartWorkingStateFunc);
160
163
const size_t size = Max<size_t >(Parts->Volume (), 1 );
@@ -359,13 +362,27 @@ class TS3FileWriteActor : public TActorBootstrapped<TS3FileWriteActor> {
359
362
}
360
363
}
361
364
365
+ bool UpdateAuthInfo () {
366
+ try {
367
+ AuthInfo = Credentials.GetAuthInfo ();
368
+ return true ;
369
+ }
370
+ catch (const yexception& ex) {
371
+ Send (ParentId, new TEvPrivate::TEvUploadError (NYql::NDqProto::StatusIds::BAD_REQUEST, TStringBuilder () << " Failed to get auth info: " << ex.what ()));
372
+ return false ;
373
+ }
374
+ }
375
+
362
376
void StartUploadParts () {
363
377
while (auto part = Parts->Pop ()) {
364
378
const auto size = part.size ();
365
379
const auto index = Tags.size ();
366
380
Tags.emplace_back ();
367
381
InFlight += size;
368
382
SentSize += size;
383
+ if (!UpdateAuthInfo ()) {
384
+ return ;
385
+ }
369
386
Gateway->Upload (Url + " ?partNumber=" + std::to_string (index + 1 ) + " &uploadId=" + UploadId,
370
387
IHTTPGateway::MakeYcHeaders (RequestId, AuthInfo.GetToken (), {}, AuthInfo.GetAwsUserPwd (), AuthInfo.GetAwsSigV4 ()),
371
388
std::move (part),
@@ -393,6 +410,9 @@ class TS3FileWriteActor : public TActorBootstrapped<TS3FileWriteActor> {
393
410
for (const auto & tag : Tags)
394
411
xml << " <Part><PartNumber>" << ++i << " </PartNumber><ETag>" << tag << " </ETag></Part>" << Endl;
395
412
xml << " </CompleteMultipartUpload>" << Endl;
413
+ if (!UpdateAuthInfo ()) {
414
+ return ;
415
+ }
396
416
Gateway->Upload (Url + " ?uploadId=" + UploadId,
397
417
IHTTPGateway::MakeYcHeaders (RequestId, AuthInfo.GetToken (), " application/xml" , AuthInfo.GetAwsUserPwd (), AuthInfo.GetAwsSigV4 ()),
398
418
xml,
@@ -409,6 +429,9 @@ class TS3FileWriteActor : public TActorBootstrapped<TS3FileWriteActor> {
409
429
return ;
410
430
}
411
431
432
+ if (!UpdateAuthInfo ()) {
433
+ return ;
434
+ }
412
435
Gateway->Delete (Url + " ?uploadId=" + UploadId,
413
436
IHTTPGateway::MakeYcHeaders (RequestId, AuthInfo.GetToken (), " application/xml" , AuthInfo.GetAwsUserPwd (), AuthInfo.GetAwsSigV4 ()),
414
437
std::bind (&TS3FileWriteActor::OnMultipartUploadAbort, ActorSystem, SelfId (), TxId, RequestId, std::placeholders::_1),
@@ -421,7 +444,7 @@ class TS3FileWriteActor : public TActorBootstrapped<TS3FileWriteActor> {
421
444
422
445
const TTxId TxId;
423
446
const IHTTPGateway::TPtr Gateway;
424
- const TS3Credentials::TAuthInfo AuthInfo ;
447
+ const TS3Credentials Credentials ;
425
448
const IHTTPGateway::TRetryPolicy::TPtr RetryPolicy;
426
449
427
450
TActorSystem* const ActorSystem;
@@ -437,6 +460,7 @@ class TS3FileWriteActor : public TActorBootstrapped<TS3FileWriteActor> {
437
460
TString UploadId;
438
461
bool DirtyWrite;
439
462
TString Token;
463
+ TS3Credentials::TAuthInfo AuthInfo;
440
464
};
441
465
442
466
class TS3WriteActor : public TActorBootstrapped <TS3WriteActor>, public IDqComputeActorAsyncOutput {
0 commit comments