Skip to content

Commit

Permalink
fix: move restart logic from config changed to install event handler (#…
Browse files Browse the repository at this point in the history
…132)

fix: move restart logic from config changed to install event handler

Move the restart logic from _on_config_changed() to _on_install() event handler so it handles a number of scenarios that depend on the service restart:

* Going from RawDeployment to Serverless mode is activated before the knative-relation exists
* Going from Serverless mode to RawDeployment
  • Loading branch information
DnPlas authored Jun 16, 2023
1 parent b1084ad commit 1eacbd6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions charms/kserve-controller/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def _on_install(self, event):
self.unit.status = MaintenanceStatus("Creating k8s resources")
self.k8s_resource_handler.apply()
self.cm_resource_handler.apply()

# The kserve-controller service must be restarted whenever the
# configuration is changed, otherwise the service will remain
# unaware of such changes.
self._restart_controller_service()
except ErrorWithStatus as err:
self.model.unit.status = err.status
log.error(f"Failed to handle {event} with error: {err}")
Expand All @@ -271,13 +276,9 @@ def _on_install(self, event):
self.model.unit.status = ActiveStatus()

def _on_config_changed(self, event):
"""Handle the config changed event."""
self._on_install(event)

# The kserve-controller service must be restarted whenever the
# configuration is changed, otherwise the service will remain
# unaware of such changes.
self._restart_controller_service()

def _on_remove(self, _):
self.unit.status = MaintenanceStatus("Removing k8s resources")
k8s_resources_manifests = self.k8s_resource_handler.render_manifests()
Expand Down

0 comments on commit 1eacbd6

Please sign in to comment.