Skip to content

Commit

Permalink
Add label
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Jul 17, 2024
1 parent fac63bd commit 90a70c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ def patch_port(self, use_node_port: bool = False) -> None:
name=service_name,
namespace=self._namespace,
ownerReferences=pod0.metadata.ownerReferences,
labels={
"app.kubernetes.io/name": self.app.name,
},
),
spec=lightkube.models.core_v1.ServiceSpec(
selector={"app.kubernetes.io/name": self.app.name},
Expand Down
4 changes: 2 additions & 2 deletions src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def _on_pgbouncer_pebble_ready(self, event: WorkloadEvent) -> None:
if self.state not in ["upgrading", "recovery"]:
return

if self.charm.unit.is_leader():
self.charm.patch_port(self.charm.client_relation.external_connectivity())
if self.charm.unit.is_leader() and self.charm.client_relation.external_connectivity():
self.charm.patch_port(True)
for relation in self.model.relations.get(CLIENT_RELATION_NAME, []):
self.charm.client_relation.update_connection_info(relation)

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ def test_patch_port(self, _client):
name="pgbouncer-k8s-nodeport",
namespace=self.charm._namespace,
ownerReferences=_client.return_value.get.return_value.metadata.ownerReferences,
labels={"app.kubernetes.io/name": "pgbouncer-k8s"},
),
spec=lightkube.models.core_v1.ServiceSpec(
selector={"app.kubernetes.io/name": self.charm.app.name},
Expand Down

0 comments on commit 90a70c0

Please sign in to comment.