Skip to content

Commit ada37ba

Browse files
author
avandras
committed
Set candidate name reliably if there is only one
1 parent 2335fe5 commit ada37ba

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
@@ -1279,7 +1279,10 @@ def _do_failover_or_switchover(action: str, cluster_name: str, group: Optional[i
12791279
raise PatroniCtlException('No candidates found to {0} to'.format(action))
12801280

12811281
if candidate is None and not force:
1282-
candidate = click.prompt('Candidate ' + str(candidate_names), type=str, default='')
1282+
if len(candidate_names) == 1:
1283+
candidate = click.prompt('Candidate ', type=str, default=candidate_names[0])
1284+
else:
1285+
candidate = click.prompt('Candidate ' + str(candidate_names), type=str, default='')
12831286

12841287
if action == 'failover' and not candidate:
12851288
raise PatroniCtlException('Failover could be performed only to a specific candidate')
@@ -1676,7 +1679,7 @@ def get_cluster_service_info(cluster: Dict[str, Any]) -> List[str]:
16761679

16771680

16781681
if 'multisite' in cluster:
1679-
info = f"Multisite {cluster['multisite']['name'] or ''} is {cluster['multisite']['status'].lower()}"
1682+
info = f"Multisite {cluster['multisite'].get('name') or ''} is {cluster['multisite']['status'].lower()}"
16801683
standby_config = cluster['multisite'].get('standby_config', {})
16811684
if standby_config and standby_config.get('host'):
16821685
info += f", replicating from {standby_config['leader_site']}"

0 commit comments

Comments
 (0)