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

feat(slimfaas): call only at least when one pod is read #19

Merged
merged 31 commits into from
Jul 3, 2023

Conversation

guillaume-chervet
Copy link
Collaborator

@guillaume-chervet guillaume-chervet commented Jun 26, 2023

#16

Now we wait at least one pod is in started state before doing the first HTTP try.

@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 26, 2023 14:23 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 26, 2023 14:23 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 26, 2023 14:48 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 26, 2023 14:48 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 26, 2023 15:24 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 26, 2023 15:24 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 10:05 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 10:05 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 12:00 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 12:00 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 13:58 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 13:58 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 14:04 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 14:04 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 14:39 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 14:39 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 15:11 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 15:11 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 15:17 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 27, 2023 15:17 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 28, 2023 13:20 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 28, 2023 13:20 — with GitHub Actions Inactive
@g7ed6e
Copy link
Contributor

g7ed6e commented Jun 28, 2023

please squash or rewrite the git history when time to merge comes.

@@ -18,7 +18,7 @@ public class HistorySynchronizationWorker: BackgroundService
_historyHttpMemoryService = historyHttpMemoryService;
_historyHttpRedisService = historyHttpRedisService;
_logger = logger;
_delay = delay;
_delay = int.Parse(Environment.GetEnvironmentVariable("HISTORY_SYNCHRONISATION_WORKER_DELAY_MILLISECONDS") ?? delay.ToString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't int.Parse throwing with null or empty values ? i would sugget using TryParse here

@@ -56,13 +65,13 @@ public KubernetesService(IConfiguration config, ILogger<KubernetesService> logge
try
{
using var client = new Kubernetes(_k8SConfig);
var patchString = "{\"spec\": {\"replicas\": " + request.Replicas + "}}";
var patchString = $"{{\"spec\": {{\"replicas\": {request?.Replicas}}}}}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if request is null it will output null in the json string

var patch = new V1Patch(patchString, V1Patch.PatchType.MergePatch);
await client.PatchNamespacedDeploymentScaleAsync(patch, request.Deployment, request.Namespace);
await client.PatchNamespacedDeploymentScaleAsync(patch, request?.Deployment, request?.Namespace);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should client.PatchNamespacedDeploymentScaleAsync be called when request is null ?

src/SlimFaas/Kubernetes/KubernetesService.cs Outdated Show resolved Hide resolved
@@ -142,4 +157,43 @@ public async Task<DeploymentsInformations> ListFunctionsAsync(string kubeNamespa
}
}

private static IList<PodInformation> MapPodInformations(V1PodList list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we could return IEnumerable and yield return filetred results. The caller would call .ToList to get the List already filtered

@@ -27,6 +28,7 @@ public record DeploymentsInformations
public record DeploymentInformation
{
public string Deployment { get; set; }
public IList<PodInformation>? Pods { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should enable add <WarningsAsErrors>Nullable</WarningsAsErrors> in csproj files to enforce correct usage/handling of NRT

@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 08:41 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 08:41 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 09:09 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 09:09 — with GitHub Actions Inactive
@sonarcloud
Copy link

sonarcloud bot commented Jun 30, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 09:17 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 09:17 — with GitHub Actions Inactive
@guillaume-chervet
Copy link
Collaborator Author

Pour le merge je ferais un squash merge

@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 12:06 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 12:06 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 15:01 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython June 30, 2023 15:01 — with GitHub Actions Inactive
public static class EnvironmentVariables
{

public static int ReadInteger<T>(ILogger<T> logger, string environmentVariableName, int defaultDelay)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultDelay => defaultValue

public static class EnvironmentVariables
{

public static int ReadInteger<T>(ILogger<T> logger, string environmentVariableName, int defaultDelay)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks strange to pass ILogger here. I would suggest something like
TryReadInteger(string environmentVariable, out int value).
The caller would interpret a false result to apply the correct default value and use its own ILogger instance.

foreach (var function in Deployments.Functions)
{
var updatedFunction = tasks.FirstOrDefault(t => t.Result.Deployment == function.Deployment);
updatedFunctions.Add(function with { Replicas = updatedFunction != null ? updatedFunction.Result.Replicas : function.Replicas });
var updatedFunction = tasks.Find(t => t.Result?.Deployment == function.Deployment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this foreach loop .Result Task property is accessed. The may cause deadlocks. We should have the following code before entering this loop.

ReplicaRequest?[] replicaResuests = await Task.WhenAll(tasks);

and loop through this array.

@@ -12,19 +13,17 @@ public async Task SyncLastTicksBetweenDatabaseAndMemory()
var redisMockService = new RedisMockService();
var historyHttpRedisService = new HistoryHttpRedisService(redisMockService);
var kubernetesService = new Mock<IKubernetesService>();
var deploymentsInformations = new DeploymentsInformations()
var deploymentsInformations = new DeploymentsInformations(Functions: new List<DeploymentInformation>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks weird to pass an empty list here, i think DeploymentsInformations should:

  • be renamed DeploymentInformation
  • initialize its own porperties internally

@@ -39,10 +38,10 @@ public async Task SyncLastTicksBetweenDatabaseAndMemory()
await Task.Delay(200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a lot of magic values that should either be centralized somewhere (a static class with const) or moved as const of the type they belong to.

@@ -1,22 +1,24 @@
using System.Collections;
using Microsoft.Extensions.Logging;
using Moq;
using SlimFaas.Kubernetes;

namespace SlimFaas.Tests;

public class DeploymentsTestData:IEnumerable<object[]>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another option to get strongly types is to inherit from TheoryData. Then in the constructor, just call Add() to add tests iterations. This allow to remove the noise of object[].

@guillaume-chervet guillaume-chervet merged commit 5c5a1f3 into main Jul 3, 2023
1 check passed
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython July 3, 2023 13:51 — with GitHub Actions Inactive
@guillaume-chervet guillaume-chervet temporarily deployed to MLOpsPython July 3, 2023 13:51 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants