Skip to content

Commit

Permalink
feat: Parse out V1Status for code 422 on Reconcile loop of ManagedCon…
Browse files Browse the repository at this point in the history
…troller (#552)

Give a little better message for errors returned by k8s (at least for
code 422).

K8S api will return a V1Status when the API rejects a call. This can be
output to the users in the log
  • Loading branch information
ewassef committed Apr 14, 2023
1 parent 016dab9 commit 17147c4
Showing 1 changed file with 10 additions and 1 deletion.
@@ -1,7 +1,9 @@
using System.Reactive;
using System.Net;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using k8s;
using k8s.Autorest;
using k8s.Models;
using KubeOps.Operator.Controller.Results;
using KubeOps.Operator.DevOps;
Expand Down Expand Up @@ -128,6 +130,13 @@ protected async Task HandleResourceEvent(ResourceEvent<TEntity> resourceEvent)
return;
}
}
catch (HttpOperationException hoe) when (hoe.Response.StatusCode == HttpStatusCode.UnprocessableEntity)
{
var status = KubernetesJson.Deserialize<V1Status>(hoe.Response.Content);
_logger.LogWarning(status.Message);
RequeueError(resourceEvent, hoe);
return;
}
catch (Exception e)
{
RequeueError(resourceEvent, e);
Expand Down

0 comments on commit 17147c4

Please sign in to comment.