Skip to content

Commit

Permalink
fix(slimfaas): log kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet committed Jan 14, 2025
1 parent eaed9fb commit 83500bf
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/SlimFaas/Kubernetes/KubernetesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,6 @@ public async Task<DeploymentsInformations> ListFunctionsAsync(string kubeNamespa
}
}

private static IList<int> ReadRetryAnnotation( IDictionary<string, string>? annotations)
{
if (annotations != null && annotations.TryGetValue(AsynchrounousRetry, out string? valueAsynchrounousRetry))
{
var result = new List<int>();
var array = valueAsynchrounousRetry.Split(';');
foreach (string s in array)
{
result.Add( int.Parse(s, NumberStyles.Integer));
}

return result;
}

return new List<int>(){2, 4, 8};
}

private static async Task AddDeployments(string kubeNamespace, V1DeploymentList deploymentList, IEnumerable<PodInformation> podList,
IList<DeploymentInformation> deploymentInformationList, ILogger<KubernetesService> logger, k8s.Kubernetes client , IList<DeploymentInformation> previousDeploymentInformationList)
{
Expand All @@ -267,7 +250,7 @@ private static async Task AddDeployments(string kubeNamespace, V1DeploymentList
ScheduleConfig? scheduleConfig = GetScheduleConfig(annotations, name, logger);
SlimFaasConfiguration configuration = GetConfiguration(annotations, name, logger);
var previousDeployment = previousDeploymentInformationList.FirstOrDefault(d => d.Deployment == name);
bool endpointReady = await GetEndpointReady(kubeNamespace, client, previousDeployment, name, pods);
bool endpointReady = await GetEndpointReady(logger, kubeNamespace, client, previousDeployment, name, pods);
var resourceVersion = $"{deploymentListItem.Metadata.ResourceVersion}-{endpointReady}";
if (previousDeployment != null && previousDeployment.ResourceVersion == resourceVersion)
{
Expand Down Expand Up @@ -320,7 +303,7 @@ private static async Task AddDeployments(string kubeNamespace, V1DeploymentList
}
}

private static async Task<bool> GetEndpointReady(string kubeNamespace, k8s.Kubernetes client,
private static async Task<bool> GetEndpointReady(ILogger<KubernetesService> logger, string kubeNamespace, k8s.Kubernetes client,
DeploymentInformation? previousDeployment, string name, List<PodInformation> pods)
{
try
Expand Down Expand Up @@ -349,7 +332,7 @@ private static async Task<bool> GetEndpointReady(string kubeNamespace, k8s.Kuber
}
catch (Exception e)
{
Console.WriteLine(e);
logger.LogDebug("Error while getting endpoint ready {Name} : {Exception}", name, e.ToString());
}
return false;
}
Expand Down Expand Up @@ -407,7 +390,7 @@ private static async Task AddStatefulSets(string kubeNamespace, V1StatefulSetLis
ScheduleConfig? scheduleConfig = GetScheduleConfig(annotations, name, logger);
SlimFaasConfiguration configuration = GetConfiguration(annotations, name, logger);
var previousDeployment = previousDeploymentInformationList.FirstOrDefault(d => d.Deployment == name);
bool endpointReady = await GetEndpointReady(kubeNamespace, client, previousDeployment, name, pods);
bool endpointReady = await GetEndpointReady(logger, kubeNamespace, client, previousDeployment, name, pods);
var resourceVersion = $"{deploymentListItem.Metadata.ResourceVersion}-{endpointReady}";
if (previousDeployment != null && previousDeployment.ResourceVersion == resourceVersion)
{
Expand Down

0 comments on commit 83500bf

Please sign in to comment.