refactor: add pg_autoctl inspect and manual sub-command groups - #1130
Merged
Conversation
dimitri
force-pushed
the
pg-autoctl-commands
branch
2 times, most recently
from
July 6, 2026 18:11
f1e2085 to
651da2e
Compare
Reorganise the operator-facing commands to make the binary more approachable without the PG_AUTOCTL_DEBUG environment variable gate: pg_autoctl inspect — read-only diagnostics, always visible inspect pgsetup local PostgreSQL setup inspection inspect fsm FSM state / list / graphviz (read-only subset) inspect monitor get primary/others/candidate-count, parse-notification inspect show ipaddr, cidr, lookup, hostname, reverse pg_autoctl manual — operator-driven FSM operations for manual recovery manual fsm assign / step / nodes get+set manual service restart postgres|listener|node-active; pgctl on|off manual monitor register / active / version manual coordinator add / activate / remove / update Both groups are always visible regardless of PG_AUTOCTL_DEBUG. PG_AUTOCTL_DEBUG now only controls log verbosity, not command visibility. Implementation details: - Add bool hidden field to CommandLine struct so make_hidden_command_set can register the internal sub-process entry points (pg_autoctl internal service postgres|listener|node-active) without surfacing them in --help - The supervisor now spawns pg_autoctl internal service ... instead of the old pg_autoctl do service ... path; pg_autoctl do is trimmed to tmux and demo tooling only - Python test helpers updated to use inspect/manual in place of do Documentation: - Add docs/ref/pg_autoctl_inspect.rst and pg_autoctl_inspect_pgsetup.rst, pg_autoctl_inspect_show.rst - Add docs/ref/pg_autoctl_manual.rst and pg_autoctl_manual_service_restart.rst - Trim docs/ref/pg_autoctl_do.rst to tmux/demo only; remove superseded pg_autoctl_do_pgsetup.rst, pg_autoctl_do_service_restart.rst, pg_autoctl_do_show.rst - Update failover-state-machine.rst: pg_autoctl inspect fsm gv (no longer requires PG_AUTOCTL_DEBUG)
dimitri
force-pushed
the
pg-autoctl-commands
branch
from
July 6, 2026 18:36
651da2e to
f876e82
Compare
…tatic fsm/monitor symbols
- Remove the PG_AUTOCTL_DEBUG command-dispatch branch: root_with_debug and
root_subcommands_with_debug are identical to root now that inspect/manual
are always-visible. Delete them from cli_root.c and cli_root.h; remove the
env_exists(PG_AUTOCTL_DEBUG) gate from main.c and cli_common.c.
- Add pg_autoctl internal service (hidden) — the supervisor spawns subprocess
entry points via fork+exec as:
pg_autoctl internal service postgres|listener|node-active --pgdata ...
make_hidden_command_set keeps these out of --help output. Replaces the old
'pg_autoctl do service' path that was broken when 'do' was renamed to 'internal'.
- Export fsm_init/state/list/gv/assign/step and monitor_get_command/
parse_notification/register/node_active/version from their respective
cli_do_*.c files (remove static) so cli_inspect.c and cli_manual.c can
compose them into the inspect/manual sub-command trees.
- Drop fsm_node_state and monitor_node_state/formation_states from
cli_inspect.c — these symbols exist only in pgaftest-infra, not origin/main.
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add two new always-visible sub-command groups to
pg_autoctl, and remove thePG_AUTOCTL_DEBUGcommand-visibility gate:pg_autoctl inspect— read-only diagnostics: pgsetup, fsm state/list/gv, monitor queries, network/show utilities. Safe to run on a live node.pg_autoctl manual— operator-driven FSM operations for manual cluster recovery: fsm init/assign/step/nodes, service restart/pgctl, monitor register/active/version, primary/standby/coordinator ops.Both groups are always visible in
pg_autoctl --help.PG_AUTOCTL_DEBUGnow only controls log verbosity — theroot_with_debugdual-root pattern and the env-var command-dispatch gate are deleted.Sub-process entry points are registered as a hidden
pg_autoctl internal servicecommand set — routable but absent from--help. The supervisor spawnspg_autoctl internal service postgres|listener|node-activeinstead of the oldpg_autoctl do service ...path.Changes
New dispatch layer
cli_inspect.c/cli_inspect.h: newpg_autoctl inspectdispatch (fsm, pgsetup, monitor, show, getpid)cli_manual.c/cli_manual.h: newpg_autoctl manualdispatch (fsm, service, monitor, primary, standby, coordinator)cli_root.c: add&inspect_commands,&manual_commands,&internal_commandsto the root sub-command tableHidden internal entry points
cli_do_root.c: add hiddenpg_autoctl internal service(pgcontroller, postgres, listener, node-active) viamake_hidden_command_setcommandline.h/commandline.c: addbool hiddenfield toCommandLinestruct; addmake_hidden_command_setmacro; skip hidden commands incommandline_pretty_print_subcommandsSupervisor fix
service_postgres_ctl.c,service_monitor.c,service_keeper.c: supervisor spawnspg_autoctl internal service ...instead of the deletedpg_autoctl do service ...pathSymbol visibility
cli_do_fsm.c: removestaticfromfsm_init/state/list/gv/assign/stepsocli_inspect.candcli_manual.ccan compose themcli_do_monitor.c: removestaticfrommonitor_get_command,monitor_parse_notification_command,monitor_register_command,monitor_node_active_command,monitor_version_commandcli_do_root.h: updated extern declarations for all newly-public symbolsDead-code removal
cli_root.c/cli_root.h: deleteroot_with_debugandroot_subcommands_with_debug(now identical toroot)main.c,cli_common.c: removeenv_exists(PG_AUTOCTL_DEBUG)command-dispatch blocksTests and docs
tests/pgautofailover_utils.py: updatedo pgsetup→inspect pgsetup,do fsm→inspect fsm(read-only) ormanual fsm(mutating),do service restart→manual service restartdocs/ref/pg_autoctl_inspect.rst,pg_autoctl_inspect_pgsetup.rst,pg_autoctl_inspect_show.rst,pg_autoctl_manual.rst,pg_autoctl_manual_service_restart.rstdocs/ref/pg_autoctl_do.rstto tmux/demo only; delete superseded pgsetup/show/service_restart pagesdocs/ref/manual.rsttoctree anddocs/failover-state-machine.rst(removePG_AUTOCTL_DEBUG=1requirement frominspect fsm gvexample)Testing
Verified locally with a full
test_basic_operationrun (32 tests, OK) against a PG 17 Docker image.