From 599583a4f40870f9885b87a9a4918cb6ca30f149 Mon Sep 17 00:00:00 2001 From: Blair L Murri Date: Mon, 25 Sep 2023 16:15:40 -0700 Subject: [PATCH] Overshoot compute node targets by rounding up to nearest 10 --- src/TesApi.Web/BatchPool.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/TesApi.Web/BatchPool.cs b/src/TesApi.Web/BatchPool.cs index 2c32a3d02..9a139a8b1 100644 --- a/src/TesApi.Web/BatchPool.cs +++ b/src/TesApi.Web/BatchPool.cs @@ -31,6 +31,8 @@ public sealed partial class BatchPool private const int MaxComputeNodesToRemoveAtOnce = 100; // https://learn.microsoft.com/en-us/rest/api/batchservice/pool/remove-nodes?tabs=HTTP#request-body nodeList description + private const int RoundUpOvershoot = 10; + private readonly ILogger _logger; private readonly IAzureProxy _azureProxy; @@ -221,7 +223,9 @@ public static string AutoPoolFormula(bool preemptable, int initialTarget) "span = TimeInterval_Second * 90;", "startup = TimeInterval_Minute * 2;", "ratio = 10;", - $"${targetVariable} = (lifespan > startup ? min($PendingTasks.GetSample(span, ratio)) : {initialTarget});" + $"target = (lifespan > startup ? min($PendingTasks.GetSample(span, ratio)) : {initialTarget});", + $"adjusted = target + {Math.Round(RoundUpOvershoot / 2.0)};", + $"${targetVariable} = target == 0 ? 0 : round(adjusted / {RoundUpOvershoot}) * {RoundUpOvershoot};" }); }