hacky way to download container logs while retries are failing.

This commit is contained in:
benbierens 2024-05-09 09:38:04 +02:00
parent c6a757d6fb
commit 6995cbfb23
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
2 changed files with 20 additions and 0 deletions

View File

@ -144,6 +144,12 @@ namespace Utils
return $"Attempt {index} took {FormatDuration(info.Item2)} and failed with exception {info.Item1}.";
}
private static Action<int> failedCallback = i => { };
public static void SetRetryFailedCallback(Action<int> onRetryFailed)
{
failedCallback = onRetryFailed;
}
public static T Retry<T>(Func<T> action, TimeSpan maxTimeout, TimeSpan retryTime, string description)
{
var start = DateTime.UtcNow;
@ -165,6 +171,7 @@ namespace Utils
catch (Exception ex)
{
exceptions.Add(ex);
failedCallback(tries);
tries++;
}

View File

@ -50,6 +50,8 @@ namespace CodexLongTests.BasicTests
var node = StartCodex(s => s.WithStorageQuota((size + 10).MB()));
Time.SetRetryFailedCallback(i => OnFailed(i, node));
var uploadStart = DateTime.UtcNow;
var cid = node.UploadFile(expectedFile);
var downloadStart = DateTime.UtcNow;
@ -60,6 +62,17 @@ namespace CodexLongTests.BasicTests
AssertTimeConstraint(uploadStart, downloadStart, downloadFinished, size);
}
private void OnFailed(int tries, ICodexNode node)
{
if (tries < 5) return;
if (tries % 10 == 0)
{
Log($"After try {tries}, downloading node log.");
Ci.DownloadLog(node);
}
}
private void AssertTimeConstraint(DateTime uploadStart, DateTime downloadStart, DateTime downloadFinished, long size)
{
float sizeInMB = size;