From 13189adfaaac62cf90440821dd666637f126a25b Mon Sep 17 00:00:00 2001 From: Zach Hilliard Date: Tue, 14 Feb 2023 13:24:58 -0600 Subject: [PATCH] Adding in check to restart sesnor if token is expired --- st2reactor/st2reactor/container/process_container.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/st2reactor/st2reactor/container/process_container.py b/st2reactor/st2reactor/container/process_container.py index 890bcccbb9..a1825f1eb5 100644 --- a/st2reactor/st2reactor/container/process_container.py +++ b/st2reactor/st2reactor/container/process_container.py @@ -214,6 +214,18 @@ def _poll_sensors_for_results(self, sensor_ids): # Sensor has been successfully running more than threshold seconds, clear the # respawn counter so we can try to restart the sensor if it dies later on self._sensor_respawn_counts[sensor_id] = 0 + if now - sensor_start_time >= cfg.CONF.auth.service_token_ttl: + sensor = self._sensors[sensor_id] + self._delete_sensor(sensor_id) + self._dispatch_trigger_for_sensor_exit(sensor, exit_code=status) + concurrency.spawn( + self._respawn_sensor, + sensor_id=sensor_id, + sensor=sensor, + exit_code=status, + ) + + def running(self): return len(self._processes)