Skip to content

Commit

Permalink
Use stored state to track initialization of MAAS
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattrees committed Oct 30, 2024
1 parent 68aa3b3 commit be53a7d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions maas-region/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(self, *args):
# Charm configuration
self.framework.observe(self.on.config_changed, self._on_config_changed)

self.maas_initialized_once = False
self._stored.set_default(maas_initialized_once=False)

@property
def peers(self) -> Union[ops.Relation, None]:
Expand Down Expand Up @@ -237,9 +237,9 @@ def _initialize_maas(self) -> bool:
MaasHelper.setup_region(
self.maas_api_url, self.connection_string, self.get_operational_mode()
)
if not self.maas_initialized_once:
if not self._stored.maas_initialized_once:
self._update_tls_config()
self.maas_initialized_once = True
self._stored.maas_initialized_once = True
return True
except subprocess.CalledProcessError:
return False
Expand Down Expand Up @@ -470,7 +470,7 @@ def _on_config_changed(self, event: ops.ConfigChangedEvent):
"Both ssl_cert_content and ssl_key_content must be defined when using tls_mode=passthrough"
)
self._update_ha_proxy()
if self.maas_initialized_once:
if self._stored.maas_initialized_once:
self._update_tls_config()


Expand Down

0 comments on commit be53a7d

Please sign in to comment.