From dc2cfc3b9e41c06c0d0e070a64774e6dc1e42d7d Mon Sep 17 00:00:00 2001 From: Dominik Fleischmann Date: Thu, 28 May 2020 13:37:13 +0200 Subject: [PATCH 1/2] Make Squid Charm of Loadbalancer type By adding this change the squid charm will expose an external IP Signed-off-by: Dominik Fleischmann --- magma/hackfest_squid_cnf/charms/squid/metadata.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/magma/hackfest_squid_cnf/charms/squid/metadata.yaml b/magma/hackfest_squid_cnf/charms/squid/metadata.yaml index 30b0d014..aa3bbfa1 100644 --- a/magma/hackfest_squid_cnf/charms/squid/metadata.yaml +++ b/magma/hackfest_squid_cnf/charms/squid/metadata.yaml @@ -10,6 +10,9 @@ tags: - misc series: - kubernetes +deployment: + type: stateful + service: loadbalancer storage: docker: type: filesystem @@ -17,10 +20,4 @@ storage: spool: type: filesystem location: /var/spool/squid -# -- example relations, delete if unneeded -#requires: -# db: -# interface: mysql -#provides: -# website: -# interface: http + -- GitLab From d6eb55b0c950d30bc108f10e710456196f519610 Mon Sep 17 00:00:00 2001 From: Dominik Fleischmann Date: Thu, 28 May 2020 14:43:55 +0200 Subject: [PATCH 2/2] Improve Squid Charm code Remove unnecesary code in charm.py for a simpler example. Signed-off-by: Dominik Fleischmann --- .../charms/squid/src/charm.py | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/magma/hackfest_squid_cnf/charms/squid/src/charm.py b/magma/hackfest_squid_cnf/charms/squid/src/charm.py index 6e2eff40..67383ee8 100755 --- a/magma/hackfest_squid_cnf/charms/squid/src/charm.py +++ b/magma/hackfest_squid_cnf/charms/squid/src/charm.py @@ -65,7 +65,6 @@ class SquidK8SCharm(CharmBase): if not self.state.installed: logging.warning("Config changed called before install complete, deferring event: {}.".format(event.handle)) - self._defer_once(event) return @@ -81,7 +80,6 @@ class SquidK8SCharm(CharmBase): if not self.state.configured: logging.warning("Start called before configuration complete, deferring event: {}".format(event.handle)) - self._defer_once(event) return self.unit.status = MaintenanceStatus("Applying pod spec") @@ -93,28 +91,6 @@ class SquidK8SCharm(CharmBase): self.state.started = True logging.info("Started") - def _defer_once(self, event): - """Defer the given event, but only once.""" - notice_count = 0 - handle = str(event.handle) - - for event_path, _, _ in self.framework._storage.notices(None): - if event_path.startswith(handle.split('[')[0]): - notice_count += 1 - logging.debug("Found event: {} x {}".format(event_path, notice_count)) - - if notice_count > 1: - logging.debug("Not deferring {} notice count of {}".format(handle, notice_count)) - else: - logging.debug("Deferring {} notice count of {}".format(handle, notice_count)) - event.defer() - - def on_addconfig_action(self, event): - """Handle the example_action action.""" - event.log("Hello from the example action.") - event.set_results({"success": "true"}) - - if __name__ == "__main__": from ops.main import main main(SquidK8SCharm) -- GitLab