-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathunified.py
More file actions
2390 lines (2279 loc) · 90.4 KB
/
unified.py
File metadata and controls
2390 lines (2279 loc) · 90.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Agent Configuration Schema
--------------------------
"""
from __future__ import annotations
import enum
import ipaddress
import logging
import os
import sys
from collections.abc import Mapping, Sequence
from decimal import Decimal
from pathlib import Path
from typing import (
Annotated,
Any,
Self,
cast,
)
from uuid import uuid4
from pydantic import (
AliasChoices,
ConfigDict,
Field,
FilePath,
PrivateAttr,
ValidationInfo,
field_validator,
model_validator,
)
from ai.backend.agent.affinity_map import AffinityPolicy
from ai.backend.agent.stats import StatModes
from ai.backend.agent.types import AgentBackend
from ai.backend.agent.utils import get_arch_name
from ai.backend.common.config import BaseConfigSchema
from ai.backend.common.configs import (
EtcdConfig,
OTELConfig,
PyroscopeConfig,
ServiceDiscoveryConfig,
)
from ai.backend.common.configs.redis import RedisConfig
from ai.backend.common.meta import BackendAIConfigMeta, CompositeType, ConfigExample
from ai.backend.common.typed_validators import (
AutoDirectoryPath,
GroupID,
HostPortPair,
UserID,
)
from ai.backend.common.types import (
BinarySize,
BinarySizeField,
ResourceGroupType,
SlotName,
SlotNameField,
)
from ai.backend.logging import BraceStyleAdapter
from ai.backend.logging.config import LoggingConfig
from ai.backend.logging.validation_context import BaseConfigValidationContext
log = BraceStyleAdapter(logging.getLogger(__spec__.name))
class EventLoopType(enum.StrEnum):
ASYNCIO = "asyncio"
UVLOOP = "uvloop"
class ContainerSandboxType(enum.StrEnum):
DOCKER = "docker"
JAIL = "jail"
class ScratchType(enum.StrEnum):
HOSTDIR = "hostdir"
HOSTFILE = "hostfile"
MEMORY = "memory"
K8S_NFS = "k8s-nfs"
class ResourceAllocationMode(enum.StrEnum):
SHARED = "shared"
AUTO_SPLIT = "auto-split"
MANUAL = "manual"
class AgentConfigValidationContext(BaseConfigValidationContext):
is_invoked_subcommand: bool
class SyncContainerLifecyclesConfig(BaseConfigSchema):
enabled: Annotated[
bool,
Field(default=True),
BackendAIConfigMeta(
description=(
"Controls whether the agent synchronizes container lifecycle states with the manager. "
"When enabled, the agent periodically checks container states (running, stopped, etc.) "
"and reports discrepancies to the manager for reconciliation. Useful for detecting "
"orphaned containers or missed lifecycle events."
),
added_version="25.12.0",
example=ConfigExample(local="true", prod="true"),
),
]
interval: Annotated[
float,
Field(default=10.0, ge=0),
BackendAIConfigMeta(
description=(
"Time interval in seconds between container lifecycle synchronization checks. "
"Lower values provide faster detection of container state changes but increase "
"system overhead. Higher values reduce overhead but may delay detection of issues."
),
added_version="25.12.0",
example=ConfigExample(local="10.0", prod="30.0"),
),
]
class CoreDumpConfig(BaseConfigSchema):
enabled: Annotated[
bool,
Field(default=False),
BackendAIConfigMeta(
description=(
"Enables collection of container core dumps when containers crash unexpectedly. "
"When enabled, the agent captures core dump files for debugging crashed containers. "
"Requires Linux with specific kernel settings. Only enable when debugging container crashes."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
path: Annotated[
AutoDirectoryPath,
Field(default=AutoDirectoryPath("./coredumps")),
BackendAIConfigMeta(
description=(
"Directory path where container core dump files are stored. "
"This directory is created automatically if it doesn't exist. "
"Ensure sufficient disk space is available for storing core dumps."
),
added_version="25.12.0",
example=ConfigExample(local="./coredumps", prod="/var/lib/backend.ai/coredumps"),
),
]
backup_count: Annotated[
int,
Field(
default=10,
ge=1,
validation_alias=AliasChoices("backup-count", "backup_count"),
serialization_alias="backup-count",
),
BackendAIConfigMeta(
description=(
"Maximum number of core dump backups to retain. "
"When this limit is exceeded, older core dump files are automatically deleted "
"to free up disk space. Increase this value if you need more historical dumps for debugging."
),
added_version="25.12.0",
example=ConfigExample(local="10", prod="20"),
),
]
size_limit: Annotated[
BinarySizeField,
Field(
default=BinarySize.finite_from_str("64M"),
validation_alias=AliasChoices("size-limit", "size_limit"),
serialization_alias="size-limit",
),
BackendAIConfigMeta(
description=(
"Maximum size limit for individual core dump files. "
"Core dumps larger than this limit are truncated. "
"Use binary size format (e.g., '64M', '128M', '1G'). "
"Larger values capture more debugging information but require more storage."
),
added_version="25.12.0",
example=ConfigExample(local="64M", prod="256M"),
),
]
_core_path: Path | None = PrivateAttr(default=None)
@property
def core_path(self) -> Path:
"""
Get the core path for core dumps.
If not set, it returns the default path.
"""
if self._core_path is None:
raise ValueError(
"Core path is not set. Please call set_core_path() before accessing core_path."
)
return self._core_path
@core_path.setter
def core_path(self, core_path: Path) -> None:
"""
Set the core path for core dumps.
This is used to set the core pattern file path.
"""
self._core_path = core_path
model_config = ConfigDict(
arbitrary_types_allowed=True,
)
@model_validator(mode="after")
def _set_coredump_path(self, info: ValidationInfo) -> Self:
if self.enabled:
context = AgentConfigValidationContext.get_config_validation_context(info)
if context is None:
raise ValueError("context must be specified in model_validate()")
if context.is_invoked_subcommand and not sys.platform.startswith("linux"):
raise ValueError("Storing container coredumps is only supported in Linux.")
core_pattern = Path("/proc/sys/kernel/core_pattern").read_text().strip()
if core_pattern.startswith("|") or not core_pattern.startswith("/"):
raise ValueError(
"/proc/sys/kernel/core_pattern must be an absolute path to enable container coredumps.",
)
self._core_path = Path(core_pattern).parent
return self
class DebugConfig(BaseConfigSchema):
enabled: Annotated[
bool,
Field(default=False),
BackendAIConfigMeta(
description=(
"Master switch for debug mode. When enabled, activates additional debugging features "
"and verbose logging across the agent. This setting is typically overridden by "
"command-line debug flag. Only enable in development or when troubleshooting issues."
),
added_version="25.12.0",
example=ConfigExample(local="true", prod="false"),
),
]
asyncio: Annotated[
bool,
Field(default=False),
BackendAIConfigMeta(
description=(
"Enables Python asyncio debug mode which provides detailed information about "
"unawaited coroutines, slow callbacks, and other async programming issues. "
"Significantly impacts performance and should only be used for debugging async bugs."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
kernel_runner: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("kernel-runner", "kernel_runner"),
serialization_alias="kernel-runner",
),
BackendAIConfigMeta(
description=(
"Enables debug mode for the kernel runner component which handles communication "
"between the agent and session containers. Produces verbose logs about code execution "
"requests, input/output handling, and container communication. Use for debugging "
"session execution issues."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
enhanced_aiomonitor_task_info: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices(
"enhanced-aiomonitor-task-info", "enhanced_aiomonitor_task_info"
),
serialization_alias="enhanced-aiomonitor-task-info",
),
BackendAIConfigMeta(
description=(
"Enables enhanced task information in the aiomonitor debugging interface. "
"Provides more detailed async task state information but adds overhead. "
"Useful for diagnosing async task leaks or blocking issues."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
skip_container_deletion: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("skip-container-deletion", "skip_container_deletion"),
serialization_alias="skip-container-deletion",
),
BackendAIConfigMeta(
description=(
"Prevents automatic container deletion after session termination. "
"Useful for post-mortem debugging of container state, filesystem, and logs. "
"Warning: containers will accumulate and consume resources. Only enable temporarily."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
log_stats: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("log-stats", "log_stats"),
serialization_alias="log-stats",
),
BackendAIConfigMeta(
description=(
"Enables logging of container resource statistics (CPU, memory, GPU usage). "
"Produces verbose periodic logs showing resource consumption metrics. "
"Useful for debugging resource tracking and quota enforcement issues."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
log_kernel_config: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("log-kernel-config", "log_kernel_config"),
serialization_alias="log-kernel-config",
),
BackendAIConfigMeta(
description=(
"Logs the kernel configuration sent to containers at startup. "
"Shows environment variables, mount points, and execution settings. "
"Helpful for debugging container initialization or configuration issues."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
log_alloc_map: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("log-alloc-map", "log_alloc_map"),
serialization_alias="log-alloc-map",
),
BackendAIConfigMeta(
description=(
"Logs the resource allocation map showing which resources (CPU cores, GPUs) "
"are assigned to which containers. Useful for debugging resource allocation "
"conflicts or understanding how resources are distributed."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
log_events: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("log-events", "log_events"),
serialization_alias="log-events",
),
BackendAIConfigMeta(
description=(
"Logs all internal agent events including container lifecycle events, "
"resource updates, and inter-component communication. Produces high volume "
"of logs but valuable for understanding agent behavior during issues."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
log_heartbeats: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("log-heartbeats", "log_heartbeats"),
serialization_alias="log-heartbeats",
),
BackendAIConfigMeta(
description=(
"Logs heartbeat messages sent between agent and manager. "
"Heartbeats contain agent status and resource availability information. "
"Use for debugging connectivity or status synchronization issues."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
heartbeat_interval: Annotated[
float,
Field(
default=20.0,
validation_alias=AliasChoices("heartbeat-interval", "heartbeat_interval"),
serialization_alias="heartbeat-interval",
),
BackendAIConfigMeta(
description=(
"Interval in seconds between heartbeat messages sent to the manager. "
"The manager uses heartbeats to detect agent availability. "
"Lower values provide faster detection of agent issues but increase network traffic."
),
added_version="25.12.0",
example=ConfigExample(local="20.0", prod="20.0"),
),
]
log_docker_events: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("log-docker-events", "log_docker_events"),
serialization_alias="log-docker-events",
),
BackendAIConfigMeta(
description=(
"Logs Docker daemon events received by the agent (container start/stop/die, etc.). "
"Useful for debugging container lifecycle issues or understanding Docker behavior. "
"Only applicable when using Docker backend."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="false"),
),
]
coredump: Annotated[
CoreDumpConfig,
Field(default_factory=CoreDumpConfig),
BackendAIConfigMeta(
description=(
"Configuration for container core dump collection. "
"Core dumps help debug container crashes by providing memory snapshots at crash time."
),
added_version="25.12.0",
composite=CompositeType.FIELD,
),
]
@field_validator("enabled", mode="before")
@classmethod
def _set_enabled(cls, v: Any, info: ValidationInfo) -> Any:
context = AgentConfigValidationContext.get_config_validation_context(info)
if context is None:
# Likely in tests, command line args do not need to be set.
return v
return context.debug
class CommonAgentConfig(BaseConfigSchema):
"""
Agent settings that cannot be overridden per-agent.
"""
backend: Annotated[
AgentBackend,
Field(
validation_alias=AliasChoices("backend", "mode"),
serialization_alias="backend",
),
BackendAIConfigMeta(
description=(
"Backend type for the agent determining how it interacts with the underlying "
"container orchestration infrastructure. Available options: "
"'docker' uses Docker daemon for container management (default for most deployments); "
"'kubernetes' uses Kubernetes API for container management in K8s clusters; "
"'dummy' is a mock backend for testing without actual containers."
),
added_version="25.12.0",
example=ConfigExample(local="docker", prod="docker"),
),
]
rpc_listen_addr: Annotated[
HostPortPair,
Field(
default=HostPortPair(host="0.0.0.0", port=6001),
validation_alias=AliasChoices("rpc-listen-addr", "rpc_listen_addr"),
serialization_alias="rpc-listen-addr",
),
BackendAIConfigMeta(
description=(
"Network address and port where the agent listens for RPC calls from the manager. "
"The manager uses this endpoint to send commands like session creation, termination, "
"and resource queries. Use '0.0.0.0' to listen on all interfaces."
),
added_version="25.12.0",
example=ConfigExample(local="0.0.0.0:6001", prod="0.0.0.0:6001"),
),
]
internal_addr: Annotated[
HostPortPair,
Field(
default=HostPortPair(host="0.0.0.0", port=6003),
validation_alias=AliasChoices("service-addr", "internal-addr", "service_addr"),
serialization_alias="internal-addr",
),
BackendAIConfigMeta(
description=(
"Network address and port for internal services within the agent. "
"Used for inter-process communication and internal API endpoints. "
"This address is typically not exposed externally."
),
added_version="25.12.0",
example=ConfigExample(local="0.0.0.0:6003", prod="0.0.0.0:6003"),
),
]
announce_internal_addr: Annotated[
HostPortPair,
Field(
default=HostPortPair(host="host.docker.internal", port=6003),
validation_alias=AliasChoices(
"announce-addr", "announce-internal-addr", "announce_addr"
),
serialization_alias="announce-internal-addr",
),
BackendAIConfigMeta(
description=(
"Address announced to containers for reaching the agent's internal services. "
"Containers use this address to communicate back with the agent. "
"Use 'host.docker.internal' for Docker on macOS/Windows, or the host's actual IP on Linux."
),
added_version="25.12.0",
example=ConfigExample(local="host.docker.internal:6003", prod="192.168.1.100:6003"),
),
]
ssl_enabled: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("ssl-enabled", "ssl_enabled"),
serialization_alias="ssl-enabled",
),
BackendAIConfigMeta(
description=(
"Enables SSL/TLS encryption for RPC communication between the agent and manager. "
"When enabled, requires ssl_cert and ssl_key to be configured with valid certificates. "
"Recommended for production deployments to secure inter-component communication."
),
added_version="25.12.0",
example=ConfigExample(local="false", prod="true"),
),
]
ssl_cert: Annotated[
FilePath | None,
Field(
default=None,
validation_alias=AliasChoices("ssl-cert", "ssl_cert"),
serialization_alias="ssl-cert",
),
BackendAIConfigMeta(
description=(
"Path to the SSL/TLS certificate file (PEM format) for encrypted RPC communication. "
"Required when ssl_enabled is true. The certificate should be valid for the agent's "
"hostname and signed by a trusted CA or self-signed for internal use."
),
added_version="25.12.0",
secret=True,
example=ConfigExample(local="/path/to/cert.pem", prod="/etc/backend.ai/ssl/agent.crt"),
),
]
ssl_key: Annotated[
FilePath | None,
Field(
default=None,
validation_alias=AliasChoices("ssl-key", "ssl_key"),
serialization_alias="ssl-key",
),
BackendAIConfigMeta(
description=(
"Path to the SSL/TLS private key file (PEM format) corresponding to the ssl_cert. "
"Required when ssl_enabled is true. The key file should have restricted permissions "
"(e.g., 0600) and be readable only by the agent process."
),
added_version="25.12.0",
secret=True,
example=ConfigExample(local="/path/to/key.pem", prod="/etc/backend.ai/ssl/agent.key"),
),
]
advertised_rpc_addr: Annotated[
HostPortPair | None,
Field(
default=None,
validation_alias=AliasChoices("advertised-rpc-addr", "advertised_rpc_addr"),
serialization_alias="advertised-rpc-addr",
),
BackendAIConfigMeta(
description=(
"External address that the agent advertises to the manager for RPC callbacks. "
"Use when the agent is behind NAT or a load balancer and the listen address "
"differs from the externally reachable address. If not set, uses rpc_listen_addr."
),
added_version="25.12.0",
example=ConfigExample(local="192.168.1.100:6001", prod="192.168.1.100:6001"),
),
]
rpc_auth_manager_public_key: Annotated[
FilePath | None,
Field(
default=None,
validation_alias=AliasChoices(
"rpc-auth-manager-public-key", "rpc_auth_manager_public_key"
),
serialization_alias="rpc-auth-manager-public-key",
),
BackendAIConfigMeta(
description=(
"Path to the manager's public key file for authenticating RPC messages. "
"Used with ZeroMQ CURVE authentication to verify messages from the manager. "
"Part of the RPC security mechanism for preventing unauthorized access."
),
added_version="25.12.0",
secret=True,
example=ConfigExample(
local="/path/to/public.key", prod="/etc/backend.ai/keys/manager.pub"
),
),
]
rpc_auth_agent_keypair: Annotated[
FilePath | None,
Field(
default=None,
validation_alias=AliasChoices("rpc-auth-agent-keypair", "rpc_auth_agent_keypair"),
serialization_alias="rpc-auth-agent-keypair",
),
BackendAIConfigMeta(
description=(
"Path to the agent's keypair file for RPC authentication. "
"Contains both public and private keys used for ZeroMQ CURVE authentication. "
"The private key must be kept secure as it proves the agent's identity."
),
added_version="25.12.0",
secret=True,
example=ConfigExample(
local="/path/to/keypair.key", prod="/etc/backend.ai/keys/agent.keypair"
),
),
]
ipc_base_path: Annotated[
AutoDirectoryPath,
Field(
default=AutoDirectoryPath("/tmp/backend.ai/ipc"),
validation_alias=AliasChoices("ipc-base-path", "ipc_base_path"),
serialization_alias="ipc-base-path",
),
BackendAIConfigMeta(
description=(
"Base directory path for Unix domain sockets and other IPC mechanisms. "
"Used for communication between the agent and its child processes. "
"Directory is created automatically with appropriate permissions."
),
added_version="25.12.0",
example=ConfigExample(local="/tmp/backend.ai/ipc", prod="/var/run/backend.ai/ipc"),
),
]
var_base_path: Annotated[
AutoDirectoryPath,
Field(
default=AutoDirectoryPath("./var/lib/backend.ai"),
validation_alias=AliasChoices("var-base-path", "var_base_path"),
serialization_alias="var-base-path",
),
BackendAIConfigMeta(
description=(
"Base directory for the agent's variable data including runtime state, "
"temporary files, and data that persists across restarts but not upgrades. "
"Ensure sufficient disk space and appropriate permissions."
),
added_version="25.12.0",
example=ConfigExample(local="./var/lib/backend.ai", prod="/var/lib/backend.ai"),
),
]
mount_path: Annotated[
AutoDirectoryPath | None,
Field(
default=None,
validation_alias=AliasChoices("mount-path", "mount_path"),
serialization_alias="mount-path",
),
BackendAIConfigMeta(
description=(
"Base directory path for mounting storage volumes into containers. "
"Virtual folders and other storage mounts are placed under this path. "
"Should be on a filesystem with sufficient space for user data."
),
added_version="25.12.0",
example=ConfigExample(local="/mnt/backend.ai", prod="/mnt/backend.ai"),
),
]
cohabiting_storage_proxy: Annotated[
bool,
Field(
default=True,
validation_alias=AliasChoices("cohabiting-storage-proxy", "cohabiting_storage_proxy"),
serialization_alias="cohabiting-storage-proxy",
),
BackendAIConfigMeta(
description=(
"Indicates whether a storage proxy runs on the same host as the agent. "
"When true, the agent uses local filesystem paths for storage operations, "
"improving performance. When false, storage is accessed via network protocols."
),
added_version="25.12.0",
example=ConfigExample(local="true", prod="true"),
),
]
public_host: Annotated[
str | None,
Field(
default=None,
validation_alias=AliasChoices("public-host", "public_host"),
serialization_alias="public-host",
),
BackendAIConfigMeta(
description=(
"Public hostname or IP address for this agent node. "
"Used for generating URLs that users can access to reach services "
"running on this agent, such as web terminals or application proxies."
),
added_version="25.12.0",
example=ConfigExample(local="backend.ai", prod="compute1.backend.ai"),
),
]
region: Annotated[
str | None,
Field(default=None),
BackendAIConfigMeta(
description=(
"Cloud region identifier where this agent is deployed. "
"Used for geographic resource allocation and displayed in admin interfaces. "
"Use standard region codes like 'us-east-1', 'eu-west-1', or custom identifiers."
),
added_version="25.12.0",
example=ConfigExample(local="us-east-1", prod="us-east-1"),
),
]
instance_type: Annotated[
str | None,
Field(
default=None,
validation_alias=AliasChoices("instance-type", "instance_type"),
serialization_alias="instance-type",
),
BackendAIConfigMeta(
description=(
"Cloud instance type identifier for this agent's host machine. "
"Used for cost tracking, capacity planning, and displayed in admin interfaces. "
"Use cloud provider's instance type names like 'm5.large' or 'n1-standard-4'."
),
added_version="25.12.0",
example=ConfigExample(local="m5.large", prod="m5.xlarge"),
),
]
pid_file: Annotated[
Path,
Field(
default=Path(os.devnull),
validation_alias=AliasChoices("pid-file", "pid_file"),
serialization_alias="pid-file",
),
BackendAIConfigMeta(
description=(
"Path to the PID file where the agent writes its process ID. "
"Used by init systems and monitoring tools to track the agent process. "
"Set to /dev/null to disable PID file creation."
),
added_version="25.12.0",
example=ConfigExample(local="/dev/null", prod="/var/run/backend.ai/agent.pid"),
),
]
event_loop: Annotated[
EventLoopType,
Field(
default=EventLoopType.ASYNCIO,
validation_alias=AliasChoices("event-loop", "event_loop"),
serialization_alias="event-loop",
),
BackendAIConfigMeta(
description=(
"Python async event loop implementation to use. "
"'asyncio' uses the standard library implementation (default, most compatible). "
"'uvloop' uses a faster libuv-based implementation (better performance, Linux only)."
),
added_version="25.12.0",
example=ConfigExample(local="asyncio", prod="asyncio"),
),
]
skip_manager_detection: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices("skip-manager-detection", "skip_manager_detection"),
serialization_alias="skip-manager-detection",
),
BackendAIConfigMeta(
description=(
"Skips automatic detection of the manager during agent startup. "
"When true, the agent starts without verifying manager connectivity. "
"Useful for testing or when the manager becomes available after the agent starts."
),
added_version="25.12.0",
example=ConfigExample(local="true", prod="false"),
),
]
aiomonitor_termui_port: Annotated[
int,
Field(
default=38200,
ge=1,
le=65535,
validation_alias=AliasChoices(
"aiomonitor-termui-port", "aiomonitor-port", "aiomonitor_termui_port"
),
serialization_alias="aiomonitor-termui-port",
),
BackendAIConfigMeta(
description=(
"Port for the aiomonitor terminal UI debugging interface. "
"Provides real-time inspection of async tasks and event loop state. "
"Connect via telnet to this port for interactive debugging."
),
added_version="25.12.0",
example=ConfigExample(local="38200", prod="38200"),
),
]
aiomonitor_webui_port: Annotated[
int,
Field(
default=39200,
ge=1,
le=65535,
validation_alias=AliasChoices("aiomonitor-webui-port", "aiomonitor_webui_port"),
serialization_alias="aiomonitor-webui-port",
),
BackendAIConfigMeta(
description=(
"Port for the aiomonitor web UI debugging interface. "
"Provides a browser-based interface for inspecting async tasks. "
"Access via http://agent-host:port for visual debugging."
),
added_version="25.12.0",
example=ConfigExample(local="39200", prod="39200"),
),
]
metadata_server_bind_host: Annotated[
str,
Field(
default="0.0.0.0",
validation_alias=AliasChoices("metadata-server-bind-host", "metadata_server_bind_host"),
serialization_alias="metadata-server-bind-host",
),
BackendAIConfigMeta(
description=(
"Bind host for the container metadata server. "
"Containers connect to this server to retrieve session metadata and configuration. "
"Use '0.0.0.0' to listen on all interfaces or a specific IP for restricted access."
),
added_version="25.12.0",
example=ConfigExample(local="0.0.0.0", prod="0.0.0.0"),
),
]
metadata_server_port: Annotated[
int,
Field(
default=40128,
ge=1,
le=65535,
validation_alias=AliasChoices("metadata-server-port", "metadata_server_port"),
serialization_alias="metadata-server-port",
),
BackendAIConfigMeta(
description=(
"Port for the container metadata server. "
"Containers access metadata like session ID, access key, and environment variables "
"through this server. Similar to cloud provider instance metadata services."
),
added_version="25.12.0",
example=ConfigExample(local="40128", prod="40128"),
),
]
allow_compute_plugins: Annotated[
set[str] | None,
Field(
default=None,
validation_alias=AliasChoices("allow-compute-plugins", "allow_compute_plugins"),
serialization_alias="allow-compute-plugins",
),
BackendAIConfigMeta(
description=(
"Allowlist of compute plugin names that can be loaded by this agent. "
"If set, only plugins in this list are loaded. If null/empty, all discovered "
"plugins are loaded except those in block_compute_plugins. "
"Plugin names use Python package notation (e.g., 'ai.backend.accelerator.cuda')."
),
added_version="25.12.0",
example=ConfigExample(
local="", prod='["ai.backend.accelerator.cuda", "ai.backend.accelerator.rocm"]'
),
),
]
block_compute_plugins: Annotated[
set[str] | None,
Field(
default=None,
validation_alias=AliasChoices("block-compute-plugins", "block_compute_plugins"),
serialization_alias="block-compute-plugins",
),
BackendAIConfigMeta(
description=(
"Blocklist of compute plugin names that should not be loaded by this agent. "
"Plugins in this list are excluded even if discovered. "
"Use to disable specific accelerators or features on certain nodes."
),
added_version="25.12.0",
example=ConfigExample(local="", prod='["ai.backend.accelerator.mock"]'),
),
]
allow_network_plugins: Annotated[
set[str] | None,
Field(
default=None,
validation_alias=AliasChoices("allow-network-plugins", "allow_network_plugins"),
serialization_alias="allow-network-plugins",
),
BackendAIConfigMeta(
description=(
"Allowlist of network plugin names that can be loaded by this agent. "
"Network plugins provide custom networking configurations for containers. "
"If set, only plugins in this list are loaded."
),
added_version="25.12.0",
example=ConfigExample(local="", prod='["ai.backend.network.overlay"]'),
),
]
block_network_plugins: Annotated[
set[str] | None,
Field(
default=None,
validation_alias=AliasChoices("block-network-plugins", "block_network_plugins"),
serialization_alias="block-network-plugins",
),
BackendAIConfigMeta(
description=(
"Blocklist of network plugin names that should not be loaded by this agent. "
"Use to disable specific network configurations on certain nodes."
),
added_version="25.12.0",
example=ConfigExample(local="", prod='["ai.backend.network.legacy"]'),
),
]
image_commit_path: Annotated[
AutoDirectoryPath,
Field(
default=AutoDirectoryPath("./tmp/backend.ai/commit"),
validation_alias=AliasChoices("image-commit-path", "image_commit_path"),
serialization_alias="image-commit-path",
),
BackendAIConfigMeta(
description=(
"Directory path for storing temporary image commit data. "
"Used when users commit their running containers as new images. "
"Requires sufficient disk space for container filesystem layers."
),
added_version="25.12.0",
example=ConfigExample(
local="./tmp/backend.ai/commit", prod="/var/lib/backend.ai/commit"
),
),
]
abuse_report_path: Annotated[
Path | None,
Field(
default=None,
validation_alias=AliasChoices("abuse-report-path", "abuse_report_path"),
serialization_alias="abuse-report-path",
),
BackendAIConfigMeta(
description=(
"Directory path for storing container abuse reports. "
"When suspicious or abusive behavior is detected in containers, "
"detailed reports are written here for review by administrators."
),
added_version="25.12.0",
example=ConfigExample(local="", prod="/var/log/backend.ai/abuse"),
),
]
use_experimental_redis_event_dispatcher: Annotated[
bool,
Field(
default=False,
validation_alias=AliasChoices(
"use-experimental-redis-event-dispatcher", "use_experimental_redis_event_dispatcher"
),
serialization_alias="use-experimental-redis-event-dispatcher",
),