Skip to content

Commit 17147c4

Browse files
author
Eddie
authored
feat: Parse out V1Status for code 422 on Reconcile loop of ManagedController (#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
1 parent 016dab9 commit 17147c4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/KubeOps/Operator/Controller/ManagedResourceController{TEntity}.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System.Reactive;
1+
using System.Net;
2+
using System.Reactive;
23
using System.Reactive.Concurrency;
34
using System.Reactive.Linq;
45
using k8s;
6+
using k8s.Autorest;
57
using k8s.Models;
68
using KubeOps.Operator.Controller.Results;
79
using KubeOps.Operator.DevOps;
@@ -128,6 +130,13 @@ protected async Task HandleResourceEvent(ResourceEvent<TEntity> resourceEvent)
128130
return;
129131
}
130132
}
133+
catch (HttpOperationException hoe) when (hoe.Response.StatusCode == HttpStatusCode.UnprocessableEntity)
134+
{
135+
var status = KubernetesJson.Deserialize<V1Status>(hoe.Response.Content);
136+
_logger.LogWarning(status.Message);
137+
RequeueError(resourceEvent, hoe);
138+
return;
139+
}
131140
catch (Exception e)
132141
{
133142
RequeueError(resourceEvent, e);

0 commit comments

Comments
 (0)