@@ -1743,7 +1743,9 @@ def get_cluster_service_info(cluster: Dict[str, Any]) -> List[str]:
17431743 if 'multisite' in cluster :
17441744 info = f"Multisite { cluster ['multisite' ].get ('name' ) or '' } is { cluster ['multisite' ]['status' ].lower ()} "
17451745 standby_config = cluster ['multisite' ].get ('standby_config' , {})
1746- if standby_config and standby_config .get ('host' ):
1746+ replicating_states = ['streaming' , 'in archive recovery' ]
1747+ leader = [m for m in cluster .get ('members' , []) if m ['role' ] == 'Standby Leader' ][0 ]
1748+ if standby_config and standby_config .get ('host' ) and leader and leader ['state' ] in replicating_states :
17471749 info += f", replicating from { standby_config ['leader_site' ]} "
17481750 info += f" ({ standby_config ['host' ]} :{ standby_config .get ('port' , 5432 )} )"
17491751 service_info .append (info )
@@ -1753,12 +1755,13 @@ def get_cluster_service_info(cluster: Dict[str, Any]) -> List[str]:
17531755 if 'members' in cluster :
17541756 r = reduce (ior , cluster ['members' ], {})
17551757 if 'latest_end_lsn' in r :
1756- lag_to_primary = r [ 'lag_to_primary' ]
1758+ lag_to_primary = r . get ( 'lag_to_primary' )
17571759 lag_to_primary = round (lag_to_primary / 1024 / 1024 ) if isinstance (lag_to_primary , int ) \
17581760 else '' if lag_to_primary == 'unknown' else lag_to_primary
1759- info = (f"The latest known LSN of the primary instance is { r ['latest_end_lsn' ]} , "
1760- f"the replication lag is { lag_to_primary } MB" )
1761- service_info .append (info )
1761+ if r ['latest_end_lsn' ] and lag_to_primary :
1762+ info = (f"The latest known LSN of the primary instance is { r ['latest_end_lsn' ]} , "
1763+ f"the replication lag is { lag_to_primary } MB" )
1764+ service_info .append (info )
17621765
17631766 if cluster .get ('pause' ):
17641767 service_info .append ('Maintenance mode: on' )
0 commit comments