Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NBS-4456: separate init and iam-token-client and get token #296

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions cloud/blockstore/apps/client/lib/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@ void TCommand::Init()
Timer = CreateWallClockTimer();
Scheduler = CreateScheduler();

InitClientConfig(InitIamTokenClient());
InitIamTokenClient();

InitClientConfig();

const auto& logConfig = ClientConfig->GetLogConfig();
const auto& monConfig = ClientConfig->GetMonitoringConfig();
Expand Down Expand Up @@ -565,7 +567,7 @@ void TCommand::InitLWTrace()
probes.AddProbesList(LWTRACE_GET_PROBES(BLOCKSTORE_SERVER_PROVIDER));
}

TString TCommand::InitIamTokenClient()
void TCommand::InitIamTokenClient()
{
NProto::TIamClientConfig iamConfig;
if (IamConfigFile) {
Expand All @@ -582,9 +584,16 @@ TString TCommand::InitIamTokenClient()
CreateLoggingService("console"),
Scheduler,
Timer);

IamClient->Start();
}

TString TCommand::GetIamTokenFromClient()
{
TString iamToken;
if (!IamClient) {
return iamToken;
}
try {
auto tokenInfo = IamClient->GetTokenAsync().GetValue(WaitTimeout);
if (!HasError(tokenInfo)) {
Expand All @@ -597,7 +606,7 @@ TString TCommand::InitIamTokenClient()
return iamToken;
}

void TCommand::InitClientConfig(TString IamTokenFromClient)
void TCommand::InitClientConfig()
{
NProto::TClientAppConfig appConfig;
if (ConfigFile) {
Expand Down Expand Up @@ -676,7 +685,7 @@ void TCommand::InitClientConfig(TString IamTokenFromClient)
iamToken = GetIamTokenFromFile(IamTokenFile);
}
if (!iamToken) {
iamToken = std::move(IamTokenFromClient);
iamToken = GetIamTokenFromClient();
}
clientConfig.SetAuthToken(std::move(iamToken));
}
Expand Down
6 changes: 4 additions & 2 deletions cloud/blockstore/apps/client/lib/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ class TCommand

void Init();
void InitLWTrace();
TString InitIamTokenClient();
void InitClientConfig(TString IamTokenFromClient);
void InitIamTokenClient();
void InitClientConfig();

TString GetIamTokenFromClient();

void Start();
void Stop();
Expand Down
Loading