Bug fixes to enable timer_workers running properly (#2343)

Co-authored-by: stas <statis@microsoft.com>
This commit is contained in:
Stas 2022-09-06 09:13:33 -07:00 committed by GitHub
parent e7abd2d8fa
commit dd3aa1ce0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -23,6 +23,7 @@ public class AgentCanSchedule {
private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
var request = await RequestHandling.ParseRequest<CanScheduleRequest>(req);
if (!request.IsOk) {
_log.Warning($"Cannot schedule due to {request.ErrorV}");
return await _context.RequestHandling.NotOk(req, request.ErrorV, typeof(CanScheduleRequest).ToString());
}
@ -30,6 +31,7 @@ public class AgentCanSchedule {
var node = await _context.NodeOperations.GetByMachineId(canScheduleRequest.MachineId);
if (node == null) {
_log.Warning($"Unable to find node {canScheduleRequest.MachineId}");
return await _context.RequestHandling.NotOk(
req,
new Error(
@ -50,11 +52,16 @@ public class AgentCanSchedule {
var workStopped = task == null || task.State.ShuttingDown();
if (workStopped) {
_log.Info($"Work stopped {canScheduleRequest.MachineId}");
allowed = false;
}
if (allowed) {
allowed = (await _context.NodeOperations.AcquireScaleInProtection(node)).IsOk;
var scp = await _context.NodeOperations.AcquireScaleInProtection(node);
if (!scp.IsOk) {
_log.Warning($"Failed to acquire scale in protection due to {scp.ErrorV}");
}
allowed = scp.IsOk;
}
return await RequestHandling.Ok(req, new CanSchedule(Allowed: allowed, WorkStopped: workStopped));

View File

@ -142,7 +142,7 @@ public class ScalesetOperations : StatefulOrm<Scaleset, ScalesetState, ScalesetO
);
}
return scaleset;
return updatedScaleSet;
}
async Async.Task<Scaleset> SetFailed(Scaleset scaleset, Error error) {

View File

@ -53,7 +53,7 @@ public class Scheduler : IScheduler {
var notReadyCount = tasks.Count - seen.Count;
if (notReadyCount > 0) {
_logTracer.Info($"tasks not ready {notReadyCount}");
_logTracer.Info($"tasks not ready {notReadyCount}. Tasks seen: {seen.Count}");
}
}