Skip to content

Commit

Permalink
Fix update token interval calculation.
Browse files Browse the repository at this point in the history
We should chouse min value from expiresIn and RefreshPeriod_, not max one
  • Loading branch information
dcherednik committed Mar 21, 2024
1 parent bde84b8 commit 152db69
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ydb/public/sdk/cpp/client/iam/common/iam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class TIAMCredentialsProvider : public ICredentialsProvider {
else {
const TDuration expiresIn = TDuration::Seconds(it->second.GetUInteger());

NextTicketUpdate_ = TInstant::Now() + std::max(expiresIn, RefreshPeriod_);
const auto interval = std::max(std::min(expiresIn, RefreshPeriod_), TDuration::MilliSeconds(100));

NextTicketUpdate_ = TInstant::Now() + interval;
}
} catch (...) {
}
Expand All @@ -83,4 +85,4 @@ TCredentialsProviderFactoryPtr CreateIamCredentialsProviderFactory(const TIamHos
return std::make_shared<TIamCredentialsProviderFactory>(params);
}

}
}

0 comments on commit 152db69

Please sign in to comment.