hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.07k stars 112 forks source link

"pg_autoctl show state --json" provides an invalid json output if a connection retry takes place #983

Closed abubakarm94 closed 1 year ago

abubakarm94 commented 1 year ago

I've noticed that when I invoke "pg_autoctl show state --json" and pg_autoctl needs to retry the connection, some log lines are included in the response that makes the json output invalid.

pg_autoctl show state --json
16:20:56 29821 WARN  Failed to connect to “postgres://autoctl_node@postgresdb-monitor-0.postgresdb-agent.default.svc.cluster.local:5432/pg_auto_failover?password=****&sslmode=verify-ca&sslrootcert=/etc/postgres_ssl/..2023_03_06_15_18_04.4141533220/ca.crt”, retrying until the server is ready
16:20:58 29821 INFO  Successfully connected to “postgres://autoctl_node@postgresdb-monitor-0.postgresdb-agent.default.svc.cluster.local:5432/pg_auto_failover?password=****&sslmode=verify-ca&sslrootcert=/etc/postgres_ssl/..2023_03_06_15_18_04.4141533220/ca.crt” after 2 attempts in 4610 ms.
[
    {
        “health”: 0,
        “node_id”: 1,
        “group_id”: 0,
        “nodehost”: “postgresdb-0.postgresdb-agent.default.svc.cluster.local”,
        “nodename”: “node_1”,
        “nodeport”: 5432,
        “nodecluster”: “default”,
        “reported_lsn”: “0/15A01B8",
        “reported_tli”: 1,
        “formation_kind”: “pgsql”,
        “candidate_priority”: 50,
        “replication_quorum”: true,
        “current_group_state”: “single”,
        “assigned_group_state”: “single”
    }
]
DimCitus commented 1 year ago

Try using --quiet or -q for the output to bypass displaying INFO and WARN log levels.