Deletes block repostore folder in container when Codex node stops.

This commit is contained in:
Ben 2024-06-10 10:58:50 +02:00
parent 25663b59a0
commit 22527a5d93
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
4 changed files with 24 additions and 6 deletions

View File

@ -126,6 +126,14 @@ namespace CodexPlugin
return workflow.GetPodInfo(Container);
}
public void DeleteRepoFolder()
{
var containerNumber = Container.Containers.First().Recipe.Number;
var dataDir = $"datadir{containerNumber}";
var workflow = tools.CreateWorkflow();
workflow.ExecuteCommand(Container.Containers.First(), "rm", "-Rfv", $"/codex/{dataDir}/repo");
}
private T OnCodex<T>(Func<CodexApi, Task<T>> action)
{
var result = tools.CreateHttp(CheckContainerCrashed).OnClient(client => CallCodex(client, action));

View File

@ -119,7 +119,7 @@ namespace CodexPlugin
}
}
if(!string.IsNullOrEmpty(config.NameOverride))
if (!string.IsNullOrEmpty(config.NameOverride))
{
AddEnvVar("CODEX_NODENAME", config.NameOverride);
}

View File

@ -26,6 +26,7 @@ namespace CodexPlugin
CrashWatcher CrashWatcher { get; }
PodInfo GetPodInfo();
ITransferSpeeds TransferSpeeds { get; }
void DeleteRepoFolder();
void Stop(bool waitTillStopped);
}
@ -160,15 +161,15 @@ namespace CodexPlugin
return CodexAccess.GetPodInfo();
}
public void DeleteRepoFolder()
{
CodexAccess.DeleteRepoFolder();
}
public void Stop(bool waitTillStopped)
{
CrashWatcher.Stop();
Group.Stop(this, waitTillStopped);
// if (Group.Count() > 1) throw new InvalidOperationException("Codex-nodes that are part of a group cannot be " +
// "individually shut down. Use 'BringOffline()' on the group object to stop the group. This method is only " +
// "available for codex-nodes in groups of 1.");
//
// Group.BringOffline(waitTillStopped);
}
public void EnsureOnlineGetVersionResponse()

View File

@ -38,6 +38,7 @@ namespace CodexTests
protected override void LifecycleStop(TestLifecycle lifecycle)
{
DeleteBlockRepo(onlineCodexNodes[lifecycle]);
onlineCodexNodes.Remove(lifecycle);
}
@ -134,5 +135,13 @@ namespace CodexTests
if (upload != null) data.Add("avgupload", upload.ToString());
if (download != null) data.Add("avgdownload", download.ToString());
}
private void DeleteBlockRepo(List<ICodexNode> codexNodes)
{
foreach (var node in codexNodes)
{
node.DeleteRepoFolder();
}
}
}
}