Skip to content

Commit ee8e44b

Browse files
DPE-7726: Stop propogating primary_endpoint=None for single unit app
It speedups the sinble unit app deployments.
1 parent 78db6a2 commit ee8e44b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/charm.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,17 @@ def primary_endpoint(self) -> str | None:
623623
# Force a retry if there is no primary or the member that was
624624
# returned is not in the list of the current cluster members
625625
# (like when the cluster was not updated yet after a failed switchover).
626-
if not primary_endpoint or primary_endpoint not in self._units_ips:
627-
# TODO figure out why peer data is not available
628-
if primary_endpoint and len(self._units_ips) == 1 and len(self._peers.units) > 1:
629-
logger.warning(
630-
"Possibly incomplete peer data: Will not map primary IP to unit IP"
631-
)
632-
return primary_endpoint
633-
logger.debug("primary endpoint early exit: Primary IP not in cached peer list.")
626+
if not primary_endpoint:
627+
logger.warning(f"Missing primary IP for {primary}")
634628
primary_endpoint = None
629+
elif primary_endpoint not in self._units_ips:
630+
if len(self._peers.units) == 0:
631+
logger.info(f"The unit didn't join {PEER} relation? Using {primary_endpoint}")
632+
elif len(self._units_ips) == 1 and len(self._peers.units) > 1:
633+
logger.warning(f"Possibly incomplete peer data, keep using {primary_endpoint}")
634+
else:
635+
logger.debug("Early exit primary_endpoint: Primary IP not in cached peer list")
636+
primary_endpoint = None
635637
except RetryError:
636638
return None
637639
else:

0 commit comments

Comments
 (0)