You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/08 03:04:02 UTC

[GitHub] [flink-kubernetes-operator] Aitozi commented on a change in pull request #45: [FLINK-26508] Webhook should only validate on /validate endpoint end log errors for others

Aitozi commented on a change in pull request #45:
URL: https://github.com/apache/flink-kubernetes-operator/pull/45#discussion_r821282554



##########
File path: flink-kubernetes-webhook/src/main/java/org/apache/flink/kubernetes/operator/admission/AdmissionHandler.java
##########
@@ -66,15 +70,25 @@ public AdmissionHandler(Validator<GenericKubernetesResource> validator) {
 
     @Override
     protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest) {
-        final ByteBuf msgContent = ((FullHttpRequest) httpRequest).content();
-        AdmissionReview review;
-        try {
-            InputStream in = new ByteBufInputStream(msgContent);
-            review = objectMapper.readValue(in, AdmissionReview.class);
-            AdmissionReview response = validatingController.handle(review);
-            sendResponse(ctx, objectMapper.writeValueAsString(response));
-        } catch (Exception e) {
-            sendError(ctx, ExceptionUtils.getStackTrace(e));
+        QueryStringDecoder decoder = new QueryStringDecoder(httpRequest.uri());
+        String path = decoder.path();
+        if ("/validate".equals(path)) {

Review comment:
       nit: could make `/validate` static and reuse it in the error msg :)

##########
File path: flink-kubernetes-webhook/src/main/java/org/apache/flink/kubernetes/operator/admission/AdmissionHandler.java
##########
@@ -66,15 +70,25 @@ public AdmissionHandler(Validator<GenericKubernetesResource> validator) {
 
     @Override
     protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest) {
-        final ByteBuf msgContent = ((FullHttpRequest) httpRequest).content();
-        AdmissionReview review;
-        try {
-            InputStream in = new ByteBufInputStream(msgContent);
-            review = objectMapper.readValue(in, AdmissionReview.class);
-            AdmissionReview response = validatingController.handle(review);
-            sendResponse(ctx, objectMapper.writeValueAsString(response));
-        } catch (Exception e) {
-            sendError(ctx, ExceptionUtils.getStackTrace(e));
+        QueryStringDecoder decoder = new QueryStringDecoder(httpRequest.uri());
+        String path = decoder.path();
+        if ("/validate".equals(path)) {

Review comment:
       nit: could make `/validate` static and reuse it in the error msg :)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org