lablup / lablup/backend.ai

Implement config CLI subcommands

Open
#7,816 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

## Motivation

Provide CLI commands for configuration management to view, update, and migrate configuration values.

## Scope

### `config show` - View configuration values

```bash
./backend.ai mgr config show # All loaders merged (effective config)
./backend.ai mgr config show redis.addr # Specific field only
./backend.ai mgr config show --loader file # Values from TOML file only
./backend.ai mgr config show --loader etcd # Values from etcd only
./backend.ai mgr config show --loader legacy-etcd # Values from legacy etcd format
```

**Output formats:**

|Format|Description|
|---|---|
|`--format flat`|Dot-notation key=value pairs (grep-friendly)|
|`--format json`|JSON (default, automation-friendly)|
|`--format yaml`|YAML (human-readable)|
|`--format toml`|TOML|

**Example** `--format flat` output:

```
redis.addr.host = "redis-server"
redis.addr.port = 6379
redis.password = "********"
logging.level = "INFO"
logging.file.path = "/var/log/backend.ai"
```

### `config schema` - View available config fields

```bash
./backend.ai mgr config schema # All fields
./backend.ai mgr config schema --section redis # Specific section
./backend.ai mgr config schema --format json # JSON output for automation
```

**Output:**

```
[redis]
addr HostPortPair | None Network address of Redis server
Added: 25.13.0, Default: None
password str | None Redis password (secret)
Added: 25.13.0, Default: None
```

### `config set` - Update configuration value

```bash
./backend.ai mgr config set redis.addr.host "new-redis-server"
./backend.ai mgr config set redis.addr.port 6380
./backend.ai mgr config set logging.level "DEBUG"
./backend.ai mgr config set --loader etcd redis.password "new-password" # Update specific loader
```

### `config migrate` - Migrate values to etcd

```bash
./backend.ai mgr config migrate redis # Migrate redis section to etcd
./backend.ai mgr config migrate redis.addr # Migrate specific field to etcd
./backend.ai mgr config migrate --all # Migrate all fields to etcd
./backend.ai mgr config migrate --dry-run redis # Preview without applying
```

Migrates current effective values (from file/legacy-etcd) to new etcd format.

## Implementation Notes

- Each loader returns `dict[str, Any]` raw data, mapped to config fields
- When `--loader` not specified, show merged config with all loaders applied
- Secret fields masked in output by default (use `--unmask-secrets` to reveal)
- Use existing `ConfigInspector` for schema extraction
- `set` updates the specified loader (default: etcd)
- `migrate` reads current value and writes to etcd

## Acceptance Criteria

- `config show [field]` with `--loader` and `--format` options
- `config schema` showing available fields with types, descriptions, versions
- `config set ` to update field value
- `config migrate ` to migrate values to etcd
- Secret fields masked by default
- Integrated with all component CLIs (Manager, Agent, Storage, Web, AppProxy)

## References

- [BEP-1023: UnifiedConfig Consolidation](https://github.com/lablup/backend.ai/blob/main/proposals/BEP-1023-unified-config-consolidation.md) Phase 4

JIRA Issue: BA-3786

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.