Skip to content

Commit 172b605

Browse files
[MISC] Clean up TLS SANs + avoid deleting and recreating K8s service (#386)
## Issue 1. We are deleting and re-creating K8s service as a result of a juju bug (https://bugs.launchpad.net/juju/+bug/2084711) which would cause integration tests to fail. The juju bug is no longer reproducible in juju 3.6.2 2. We have a number of unreachable DNS names which are included in the SANs when constructing the TLS CSR ## Solution 1. Avoid deleting and recreating the service 2. Clean up unreachable DNS names
1 parent 89dbe94 commit 172b605

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

src/charm.py

+1-25
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _status(self) -> ops.StatusBase:
130130
):
131131
return ops.MaintenanceStatus("Waiting for K8s service connectivity")
132132
else:
133-
return ops.BlockedStatus("K8s service not connectible")
133+
return ops.BlockedStatus("K8s service not connectable")
134134

135135
def is_externally_accessible(self, *, event) -> typing.Optional[bool]:
136136
"""No-op since this charm is exposed with the expose-external config."""
@@ -221,30 +221,6 @@ def _reconcile_service(self) -> None:
221221
),
222222
)
223223

224-
# Delete and re-create until https://bugs.launchpad.net/juju/+bug/2084711 resolved
225-
if service_exists:
226-
logger.info(f"Issuing delete service {service_type=}")
227-
self._lightkube_client.delete(
228-
res=lightkube.resources.core_v1.Service,
229-
name=self.service_name,
230-
namespace=self.model.name,
231-
)
232-
logger.info(f"Deleting service {service_type=}")
233-
234-
try:
235-
for attempt in tenacity.Retrying(
236-
reraise=True,
237-
stop=tenacity.stop_after_delay(10),
238-
wait=tenacity.wait_fixed(1),
239-
):
240-
with attempt:
241-
assert self._get_service() is not None
242-
except AssertionError:
243-
logger.warning("Deletion of service took longer than expected")
244-
return
245-
else:
246-
logger.debug(f"Deleted service {service_type=}")
247-
248224
logger.info(f"Creating desired service {desired_service_type=}")
249225
self._lightkube_client.apply(desired_service, field_manager=self.app.name)
250226

src/relations/tls.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,15 @@ def _generate_csr(self, key: bytes) -> bytes:
124124
sans_dns=[
125125
socket.getfqdn(),
126126
service_name,
127+
f"{service_name}.{self._charm.model_service_domain}",
127128
unit_name,
128-
f"{service_name}.{self._charm.app.name}-endpoints",
129129
f"{unit_name}.{self._charm.app.name}-endpoints",
130-
f"{self._charm.app.name}.{self._charm.app.name}-endpoints",
131-
f"{service_name}.{self._charm.app.name}-endpoints.{self._charm.model_service_domain}",
132130
f"{unit_name}.{self._charm.app.name}-endpoints.{self._charm.model_service_domain}",
133-
f"{self._charm.app.name}.{self._charm.app.name}-endpoints.{self._charm.model_service_domain}",
131+
self._charm.app.name,
132+
f"{self._charm.app.name}.{self._charm.app.name}-endpoints",
133+
f"{self._charm.app.name}.{self._charm.app.name}-endpoints.{self._charm.model_service_domain}"
134134
f"{self._charm.app.name}-endpoints",
135135
f"{self._charm.app.name}-endpoints.{self._charm.model_service_domain}",
136-
f"{service_name}.{self._charm.app.name}",
137-
f"{unit_name}.{self._charm.app.name}",
138-
f"{self._charm.app.name}.{self._charm.app.name}",
139-
f"{service_name}.{self._charm.app.name}.{self._charm.model_service_domain}",
140-
f"{unit_name}.{self._charm.app.name}.{self._charm.model_service_domain}",
141-
f"{self._charm.app.name}.{self._charm.app.name}.{self._charm.model_service_domain}",
142-
self._charm.app.name,
143136
f"{self._charm.app.name}.{self._charm.model_service_domain}",
144137
*extra_hosts,
145138
],

0 commit comments

Comments
 (0)