Skip to content

Commit 651da2e

Browse files
committed
refactor: add pg_autoctl inspect and manual sub-command groups
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)
1 parent 1b2f3c6 commit 651da2e

29 files changed

Lines changed: 1841 additions & 500 deletions

docs/failover-state-machine.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,10 @@ command, and then the node entry is removed from the monitor.
277277
pg_auto_failover keeper's State Machine
278278
---------------------------------------
279279

280-
When built in TEST mode, it is then possible to use the following command to
281-
get a visual representation of the Keeper's Finite State Machine::
280+
It is possible to use the following command to get a visual representation
281+
of the Keeper's Finite State Machine::
282282

283-
$ PG_AUTOCTL_DEBUG=1 pg_autoctl do fsm gv | dot -Tsvg > fsm.svg
283+
$ pg_autoctl inspect fsm gv | dot -Tsvg > fsm.svg
284284

285285
The `dot` program is part of the Graphviz suite and produces the following
286286
output:

docs/ref/manual.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ have their own manual page.
2020
pg_autoctl_get
2121
pg_autoctl_set
2222
pg_autoctl_perform
23+
pg_autoctl_inspect
24+
pg_autoctl_manual
2325
pg_autoctl_do
2426
pg_autoctl_run
2527
pg_autoctl_watch

docs/ref/pg_autoctl_do.rst

Lines changed: 8 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -3,121 +3,24 @@
33
pg_autoctl do
44
=============
55

6-
pg_autoctl do - Internal commands and internal QA tooling
6+
pg_autoctl do - Internal QA tooling (tmux sessions, demo app)
77

8-
The debug commands for ``pg_autoctl`` are only available when the
9-
environment variable ``PG_AUTOCTL_DEBUG`` is set (to any value).
10-
11-
When testing pg_auto_failover, it is helpful to be able to play with the
12-
local nodes using the same lower-level API as used by the pg_auto_failover
13-
Finite State Machine transitions. Some commands could be useful in contexts
14-
other than pg_auto_failover development and QA work, so some documentation
15-
has been made available.
8+
The ``pg_autoctl do`` command group contains development and QA tooling that
9+
is not intended for production use. For read-only diagnostics see
10+
:ref:`pg_autoctl_inspect`; for manual cluster recovery operations see
11+
:ref:`pg_autoctl_manual`.
1612

1713
.. toctree::
1814
:maxdepth: 1
1915

2016
pg_autoctl_do_tmux
2117
pg_autoctl_do_demo
22-
pg_autoctl_do_service_restart
23-
pg_autoctl_do_show
24-
pg_autoctl_do_pgsetup
2518

26-
The low-level API is made available through the following ``pg_autoctl do``
27-
commands, only available in debug environments::
19+
``pg_autoctl do`` provides the following commands::
2820

2921
pg_autoctl do
30-
+ monitor Query a pg_auto_failover monitor
31-
+ fsm Manually manage the keeper's state
32-
+ primary Manage a PostgreSQL primary server
33-
+ standby Manage a PostgreSQL standby server
34-
+ show Show some debug level information
35-
+ pgsetup Manage a local Postgres setup
36-
+ pgctl Signal the pg_autoctl postgres service
37-
+ service Run pg_autoctl sub-processes (services)
38-
+ tmux Set of facilities to handle tmux interactive sessions
39-
+ demo Use a demo application for pg_auto_failover
40-
41-
pg_autoctl do monitor
42-
+ get Get information from the monitor
43-
register Register the current node with the monitor
44-
active Call in the pg_auto_failover Node Active protocol
45-
version Check that monitor version is 1.5.0.1; alter extension update if not
46-
parse-notification parse a raw notification message
47-
48-
pg_autoctl do monitor get
49-
primary Get the primary node from pg_auto_failover in given formation/group
50-
others Get the other nodes from the pg_auto_failover group of hostname/port
51-
coordinator Get the coordinator node from the pg_auto_failover formation
52-
53-
pg_autoctl do fsm
54-
init Initialize the keeper's state on-disk
55-
state Read the keeper's state from disk and display it
56-
list List reachable FSM states from current state
57-
gv Output the FSM as a .gv program suitable for graphviz/dot
58-
assign Assign a new goal state to the keeper
59-
step Make a state transition if instructed by the monitor
60-
+ nodes Manually manage the keeper's nodes list
61-
62-
pg_autoctl do fsm nodes
63-
get Get the list of nodes from file (see --disable-monitor)
64-
set Set the list of nodes to file (see --disable-monitor)
65-
66-
pg_autoctl do primary
67-
+ slot Manage replication slot on the primary server
68-
+ adduser Create users on primary
69-
defaults Add default settings to postgresql.conf
70-
identify Run the IDENTIFY_SYSTEM replication command on given host
71-
72-
pg_autoctl do primary slot
73-
create Create a replication slot on the primary server
74-
drop Drop a replication slot on the primary server
75-
76-
pg_autoctl do primary adduser
77-
monitor add a local user for queries from the monitor
78-
replica add a local user with replication privileges
79-
80-
pg_autoctl do standby
81-
init Initialize the standby server using pg_basebackup
82-
rewind Rewind a demoted primary server using pg_rewind
83-
promote Promote a standby server to become writable
84-
85-
pg_autoctl do show
86-
ipaddr Print this node's IP address information
87-
cidr Print this node's CIDR information
88-
lookup Print this node's DNS lookup information
89-
hostname Print this node's default hostname
90-
reverse Lookup given hostname and check reverse DNS setup
91-
92-
pg_autoctl do pgsetup
93-
pg_ctl Find a non-ambiguous pg_ctl program and Postgres version
94-
discover Discover local PostgreSQL instance, if any
95-
ready Return true is the local Postgres server is ready
96-
wait Wait until the local Postgres server is ready
97-
logs Outputs the Postgres startup logs
98-
tune Compute and log some Postgres tuning options
99-
100-
pg_autoctl do pgctl
101-
on Signal pg_autoctl postgres service to ensure Postgres is running
102-
off Signal pg_autoctl postgres service to ensure Postgres is stopped
103-
104-
pg_autoctl do service
105-
+ getpid Get the pid of pg_autoctl sub-processes (services)
106-
+ restart Restart pg_autoctl sub-processes (services)
107-
pgcontroller pg_autoctl supervised postgres controller
108-
postgres pg_autoctl service that start/stop postgres when asked
109-
listener pg_autoctl service that listens to the monitor notifications
110-
node-active pg_autoctl service that implements the node active protocol
111-
112-
pg_autoctl do service getpid
113-
postgres Get the pid of the pg_autoctl postgres controller service
114-
listener Get the pid of the pg_autoctl monitor listener service
115-
node-active Get the pid of the pg_autoctl keeper node-active service
116-
117-
pg_autoctl do service restart
118-
postgres Restart the pg_autoctl postgres controller service
119-
listener Restart the pg_autoctl monitor listener service
120-
node-active Restart the pg_autoctl keeper node-active service
22+
+ tmux Set of facilities to handle tmux interactive sessions
23+
+ demo Use a demo application for pg_auto_failover
12124

12225
pg_autoctl do tmux
12326
script Produce a tmux script for a demo or a test case (debug only)

docs/ref/pg_autoctl_do_pgsetup.rst

Lines changed: 0 additions & 159 deletions
This file was deleted.

docs/ref/pg_autoctl_do_service_restart.rst

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)