lablup / lablup/backend.ai

Fix hardcoded advertise_address in app proxy coordinator status endpoint

Open
#6,622 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Problem

The `/status` endpoint in the app proxy coordinator returns a hardcoded `advertise_address` value instead of using the configured `announce_addr` from the server configuration.

**Current Code** (`server.py:736`):

```python
async def status(request: web.Request) -> web.Response:
request["do_not_print_access_log"] = True
return web.json_response({"api_version": "v2", "advertise_address": "http://10.100.6.113:10200"})
```

**Expected Behavior**:
The endpoint should return the dynamically configured address from `local_config.proxy_coordinator.announce_addr` instead of the hardcoded value.

## Configuration Available

The configuration already has the proper field defined in `ProxyCoordinatorConfig`:

- `announce_addr`: HostPortPair field for manually setting the announced address for service discovery

## Impact

- The hardcoded address prevents proper service discovery in different deployment environments
- Configuration changes to `announce_addr` are ignored
- This breaks dynamic deployment scenarios where the coordinator address varies

## Suggested Fix

Replace the hardcoded value with the configured `announce_addr`:

```python
async def status(request: web.Request) -> web.Response:
request["do_not_print_access_log"] = True
root_ctx: RootContext = request.app["_root.context"]
announce_addr = root_ctx.local_config.proxy_coordinator.announce_addr
protocol = "https" if root_ctx.local_config.proxy_coordinator.tls_advertised else "http"
advertise_address = f"{protocol}://{announce_addr}"
return web.json_response({"api_version": "v2", "advertise_address": advertise_address})
```

## Files to Modify

- `src/ai/backend/appproxy/coordinator/server.py` (line 736)

JIRA Issue: BA-2951

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.