Better logging of k8s exceptions

This commit is contained in:
benbierens 2023-10-23 15:49:14 +02:00
parent 2fae9505d6
commit abb9560b6d
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 26 additions and 9 deletions

View File

@ -1,4 +1,5 @@
using Logging;
using Newtonsoft.Json;
using Utils;
namespace KubernetesWorkflow
@ -195,17 +196,33 @@ namespace KubernetesWorkflow
private void K8s(Action<K8sController> action)
{
var controller = new K8sController(log, cluster, knownK8SPods, numberSource, k8sNamespace);
action(controller);
controller.Dispose();
try
{
var controller = new K8sController(log, cluster, knownK8SPods, numberSource, k8sNamespace);
action(controller);
controller.Dispose();
}
catch (k8s.Autorest.HttpOperationException ex)
{
log.Error(JsonConvert.SerializeObject(ex));
throw;
}
}
private T K8s<T>(Func<K8sController, T> action)
{
var controller = new K8sController(log, cluster, knownK8SPods, numberSource, k8sNamespace);
var result = action(controller);
controller.Dispose();
return result;
try
{
var controller = new K8sController(log, cluster, knownK8SPods, numberSource, k8sNamespace);
var result = action(controller);
controller.Dispose();
return result;
}
catch (k8s.Autorest.HttpOperationException ex)
{
log.Error(JsonConvert.SerializeObject(ex));
throw;
}
}
}

View File

@ -33,9 +33,9 @@ namespace CodexContractsPlugin
{
return DeployContract(container, workflow, gethNode);
}
catch
catch (Exception ex)
{
Log("Failed to deploy contract.");
Log("Failed to deploy contract: " + ex);
Log("Downloading Codex SmartContracts container log...");
ci.DownloadLog(container);
throw;