diff --git a/Framework/KubernetesWorkflow/ByteSizeExtensions.cs b/Framework/KubernetesWorkflow/ByteSizeExtensions.cs deleted file mode 100644 index c3cca24..0000000 --- a/Framework/KubernetesWorkflow/ByteSizeExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Utils; - -namespace KubernetesWorkflow -{ - public static class ByteSizeExtensions - { - public static string ToSuffixNotation(this ByteSize b) - { - long x = 1024; - var map = new Dictionary - { - { Pow(x, 4), "Ti" }, - { Pow(x, 3), "Gi" }, - { Pow(x, 2), "Mi" }, - { (x), "Ki" }, - }; - - var bytes = b.SizeInBytes; - foreach (var pair in map) - { - if (bytes > pair.Key) - { - double bytesD = bytes; - double divD = pair.Key; - double numD = Math.Ceiling(bytesD / divD); - var v = Convert.ToInt64(numD); - return $"{v}{pair.Value}"; - } - } - - return $"{bytes}"; - } - - private static long Pow(long x, int v) - { - long result = 1; - for (var i = 0; i < v; i++) result *= x; - return result; - } - } -} diff --git a/Framework/KubernetesWorkflow/CrashWatcher.cs b/Framework/KubernetesWorkflow/CrashWatcher.cs index 5cb2e03..eb1ced7 100644 --- a/Framework/KubernetesWorkflow/CrashWatcher.cs +++ b/Framework/KubernetesWorkflow/CrashWatcher.cs @@ -83,12 +83,13 @@ namespace KubernetesWorkflow private bool HasContainerBeenRestarted(Kubernetes client) { var podInfo = client.ReadNamespacedPod(podName, k8sNamespace); - return podInfo.Status.ContainerStatuses.Any(c => c.RestartCount > 0); + var result = podInfo.Status.ContainerStatuses.Any(c => c.RestartCount > 0); + if (result) log.Log("Pod crash detected for " + containerName); + return result; } private void DownloadCrashedContainerLogs(Kubernetes client) { - log.Log("Pod crash detected for " + containerName); using var stream = client.ReadNamespacedPodLog(podName, k8sNamespace, recipeName, previous: true); logHandler!.Log(stream); } diff --git a/Framework/KubernetesWorkflow/K8sController.cs b/Framework/KubernetesWorkflow/K8sController.cs index 30de0c9..00c7563 100644 --- a/Framework/KubernetesWorkflow/K8sController.cs +++ b/Framework/KubernetesWorkflow/K8sController.cs @@ -535,7 +535,7 @@ namespace KubernetesWorkflow } if (set.Memory.SizeInBytes != 0) { - result.Add("memory", new ResourceQuantity(set.Memory.ToSuffixNotation())); + result.Add("memory", new ResourceQuantity(set.Memory.SizeInBytes.ToString())); } return result; } diff --git a/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs b/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs index 6b6ae2d..2c42143 100644 --- a/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs +++ b/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs @@ -105,7 +105,7 @@ namespace KubernetesWorkflow.Recipe protected void AddVolume(string name, string mountPath, string? subPath = null, string? secret = null, string? hostPath = null) { - var size = 10.MB().ToSuffixNotation(); + var size = 10.MB().SizeInBytes.ToString(); volumeMounts.Add(new VolumeMount(name, mountPath, subPath, size, secret, hostPath)); } @@ -114,7 +114,7 @@ namespace KubernetesWorkflow.Recipe volumeMounts.Add(new VolumeMount( $"autovolume-{Guid.NewGuid().ToString().ToLowerInvariant()}", mountPath, - resourceQuantity: volumeSize.ToSuffixNotation())); + resourceQuantity: volumeSize.SizeInBytes.ToString())); } protected void Additional(object userData) diff --git a/ProjectPlugins/CodexPlugin/CodexAccess.cs b/ProjectPlugins/CodexPlugin/CodexAccess.cs index 7013900..b63b9f4 100644 --- a/ProjectPlugins/CodexPlugin/CodexAccess.cs +++ b/ProjectPlugins/CodexPlugin/CodexAccess.cs @@ -167,8 +167,8 @@ namespace CodexPlugin { var log = tools.GetLog(); var file = log.CreateSubfile(); - log.Log($"Container {Container.Name} has crashed. Downloading crash log to '{file.FullFilename}'..."); - file.Write($"Container Crash Log for {Container.Name}."); + log.Log($"Downloading log to '{file.FullFilename}'..."); + file.Write($"Container log for {Container.Name}."); using var reader = new StreamReader(crashLog); var line = reader.ReadLine(); diff --git a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs index 531f82a..ac29ce1 100644 --- a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs +++ b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs @@ -159,7 +159,7 @@ namespace CodexPlugin private ByteSize GetVolumeCapacity(CodexStartupConfig config) { - if (config.StorageQuota != null) return config.StorageQuota; + if (config.StorageQuota != null) return config.StorageQuota.Multiply(1.2); // Default Codex quota: 8 Gb, using +20% to be safe. return 8.GB().Multiply(1.2); } diff --git a/Tests/CodexLongTests/ScalabilityTests/ScalabilityTests.cs b/Tests/CodexLongTests/ScalabilityTests/ScalabilityTests.cs index 4c9ce65..2e6eb14 100644 --- a/Tests/CodexLongTests/ScalabilityTests/ScalabilityTests.cs +++ b/Tests/CodexLongTests/ScalabilityTests/ScalabilityTests.cs @@ -9,12 +9,6 @@ namespace CodexTests.ScalabilityTests; [TestFixture] public class ScalabilityTests : CodexDistTest { - private const int Below2 = (Int32.MaxValue / (1024 * 1024)) - 20; - private const int Below1 = (Int32.MaxValue / (1024 * 1024)) - 10; - private const int Exact = (Int32.MaxValue / (1024 * 1024)) + 0; - private const int Above1 = (Int32.MaxValue / (1024 * 1024)) + 10; - private const int Above2 = (Int32.MaxValue / (1024 * 1024)) + 20; - /// /// We upload a file to node A, then download it with B. /// Then we stop node A, and download again with node C. @@ -25,8 +19,8 @@ public class ScalabilityTests : CodexDistTest [DontDownloadLogs] [WaitForCleanup] public void ShouldMaintainFileInNetwork( - [Values(5)] int numberOfNodes, // TODO: include 10, 40, 80 and 100, not 5 - [Values(Below2, Below1, Exact, Above1, Above2)] int fileSizeInMb // TODO: include 100, 1000, 5000, 10000 + [Values(4, 5, 6)] int numberOfNodes, // TODO: include 10, 40, 80 and 100, not 5 + [Values(2000, 2200, 2500, 2800, 3000, 3200, 3500, 3800, 4200, 4500, 4800, 5000)] int fileSizeInMb // TODO: include 100, 1000, 5000, 10000 ) { var logLevel = CodexLogLevel.Info; @@ -47,9 +41,11 @@ public class ScalabilityTests : CodexDistTest LogNodeStatus(uploader); var contentId = uploader.UploadFile(testFile, f => LogNodeStatus(uploader)); + LogNodeStatus(uploader); LogNodeStatus(downloader); var downloadedFile = downloader.DownloadContent(contentId, f => LogNodeStatus(downloader)); + LogNodeStatus(downloader); downloadedFile!.AssertIsEqual(testFile);