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 2 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
6 changes: 1 addition & 5 deletions src/machine_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ def _logrotate(self) -> machine_logrotate.LogRotate:
@property
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")
):
if self.is_externally_accessible(event=None) and self.config.get("vip"):
return self.config["vip"]
Copy link
Contributor

Choose a reason for hiding this comment

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

if ha_cluster.is_clustered() is False, will router be providing a non-accessible endpoint in the databag? is that desired?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on that. Can this just be transient condition though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change was made to support the use case where the VIP is somehow configured outside of hacluster. however, it is possible to confirm that hacluster is clustered if a relation with hacluster exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking _ha_cluster.is_clustered() only if relation with _ha_cluster exists in 03c5777

return str(self.model.get_binding("juju-info").network.bind_address)

Expand Down
8 changes: 1 addition & 7 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 Down Expand Up @@ -57,11 +55,7 @@ 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
):
if self.charm.unit.is_leader() and vip:
return ops.ActiveStatus(f"VIP: {vip}")
Copy link
Contributor

Choose a reason for hiding this comment

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

if workload is not running we shouldn't set active status

also follow-up to #177 (comment)

also this could also be an issue for refresh, where active status with vip will block refresh status (https://github.com/canonical/charm-refresh/blob/main/docs/requirements_and_user_experience.md#lower-priority-statuses)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed ActiveStatus setting on leader unit in 49ce228


def set_vip(self, vip: Optional[str]) -> None:
Expand Down
Loading