Skip to content

Commit

Permalink
fix: use force for lightkube.Client.apply (#148)
Browse files Browse the repository at this point in the history
This adds `force` to all `lightkube.Client.apply()` calls to mitigate [this issue](#147)
  • Loading branch information
ca-scribner authored Jun 12, 2023
1 parent 72a592f commit 58a245b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,10 @@ def _check_and_report_k8s_conflict(self, error):
return True
return False

def _apply_k8s_resources(self, force_conflicts: bool = False) -> None:
# TODO: force_conflicts=True to work around issue
# https://github.com/canonical/seldon-core-operator/issues/147. Remove this when we have
# a better solution.
def _apply_k8s_resources(self, force_conflicts: bool = True) -> None:
"""Apply K8S resources.
Args:
Expand Down Expand Up @@ -355,15 +358,21 @@ def _apply_k8s_resources(self, force_conflicts: bool = False) -> None:
def _on_install(self, _):
"""Installation only tasks."""
# deploy K8S resources to speed up deployment
self._apply_k8s_resources()
# TODO: force_conflicts=True to work around issue
# https://github.com/canonical/seldon-core-operator/issues/147. Remove this when we have
# a better solution.
self._apply_k8s_resources(force_conflicts=True)

def _on_pebble_ready(self, event):
"""Configure started container."""
if not self._upload_certs_to_container(event):
return

# proceed with other actions
self._on_event(event)
# TODO: force_conflicts=True to work around issue
# https://github.com/canonical/seldon-core-operator/issues/147. Remove this when we have
# a better solution.
self._on_event(event, force_conflicts=True)

def _on_upgrade(self, event):
"""Perform upgrade steps."""
Expand Down Expand Up @@ -508,7 +517,10 @@ def _get_istio_gateway(self):
istio_gateway = gateway_info["gateway_namespace"] + "/" + gateway_info["gateway_name"]
return istio_gateway

def _on_event(self, event, force_conflicts: bool = False) -> None:
# TODO: force_conflicts=True to work around issue
# https://github.com/canonical/seldon-core-operator/issues/147. Remove this when we have
# a better solution.
def _on_event(self, event, force_conflicts: bool = True) -> None:
"""Perform all required actions for the Charm.
Args:
Expand Down

0 comments on commit 58a245b

Please sign in to comment.