Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(slimfaas): scale down add log #68

Merged
merged 9 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/SlimFaas/HistorySynchronizationWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
long ticksMemory = historyHttpMemoryService.GetTicksLastCall(function.Deployment);
if (ticksInDatabase > ticksMemory)
{
logger.LogInformation("HistorySynchronizationWorker: Synchronizing history for {Function} to {Ticks} from Database", function.Deployment, ticksInDatabase);
logger.LogDebug("HistorySynchronizationWorker: Synchronizing history for {Function} to {Ticks} from Database", function.Deployment, ticksInDatabase);
historyHttpMemoryService.SetTickLastCall(function.Deployment, ticksInDatabase);
}
else if (ticksInDatabase < ticksMemory)
{
logger.LogInformation("HistorySynchronizationWorker: Synchronizing history for {Function} to {Ticks} from Memory", function.Deployment, ticksMemory);
logger.LogDebug("HistorySynchronizationWorker: Synchronizing history for {Function} to {Ticks} from Memory", function.Deployment, ticksMemory);
await historyHttpDatabaseService.SetTickLastCallAsync(function.Deployment, ticksMemory);
}
}
Expand Down
18 changes: 14 additions & 4 deletions src/SlimFaas/ReplicasService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public async Task CheckScaleAsync(string kubeNamespace)
}

var lastTicksFromSchedule = GetLastTicksFromSchedule(deploymentInformation, DateTime.UtcNow);
if (lastTicksFromSchedule > tickLastCall)
if (lastTicksFromSchedule.HasValue && lastTicksFromSchedule > tickLastCall)
{
tickLastCall = lastTicksFromSchedule.Value;
}
Expand All @@ -126,9 +126,19 @@ public async Task CheckScaleAsync(string kubeNamespace)
tickLastCall = ticksLastCall[information.Deployment];
}

bool timeElapsedWithoutRequest = TimeSpan.FromTicks(tickLastCall) +
TimeSpan.FromSeconds(GetTimeoutSecondBeforeSetReplicasMin(deploymentInformation, DateTime.UtcNow)) <
TimeSpan.FromTicks(DateTime.UtcNow.Ticks);
var timeToWaitSeconds = TimeSpan.FromSeconds(GetTimeoutSecondBeforeSetReplicasMin(deploymentInformation, DateTime.UtcNow));
bool timeElapsedWithoutRequest = (TimeSpan.FromTicks(tickLastCall) +
timeToWaitSeconds) < TimeSpan.FromTicks(DateTime.UtcNow.Ticks);

if (logger.IsEnabled(LogLevel.Debug))
{
var time = (TimeSpan.FromTicks(tickLastCall) +
timeToWaitSeconds) -
TimeSpan.FromTicks(DateTime.UtcNow.Ticks);
logger.LogDebug(
"Time left without request for scale down {Deployment} is {TimeElapsedWithoutRequest}",
deploymentInformation.Deployment, time);
}
int currentScale = deploymentInformation.Replicas;
if (timeElapsedWithoutRequest)
{
Expand Down
Loading