You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dongjoon-hyun (via GitHub)" <gi...@apache.org> on 2025/09/19 19:04:31 UTC
[PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
dongjoon-hyun opened a new pull request, #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327
…
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, use `Draft` feature of GitHub Action.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If there is design documentation, please add the link.
3. If there is a discussion in the mailing list, please add the link.
-->
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327#discussion_r2364225647
##########
spark-operator/src/test/java/org/apache/spark/k8s/operator/metrics/source/KubernetesMetricsInterceptorTest.java:
##########
@@ -122,7 +122,7 @@ void testWhenKubernetesServerNotWorking() {
Map<String, Metric> map = metricsInterceptor.metricRegistry().getMetrics();
Assertions.assertEquals(12, map.size());
Meter metric = (Meter) map.get("failed");
- Assertions.assertEquals(metric.getCount(), retry + 1);
+ Assertions.assertEquals(metric.getCount(), retry);
Review Comment:
New value is correct and reasonable.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327#issuecomment-3313563878
Could you review this important migration PR when you have some time, @viirya , @peter-toth , @jiangzho ?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327#issuecomment-3320795306
Thank you, @peter-toth . Ya, I reused the existing method assumption to narrow down the scope during this migration.
Since we successfully migrated, let's split it like your advice. I'll make a new PR for that.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327#issuecomment-3313664732
Thank you, @viirya .
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #327: [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor`
URL: https://github.com/apache/spark-kubernetes-operator/pull/327
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327#issuecomment-3313647113
Rebase to the `main` branch once more.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327#issuecomment-3313679615
Merged to main.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53647][SPARK-53648] Use `VertxHttpClientFactory` and `io.fabric8.kubernetes.client.http.Interceptor` [spark-kubernetes-operator]
Posted by "peter-toth (via GitHub)" <gi...@apache.org>.
peter-toth commented on code in PR #327:
URL: https://github.com/apache/spark-kubernetes-operator/pull/327#discussion_r2366142941
##########
spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/source/KubernetesMetricsInterceptor.java:
##########
@@ -90,25 +88,62 @@ public KubernetesMetricsInterceptor() {
}
/**
- * Intercepts an HTTP request and updates Kubernetes client metrics.
+ * Called before a request to allow for the manipulation of the request
*
- * @param chain The Interceptor.Chain for the current request.
- * @return The Response from the intercepted request.
- * @throws IOException if an I/O error occurs during the request.
+ * @param builder used to modify the request
+ * @param request the current request
*/
- @NotNull
@Override
- public Response intercept(@NotNull Chain chain) throws IOException {
- Request request = chain.request();
+ public void before(BasicBuilder builder, HttpRequest request, RequestTags tags) {
updateRequestMetrics(request);
- Response response = null;
- final long startTime = System.nanoTime();
- try {
- response = chain.proceed(request);
- return response;
- } finally {
- updateResponseMetrics(response, startTime);
- }
+ }
+
+ /**
+ * Called after a non-WebSocket HTTP response is received. The body might or might not be already
+ * consumed.
+ *
+ * <p>Should be used to analyze response codes and headers, original response shouldn't be
+ * altered.
+ *
+ * @param request the original request sent to the server.
+ * @param response the response received from the server.
+ */
+ @Override
+ public void after(
+ HttpRequest request,
+ HttpResponse<?> response,
+ AsyncBody.Consumer<List<ByteBuffer>> consumer) {
+ updateResponseMetrics(response, System.nanoTime());
+ }
+
+ /**
+ * Called after a websocket failure or by default from a normal request.
+ *
+ * <p>Failure is determined by HTTP status code and will be invoked in addition to {@link
+ * Interceptor#after(HttpRequest, HttpResponse, AsyncBody.Consumer)}
+ *
+ * @param builder used to modify the request
+ * @param response the failed response
+ * @return true if the builder should be used to execute a new request
+ */
+ @Override
+ public CompletableFuture<Boolean> afterFailure(
+ BasicBuilder builder, HttpResponse<?> response, RequestTags tags) {
+ updateResponseMetrics(null, System.nanoTime());
+ return CompletableFuture.completedFuture(false);
Review Comment:
Just a nit that now that the new `Interceptor` has sepated success (`after()`) and failure (`afterFailure()`, `afterConnectionFailure()`) handling methods, it might make sense to split our `updateResponseMetrics()` method as well. It seems a bit weird that we explicitely pass `null` and `System.nanoTime()`, which is then never used inside `updateResponseMetrics()`.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org