[BUG] Preflight check - server attempts to bind to DNS name instead of localhost
Describe the bug When running the preflight_check on a provisioned server startup kit downloaded from the dashboard, the server attempts (and files) to bind its grpc and admin ports to the server DNS name rather than binding to localhost.
This happens when the DNS name configured for the server is to a load balancer rather than the server machine directly (have not tested whether it happens without a load balancer).
A workaround is to modify the /etc/hosts file on this machine to map 0.0.0.0 to the server DNS name.
To Reproduce Steps to reproduce the behavior:
- Go to dashboard
- Log in or register as an Org Admin
- Enter project configuration and application configuration
- Go to Server Configuration
- Enter the Server DNS name as the load balancer DNS name
- Enable HA and enter an Overseer DNS name
- Go to Project Home and Freeze the project
- Go to Downloads and download the overseer and server startup kits
- Launch the overseer kit using
./overseer/startup/start.sh - Run the preflight_check on the server using
nvflare preflight_check -p server/ - Observe the errors in "check grpc port binding" and "check admin port binding":
Can't bind to address (address:8003): [Errno 99] Cannot assign requested address - Launch the server startup kit using
./server/startup/start.sh - Observe the server runs successfully
- (Optional) Modify the server/startup/fed_server.json and replace the hostname occurrences under
servers[0].service.targetandserver[0].admin_hostwith "0.0.0.0" or "localhost" -- the preflight check will now pass but the dry run/actual execution of the startup kit will understandably complain that the fed_server.json file has been modified - Edit the /etc/hosts file to add a mapping of the DNS name to localhost using
echo '0.0.0.0 server.hostname' >> /etc/hosts - Observe the preflight_check now passes
Expected behavior The preflight check should pass on a freshly downloaded server startup kit without needing to manually modify the fed_server.json or /etc/hosts file.
Screenshots
Checking Package: server
-------------------------------------------------------------------------------------------------------------------------------------------------------
| Checks | Problems | How to fix |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Check overseer running | PASSED | N/A |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Check grpc port binding | Can't bind to address | Please check the DNS and port. |
| | (server.hostname:8003): [Errno 99] Cannot assign requested address | |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Check admin port binding | Can't bind to address | Please check the DNS and port. |
| | (server.hostname:8003): [Errno 99] Cannot assign requested address | |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Check snapshot storage writable | PASSED | N/A |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Check job storage writable | PASSED | N/A |
-------------------------------------------------------------------------------------------------------------------------------------------------------
Desktop (please complete the following information):
- OS: 20.04
- Python Version: 3.8.12
- NVFlare Version: 2.2.1
Additional context
- Using startup kits downloaded from the dashboard on the latest nvflare/nvflare image, launched with
nvflare dashboard -p 8008 --start - The DNS name we're using is for a load balancer in front of the server rather than for the server machine itself
@parkeraddison thanks for reporting, we will take a look. @YuanTingHsieh, can you check this ?
Thanks for the good report. The suggestion makes sense to me. I will work on this.
Fixed in #1234
@parkeraddison this code is also patched in 2.2 branch as well as main (latest stable) branch, the new pypi wheel version 2.2.5 (https://pypi.org/project/nvflare/) also updated