Skip to content

Commit 12e0df5

Browse files
author
avandras
committed
Set candidate name reliably if there is only one
1 parent 2be30da commit 12e0df5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

patroni/ctl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,10 @@ def _do_failover_or_switchover(action: str, cluster_name: str, group: Optional[i
12891289
raise PatroniCtlException('No candidates found to {0} to'.format(action))
12901290

12911291
if candidate is None and not force:
1292-
candidate = click.prompt('Candidate ' + str(candidate_names), type=str, default='')
1292+
if len(candidate_names) == 1:
1293+
candidate = click.prompt('Candidate ', type=str, default=candidate_names[0])
1294+
else:
1295+
candidate = click.prompt('Candidate ' + str(candidate_names), type=str, default='')
12931296

12941297
if action == 'failover' and not candidate:
12951298
raise PatroniCtlException('Failover could be performed only to a specific candidate')
@@ -1686,7 +1689,7 @@ def get_cluster_service_info(cluster: Dict[str, Any]) -> List[str]:
16861689

16871690

16881691
if 'multisite' in cluster:
1689-
info = f"Multisite {cluster['multisite']['name'] or ''} is {cluster['multisite']['status'].lower()}"
1692+
info = f"Multisite {cluster['multisite'].get('name') or ''} is {cluster['multisite']['status'].lower()}"
16901693
standby_config = cluster['multisite'].get('standby_config', {})
16911694
if standby_config and standby_config.get('host'):
16921695
info += f", replicating from {standby_config['leader_site']}"

0 commit comments

Comments
 (0)