Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always return VIP as host if set #179

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/machine_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ def _logrotate(self) -> machine_logrotate.LogRotate:
def host_address(self) -> str:
"""The host address for the machine."""
if (
self._ha_cluster.relation
and self._ha_cluster.is_clustered()
and self.config.get("vip")
not self.is_externally_accessible(event=None)
or not self.config.get("vip")
or (self._ha_cluster and not self._ha_cluster.is_clustered())
Comment on lines -90 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check for ha_cluster.relation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a check in is_clustered() to return false if no relation formed yet in 49ce228

):
return self.config["vip"]
return str(self.model.get_binding("juju-info").network.bind_address)
return str(self.model.get_binding("juju-info").network.bind_address)

return self.config["vip"]

@property
def _read_write_endpoint(self) -> str:
Expand Down
12 changes: 3 additions & 9 deletions src/relations/hacluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import ops

import workload

HACLUSTER_RELATION_NAME = "ha"

logger = logging.getLogger(__name__)
Expand All @@ -36,6 +34,9 @@ def relation(self) -> Optional[ops.Relation]:

def is_clustered(self) -> bool:
"""Check if the related hacluster charm is clustered."""
if not self.relation:
return False

for key, value in self.relation.data.items():
if (
isinstance(key, ops.Unit)
Expand All @@ -57,13 +58,6 @@ def get_unit_juju_status(self) -> ops.StatusBase:
if vip and not self.charm.is_externally_accessible(event=None):
return ops.BlockedStatus("vip configuration without data-integrator")

if (
isinstance(self.charm.get_workload(event=None), workload.AuthenticatedWorkload)
and self.charm.unit.is_leader()
and vip
):
return ops.ActiveStatus(f"VIP: {vip}")

def set_vip(self, vip: Optional[str]) -> None:
"""Adds the requested virtual IP to the integration."""
if not self.relation:
Expand Down
Loading