Skip to content

Commit b1c40ae

Browse files
committed
you can't close client
1 parent 1bfd8db commit b1c40ae

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/charm.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,12 @@ def _on_webhook_mutator_pebble_ready(self, event) -> None:
714714
generate_mutating_webhook(
715715
client, self.unit, self.model.name, cert, self.mutator_service_name
716716
)
717-
client.close()
718717

719718
# We must ensure that juju does not overwrite our termination period, so we should update
720719
# it as needed. However, updating the termination period can result in an onslaught of
721-
# events, including the upgrade event. To prevent this from messing with upgrades do not
722-
# update the termination period when an upgrade is occurring.
720+
# events, including the upgrade event.
721+
# To prevent this from messing with upgrades do not update the termination period when an
722+
# upgrade is occurring.
723723
if self.get_current_termination_period() != ONE_YEAR and not self.upgrade_in_progress:
724724
self.update_termination_grace_period_to_one_year()
725725

@@ -989,7 +989,6 @@ def get_current_termination_period(self) -> int:
989989
"""Returns the current termination period for the stateful set of this juju application."""
990990
client = Client()
991991
statefulset = client.get(StatefulSet, name=self.app.name, namespace=self.model.name)
992-
client.close()
993992
return statefulset.spec.template.spec.terminationGracePeriodSeconds
994993

995994
def get_termination_period_for_pod(self) -> int:
@@ -998,7 +997,6 @@ def get_termination_period_for_pod(self) -> int:
998997
client = Client()
999998
pod = client.get(Pod, name=pod_name, namespace=self.model.name)
1000999
termination_grace_period = pod.spec.terminationGracePeriodSeconds
1001-
client.close()
10021000
return termination_grace_period
10031001

10041002
def update_termination_grace_period_to_one_year(self) -> None:
@@ -1021,7 +1019,6 @@ def update_termination_grace_period_to_one_year(self) -> None:
10211019
)
10221020
# Works because we're leader.
10231021
self.needs_new_termination_period = False
1024-
client.close()
10251022

10261023
def __handle_partition_on_stop(self) -> None:
10271024
"""Raise partition to prevent other units from restarting if an upgrade is in progress.

0 commit comments

Comments
 (0)