This is an automated email from the ASF dual-hosted git repository.
rexxiong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git
The following commit(s) were added to refs/heads/main by this push:
new 48910bb35 [CELEBORN-1553] Using the request base url as swagger server
48910bb35 is described below
commit 48910bb35709d7adbb22fc5cadfd26fb5e619b3b
Author: Wang, Fei <[email protected]>
AuthorDate: Wed Sep 4 00:06:04 2024 +0800
[CELEBORN-1553] Using the request base url as swagger server
### What changes were proposed in this pull request?
Using the request base url as swagger server, to prevent the swagger server
not reachable and `CORS` error if the swagger server urls do not match.
Currently, if the http host is bound to local, the swagger server is not
reachable.
For example:
```
celeborn.master.http.host=0.0.0.0
celeborn.worker.http.host=0.0.0.0
```
### Why are the changes needed?

### Does this PR introduce _any_ user-facing change?
No, just use the request base url as swagger server.
### How was this patch tested?
Integration testing:
<img width="1483" alt="image"
src="https://github.com/user-attachments/assets/f8465bcb-a266-4532-9f11-52e9374c56a5">
<img width="1423" alt="image"
src="https://github.com/user-attachments/assets/84eacd86-7ba3-4f14-907b-6d529c6e0e28">
Closes #2674 from turboFei/swagger_server.
Authored-by: Wang, Fei <[email protected]>
Signed-off-by: Shuang <[email protected]>
---
.../celeborn/server/common/http/api/CelebornOpenApiResource.scala | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git
a/service/src/main/scala/org/apache/celeborn/server/common/http/api/CelebornOpenApiResource.scala
b/service/src/main/scala/org/apache/celeborn/server/common/http/api/CelebornOpenApiResource.scala
index 36862d2b3..84be2dbc1 100644
---
a/service/src/main/scala/org/apache/celeborn/server/common/http/api/CelebornOpenApiResource.scala
+++
b/service/src/main/scala/org/apache/celeborn/server/common/http/api/CelebornOpenApiResource.scala
@@ -60,7 +60,7 @@ class CelebornOpenApiResource extends BaseOpenApiResource
with ApiRequestContext
.ctxId(ctxId)
.buildContext(true)
- val openApi = setCelebornOpenAPIDefinition(ctx.read())
+ val openApi = setCelebornOpenAPIDefinition(ctx.read(),
uriInfo.getBaseUri.toString)
if (StringUtils.isNotBlank(tpe) && tpe.trim().equalsIgnoreCase("yaml")) {
Response.status(Response.Status.OK)
@@ -81,9 +81,9 @@ class CelebornOpenApiResource extends BaseOpenApiResource
with ApiRequestContext
}
}
- private def setCelebornOpenAPIDefinition(openApi: OpenAPI): OpenAPI = {
+ private def setCelebornOpenAPIDefinition(openApi: OpenAPI, requestBaseUrl:
String): OpenAPI = {
// TODO: to improve when https is enabled.
- val apiUrl = s"http://${httpService.connectionUrl}/"
+ val apiUrls = List(requestBaseUrl,
s"http://${httpService.connectionUrl}/").distinct
openApi.info(
new Info().title(
s"Apache Celeborn REST API Documentation")
@@ -91,7 +91,7 @@ class CelebornOpenApiResource extends BaseOpenApiResource
with ApiRequestContext
.license(
new License().name("Apache License 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0.txt")))
- .servers(List(new Server().url(apiUrl)).asJava)
+ .servers(apiUrls.map(url => new Server().url(url)).asJava)
.components(Option(openApi.getComponents).getOrElse(new Components())
.addSecuritySchemes(
"BasicAuth",