Skip to content

Commit 459f1f6

Browse files
authored
[MISC] Increase coverage (#505)
* Bump libs * Tweak asserts * Bump topology coverage * Increase charm coverage * Increase coverage on charm * Bump libs
1 parent 885ab0c commit 459f1f6

File tree

11 files changed

+498
-261
lines changed

11 files changed

+498
-261
lines changed

lib/charms/postgresql_k8s/v0/postgresql.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Increment this PATCH version before using `charmcraft publish-lib` or reset
3838
# to 0 if you are raising the major API version
39-
LIBPATCH = 28
39+
LIBPATCH = 29
4040

4141
INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"
4242

@@ -604,12 +604,11 @@ def build_postgresql_parameters(
604604
# Use 25% of the available memory for shared_buffers.
605605
# and the remaining as cache memory.
606606
shared_buffers = int(available_memory * 0.25)
607+
parameters["shared_buffers"] = f"{int(shared_buffers * 128 / 10**6)}"
607608
effective_cache_size = int(available_memory - shared_buffers)
608-
parameters.setdefault("shared_buffers", f"{int(shared_buffers / 10**6)}MB")
609-
parameters.update({"effective_cache_size": f"{int(effective_cache_size / 10**6)}MB"})
610-
else:
611-
# Return default
612-
parameters.setdefault("shared_buffers", "128MB")
609+
parameters.update({
610+
"effective_cache_size": f"{int(effective_cache_size / 10**6) * 128}"
611+
})
613612
return parameters
614613

615614
def validate_date_style(self, date_style: str) -> bool:

lib/charms/postgresql_k8s/v0/postgresql_tls.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from ops.charm import ActionEvent, RelationBrokenEvent
3535
from ops.framework import Object
3636
from ops.pebble import ConnectionError, PathError, ProtocolError
37+
from tenacity import RetryError
3738

3839
# The unique Charmhub library identifier, never change it
3940
LIBID = "c27af44a92df4ef38d7ae06418b2800f"
@@ -43,7 +44,7 @@
4344

4445
# Increment this PATCH version before using `charmcraft publish-lib` or reset
4546
# to 0 if you are raising the major API version.
46-
LIBPATCH = 8
47+
LIBPATCH = 9
4748

4849
logger = logging.getLogger(__name__)
4950
SCOPE = "unit"
@@ -142,7 +143,7 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
142143
logger.debug("Cannot push TLS certificates at this moment")
143144
event.defer()
144145
return
145-
except (ConnectionError, PathError, ProtocolError) as e:
146+
except (ConnectionError, PathError, ProtocolError, RetryError) as e:
146147
logger.error("Cannot push TLS certificates: %r", e)
147148
event.defer()
148149
return

0 commit comments

Comments
 (0)