You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//If a previous request failed, then do not retry until backoffTimeoutUs has passed.
903
+
if (backoffFailureTs)
899
904
{
900
-
OERRLOG("Vault %s cannot get secret at location without a location", name.str());
901
-
returnfalse;
902
-
}
903
-
904
-
httplib::Client cli(schemeHostPort.str());
905
-
httplib::Headers headers = {
906
-
{ "X-Vault-Token", clientToken.str() }
907
-
};
905
+
if (getTimeStampNowValue() - backoffFailureTs < backoffTimeoutUs)
906
+
returnfalse;
908
907
909
-
unsigned numRetries = 0;
910
-
initClient(cli, headers, numRetries);
911
-
httplib::Result res = cli.Get(location, headers);
912
-
while (!res && numRetries--)
913
-
{
914
-
OERRLOG("Retrying vault %s get secret, communication error %d location %s", name.str(), res.error(), location);
915
-
if (retryWait)
916
-
Sleep(retryWait);
917
-
res = cli.Get(location, headers);
908
+
//Clear the last failure - to avoid the check on the timestamp.
909
+
backoffFailureTs = 0;
918
910
}
919
911
920
-
if (res)
912
+
bool backoff = false;
913
+
try
921
914
{
922
-
if (res->status == 200)
915
+
checkAuthentication(permissionDenied);
916
+
if (isEmptyString(location))
923
917
{
924
-
rkind = kind;
925
-
content.append(res->body.c_str());
926
-
returntrue;
918
+
OERRLOG("Vault %s cannot get secret at location without a location", name.str());
919
+
returnfalse;
927
920
}
928
-
elseif (res->status == 403)
921
+
922
+
httplib::Client cli(schemeHostPort.str());
923
+
httplib::Headers headers = {
924
+
{ "X-Vault-Token", clientToken.str() }
925
+
};
926
+
927
+
unsigned numRetries = 0;
928
+
initClient(cli, headers, numRetries);
929
+
httplib::Result res = cli.Get(location, headers);
930
+
while (!res && numRetries--)
929
931
{
930
-
//try again forcing relogin, but only once. Just in case the token was invalidated but hasn't passed expiration time (for example max usage count exceeded).
OERRLOG("Retrying vault %s get secret, communication error %d location %s", name.str(), res.error(), location);
933
+
if (retryWait)
934
+
Sleep(retryWait);
935
+
res = cli.Get(location, headers);
934
936
}
935
-
elseif (res->status == 404)
937
+
938
+
if (res)
936
939
{
937
-
OERRLOG("Vault %s secret not found %s.%s location %s", name.str(), secretCacheKey, version ? version : "", location);
940
+
if (res->status == 200)
941
+
{
942
+
rkind = kind;
943
+
content.append(res->body.c_str());
944
+
returntrue;
945
+
}
946
+
elseif (res->status == 403)
947
+
{
948
+
//try again forcing relogin, but only once. Just in case the token was invalidated but hasn't passed expiration time (for example max usage count exceeded).
0 commit comments