From f3f1f03784b1995e9233436cb563270e3f3bff21 Mon Sep 17 00:00:00 2001 From: Avinesh Singh Date: Sat, 18 Nov 2023 20:39:23 +0530 Subject: [PATCH] Fix: Exec Process deadlock WaitForExit should have been called after all other methods are called on the process --- .../KubernetesClientConfiguration.ConfigFile.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs b/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs index e74660bc9..8a6b45dc6 100644 --- a/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs +++ b/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs @@ -537,12 +537,13 @@ public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution co try { - if (!process.WaitForExit((int)(ExecTimeout.TotalMilliseconds))) + var responseObject = KubernetesJson.Deserialize(process.StandardOutput.ReadToEnd()); + + if (!process.WaitForExit((int)ExecTimeout.TotalMilliseconds)) { throw new KubeConfigException("external exec failed due to timeout"); } - var responseObject = KubernetesJson.Deserialize(process.StandardOutput.ReadToEnd()); if (responseObject == null || responseObject.ApiVersion != config.ApiVersion) { throw new KubeConfigException(