Skip to content

Conversation

@hhzguo
Copy link
Contributor

@hhzguo hhzguo commented May 19, 2025

  1. Update the README.doc
  2. Made changes to cluster_client.py after Dongmao's API refactoring

@thesues thesues requested a review from Copilot May 20, 2025 03:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces cluster mode support by refactoring the server to register with Consul, exposing new management endpoints, updating the configuration class, providing a cluster client example, and documenting cluster mode setup.

  • Extend server with health and service/config endpoints and CLI flags for cluster mode
  • Add host to ServerConfig and export new cluster manager classes
  • Provide an example client and update README with cluster mode instructions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
infinistore/server.py Add health/config routes, cluster-mode CLI flags, and Consul registration logic
infinistore/lib.py Include host attribute in ServerConfig
infinistore/example/cluster_client.py New example demonstrating cluster-based RDMA calls
infinistore/init.py Export ConsulClusterMgr and NoClusterMgr
README.md Document how to run the server in cluster mode
Comments suppressed due to low confidence (1)

infinistore/server.py:268

  • The variable loop is not defined in this scope. Use asyncio.get_event_loop() or capture the running event loop to schedule the refresh task.
loop.create_task(cluster_mgr.refresh_task())

"link_type": config.link_type,
"dev_name": config.dev_name,
}
return JSONResponse(status_code=200, content=json.dumps(service_conf))
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing a JSON string to JSONResponse.content will double-encode the payload. Use content=service_conf or return the dict directly so FastAPI handles serialization correctly.

Suggested change
return JSONResponse(status_code=200, content=json.dumps(service_conf))
return service_conf

Copilot uses AI. Check for mistakes.
@app.get("/health")
async def health():
Logger.info(f"Health check received at {config.host}:{config.manage_port}...")
return "Healthy", 200
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a tuple ("Healthy", 200) is not the recommended pattern in FastAPI. Return a Response or JSONResponse with an explicit status_code to ensure the status is applied.

Suggested change
return "Healthy", 200
return Response(content="Healthy", status_code=200)

Copilot uses AI. Check for mistakes.
README.md Outdated
Comment on lines 102 to 108
* ```docker run -d \```
* ``` --name=consul \```
* ``` --network=host \```
* ``` -e CONSUL_BIND_INTERFACE=eth0 \```
* ``` -e CONSUL_CLIENT_ADDR=0.0.0.0 \```
* ``` -p 8500:8500 \```
* ``` hashicorp/consul```
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code fences are opened and closed on each line, breaking the block. Use a single fenced block (```shell) around all related commands for better readability.

Suggested change
* ```docker run -d \```
* ``` --name=consul \```
* ``` --network=host \```
* ``` -e CONSUL_BIND_INTERFACE=eth0 \```
* ``` -e CONSUL_CLIENT_ADDR=0.0.0.0 \```
* ``` -p 8500:8500 \```
* ``` hashicorp/consul```
```shell
docker run -d \
--name=consul \
--network=host \
-e CONSUL_BIND_INTERFACE=eth0 \
-e CONSUL_CLIENT_ADDR=0.0.0.0 \
-p 8500:8500 \
hashicorp/consul

Copilot uses AI. Check for mistakes.
Comment on lines 39 to 41
before_sync = time.time()
print(f"sync elapse time is {time.time() - before_sync}")

Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This prints a 'sync' elapsed time without any synchronization step in between, which may confuse readers. Consider removing or clarifying this measurement.

Suggested change
before_sync = time.time()
print(f"sync elapse time is {time.time() - before_sync}")

Copilot uses AI. Check for mistakes.
@hhzguo hhzguo force-pushed the feat/cluster_mode branch from 4a29c24 to 3e672de Compare May 28, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants