Skip to content

Commit a0c5bc6

Browse files
authored
fix: localnet status and proxy dns issue (#525)
1 parent 946c53a commit a0c5bc6

16 files changed

+124
-443
lines changed

src/algokit/cli/localnet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def reset_localnet(*, update: bool) -> None:
210210
sandbox.up()
211211

212212

213-
SERVICE_NAMES = ("algod", "conduit", "indexer-db", "indexer")
213+
SERVICE_NAMES = ("algod", "conduit", "indexer-db", "indexer", "proxy")
214214

215215

216216
@localnet_group.command("status", short_help="Check the status of the AlgoKit LocalNet.")
@@ -237,10 +237,10 @@ def localnet_status() -> None:
237237
}
238238
# fill out remaining output_by_name["algod"] values
239239
if output_by_name["algod"]["Status"] == "Running":
240-
output_by_name["algod"].update(fetch_algod_status_data(ps_by_name["algod"]))
240+
output_by_name["algod"].update(fetch_algod_status_data(ps_by_name["proxy"]))
241241
# fill out remaining output_by_name["indexer"] values
242242
if output_by_name["indexer"]["Status"] == "Running":
243-
output_by_name["indexer"].update(fetch_indexer_status_data(ps_by_name["indexer"]))
243+
output_by_name["indexer"].update(fetch_indexer_status_data(ps_by_name["proxy"]))
244244

245245
# Print the status details
246246
for service_name, service_info in output_by_name.items():

src/algokit/core/sandbox.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -443,38 +443,24 @@ def get_proxy_config(algod_port: int = DEFAULT_ALGOD_PORT, kmd_port: int = 4002)
443443
http {{
444444
access_log off;
445445
446+
resolver 127.0.0.11 ipv6=off valid=10s;
447+
resolver_timeout 5s;
448+
446449
map $request_method$http_access_control_request_private_network $cors_allow_private_network {{
447450
"OPTIONStrue" "true";
448451
default "";
449452
}}
450453
451454
add_header Access-Control-Allow-Private-Network $cors_allow_private_network;
452455
453-
upstream algod_api {{
454-
zone upstreams 64K;
455-
server algod:8080 max_fails=1 fail_timeout=2s;
456-
keepalive 2;
457-
}}
458-
459-
upstream kmd_api {{
460-
zone upstreams 64K;
461-
server algod:7833 max_fails=1 fail_timeout=2s;
462-
keepalive 2;
463-
}}
464-
465-
upstream indexer_api {{
466-
zone upstreams 64K;
467-
server indexer:8980 max_fails=1 fail_timeout=2s;
468-
keepalive 2;
469-
}}
470-
471456
server {{
472457
listen {algod_port};
473458
474459
location / {{
475460
proxy_set_header Host $host;
476-
proxy_pass http://algod_api;
477461
proxy_pass_header Server;
462+
set $target http://algod:8080;
463+
proxy_pass $target;
478464
}}
479465
}}
480466
@@ -483,8 +469,9 @@ def get_proxy_config(algod_port: int = DEFAULT_ALGOD_PORT, kmd_port: int = 4002)
483469
484470
location / {{
485471
proxy_set_header Host $host;
486-
proxy_pass http://kmd_api;
487472
proxy_pass_header Server;
473+
set $target http://algod:7833;
474+
proxy_pass $target;
488475
}}
489476
}}
490477
@@ -493,8 +480,9 @@ def get_proxy_config(algod_port: int = DEFAULT_ALGOD_PORT, kmd_port: int = 4002)
493480
494481
location / {{
495482
proxy_set_header Host $host;
496-
proxy_pass http://indexer_api;
497483
proxy_pass_header Server;
484+
set $target http://indexer:8980;
485+
proxy_pass $target;
498486
}}
499487
}}
500488
}}
@@ -514,8 +502,6 @@ def get_docker_compose_yml(
514502
container_name: "{name}_algod"
515503
image: {ALGORAND_IMAGE}
516504
ports:
517-
- 8080
518-
- 7833
519505
- {tealdbg_port}:9392
520506
environment:
521507
START_KMD: 1
@@ -559,8 +545,6 @@ def get_docker_compose_yml(
559545
indexer:
560546
container_name: "{name}_indexer"
561547
image: {INDEXER_IMAGE}
562-
ports:
563-
- 8980
564548
restart: unless-stopped
565549
command: daemon --enable-all-parameters
566550
environment:
@@ -635,7 +619,7 @@ def fetch_indexer_status_data(service_info: dict[str, Any]) -> dict[str, Any]:
635619
if not any(item["PublishedPort"] == DEFAULT_INDEXER_PORT for item in service_info["Publishers"]):
636620
return {"Status": "Error"}
637621

638-
results["Port"] = service_info["Publishers"][0]["PublishedPort"]
622+
results["Port"] = DEFAULT_INDEXER_PORT
639623
# container specific response
640624
health_url = f"{DEFAULT_ALGOD_SERVER}:{DEFAULT_INDEXER_PORT}/health"
641625
http_response = httpx.get(health_url, timeout=5)

tests/localnet/test_localnet_reset.test_localnet_reset_with_existing_sandbox_with_out_of_date_config.approved.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ services:
3333
container_name: "algokit_sandbox_algod"
3434
image: algorand/algod:latest
3535
ports:
36-
- 8080
37-
- 7833
3836
- 9392:9392
3937
environment:
4038
START_KMD: 1
@@ -78,8 +76,6 @@ services:
7876
indexer:
7977
container_name: "algokit_sandbox_indexer"
8078
image: algorand/indexer:latest
81-
ports:
82-
- 8980
8379
restart: unless-stopped
8480
command: daemon --enable-all-parameters
8581
environment:

tests/localnet/test_localnet_reset.test_localnet_reset_without_existing_sandbox.approved.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ services:
2525
container_name: "algokit_sandbox_algod"
2626
image: algorand/algod:latest
2727
ports:
28-
- 8080
29-
- 7833
3028
- 9392:9392
3129
environment:
3230
START_KMD: 1
@@ -70,8 +68,6 @@ services:
7068
indexer:
7169
container_name: "algokit_sandbox_indexer"
7270
image: algorand/indexer:latest
73-
ports:
74-
- 8980
7571
restart: unless-stopped
7672
command: daemon --enable-all-parameters
7773
environment:

tests/localnet/test_localnet_start.test_localnet_start.approved.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ services:
3131
container_name: "algokit_sandbox_algod"
3232
image: algorand/algod:latest
3333
ports:
34-
- 8080
35-
- 7833
3634
- 9392:9392
3735
environment:
3836
START_KMD: 1
@@ -76,8 +74,6 @@ services:
7674
indexer:
7775
container_name: "algokit_sandbox_indexer"
7876
image: algorand/indexer:latest
79-
ports:
80-
- 8980
8177
restart: unless-stopped
8278
command: daemon --enable-all-parameters
8379
environment:

tests/localnet/test_localnet_start.test_localnet_start_health_bad_status.approved.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ services:
3131
container_name: "algokit_sandbox_algod"
3232
image: algorand/algod:latest
3333
ports:
34-
- 8080
35-
- 7833
3634
- 9392:9392
3735
environment:
3836
START_KMD: 1
@@ -76,8 +74,6 @@ services:
7674
indexer:
7775
container_name: "algokit_sandbox_indexer"
7876
image: algorand/indexer:latest
79-
ports:
80-
- 8980
8177
restart: unless-stopped
8278
command: daemon --enable-all-parameters
8379
environment:

tests/localnet/test_localnet_start.test_localnet_start_health_failure.approved.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ services:
3030
container_name: "algokit_sandbox_algod"
3131
image: algorand/algod:latest
3232
ports:
33-
- 8080
34-
- 7833
3533
- 9392:9392
3634
environment:
3735
START_KMD: 1
@@ -75,8 +73,6 @@ services:
7573
indexer:
7674
container_name: "algokit_sandbox_indexer"
7775
image: algorand/indexer:latest
78-
ports:
79-
- 8980
8076
restart: unless-stopped
8177
command: daemon --enable-all-parameters
8278
environment:

tests/localnet/test_localnet_start.test_localnet_start_with_name.approved.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ services:
3434
container_name: "algokit_sandbox_test_algod"
3535
image: algorand/algod:latest
3636
ports:
37-
- 8080
38-
- 7833
3937
- 9392:9392
4038
environment:
4139
START_KMD: 1
@@ -79,8 +77,6 @@ services:
7977
indexer:
8078
container_name: "algokit_sandbox_test_indexer"
8179
image: algorand/indexer:latest
82-
ports:
83-
- 8980
8480
restart: unless-stopped
8581
command: daemon --enable-all-parameters
8682
environment:

0 commit comments

Comments
 (0)