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

Kubernetes debugging #1975

Merged
merged 2 commits into from
Apr 26, 2023
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/Proto.Cluster.Kubernetes/KubernetesClusterMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ private void Watch(WatchEventType eventType, V1Pod eventPod)

var memberStatuses = _clusterPods.Values
.Select(x => x.GetMemberStatus())
.Where(x => x.IsCandidate)
.Select(x => x.Status)
.Where(x => x.IsRunning && x.IsReady)
.Select(x => x.Member)
.ToList();

Logger.Log(_config.DebugLogLevel, "[Cluster][KubernetesProvider] Topology received from Kubernetes {Members}",
Expand Down
10 changes: 6 additions & 4 deletions src/Proto.Cluster.Kubernetes/KubernetesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ IDictionary<string, string> annotations
/// </summary>
/// <param name="pod">Kubernetes Pod object</param>
/// <returns></returns>
internal static (bool IsCandidate, bool IsAlive, Member Status) GetMemberStatus(this V1Pod pod)
internal static MemberStatus GetMemberStatus(this V1Pod pod)
{
var isCandidate = pod.Status.Phase == "Running" && pod.Status.PodIP is not null;
var isRunning = pod.Status.Phase == "Running" && pod.Status.PodIP is not null;

var kinds = pod
.Metadata
Expand All @@ -73,7 +73,7 @@ internal static (bool IsCandidate, bool IsAlive, Member Status) GetMemberStatus(
var mid = pod.Metadata.Labels[LabelMemberId];
var alive = pod.Status.ContainerStatuses.All(x => x.Ready);

return (isCandidate, alive,
return new MemberStatus(isRunning, alive,
new Member
{
Id = mid,
Expand Down Expand Up @@ -111,4 +111,6 @@ internal static string GetKubeNamespace()
/// </summary>
/// <returns></returns>
internal static string GetPodName() => Environment.MachineName;
}
}

public record MemberStatus(bool IsRunning, bool IsReady, Member Member);