Skip to content

Commit

Permalink
fix: remove logrotate
Browse files Browse the repository at this point in the history
  • Loading branch information
nsklikas committed Oct 25, 2023
1 parent 839b2e6 commit b11c9b8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
20 changes: 0 additions & 20 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@
]

LOG_FILE = "/var/log/openfga-k8s"
LOGROTATE_CONFIG_PATH = "/etc/logrotate.d/openfga"

OPENFGA_SERVER_PORT = 8080

LOG_FILE = "/var/log/openfga-k8s"
LOGROTATE_CONFIG_PATH = "/etc/logrotate.d/openfga"

OPENFGA_SERVER_PORT = 8080

Expand Down Expand Up @@ -191,9 +189,6 @@ def _on_leader_elected(self, event):
@requires_state
def _update_workload(self, event):
"""' Update workload with all available configuration data."""
# Quickly update logrotates config each workload update
self._push_to_workload(LOGROTATE_CONFIG_PATH, self._get_logrotate_config(), event)

container = self.unit.get_container(WORKLOAD_CONTAINER)
# make sure we can connect to the container
if not container.can_connect():
Expand All @@ -203,9 +198,6 @@ def _update_workload(self, event):

self._create_token(event)

# Quickly update logrotates config each workload update
self._push_to_workload(LOGROTATE_CONFIG_PATH, self._get_logrotate_config(), event)

dnsname = "{}.{}-endpoints.{}.svc.cluster.local".format(
self.unit.name.replace("/", "-"), self.app.name, self.model.name
)
Expand Down Expand Up @@ -553,18 +545,6 @@ def _on_ingress_revoked(self, event: IngressPerAppRevokedEvent):

self._update_workload(event)

def _get_logrotate_config(self):
return f"""{LOG_FILE} {"{"}
rotate 3
daily
compress
delaycompress
missingok
notifempty
size 10M
{"}"}
"""

def _push_to_workload(self, filename, content, event):
"""Pushes file to the workload container.
Expand Down
20 changes: 0 additions & 20 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ def setUp(self, *unused):

self.harness.container_pebble_ready("openfga")

def test_logrotate_config_pushed(self):
self.harness.set_leader(True)

rel_id = self.harness.add_relation("peer", "openfga")
self.harness.add_relation_unit(rel_id, "openfga-k8s/1")
self.harness.charm._state.token = "test-token"
self.harness.charm._state.schema_created = "true"
self.harness.charm._state.db_uri = "test-db-uri"
self.harness.charm._state.private_key = "test-key"
self.harness.charm._state.certificate = "test-cert"
self.harness.charm._state.ca = "test-ca"
self.harness.charm._state.key_chain = "test-chain"
self.harness.charm._state.dns_name = "test-dns-name"

container = self.harness.model.unit.get_container("openfga")
self.harness.charm.on.openfga_pebble_ready.emit(container)
root = self.harness.get_filesystem_root("openfga")
config = (root / "etc/logrotate.d/openfga").read_text()
self.assertIn("/var/log/openfga-k8s {", config)

@patch("secrets.token_urlsafe")
def test_on_config_changed(self, token_urlsafe):
token_urlsafe.return_value = "a_test_secret"
Expand Down

0 comments on commit b11c9b8

Please sign in to comment.