Skip to content

Commit

Permalink
Add keep_alive property to collect_logs (#2533) (#2535)
Browse files Browse the repository at this point in the history
(cherry picked from commit 47770b7)
  • Loading branch information
kevinclark19a authored Mar 15, 2022
1 parent 3eda39b commit be720fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions azurelinuxagent/common/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ def get_thread_name():
def run(self):
raise NotImplementedError("run() not implemented")

def keep_alive(self):
"""
Returns true if the thread handler should be restarted when the thread dies
and false when it should remain dead.
Defaults to True and can be overridden by sub-classes.
"""
return True

def is_alive(self):
raise NotImplementedError("is_alive() not implemented")

Expand Down
3 changes: 3 additions & 0 deletions azurelinuxagent/ga/collect_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ def __init__(self):
def run(self):
self.start()

def keep_alive(self):
return self.should_run

def is_alive(self):
return self.event_thread.is_alive()

Expand Down
2 changes: 1 addition & 1 deletion azurelinuxagent/ga/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def _check_daemon_running(self, debug):
def _check_threads_running(self, all_thread_handlers):
# Check that all the threads are still running
for thread_handler in all_thread_handlers:
if not thread_handler.is_alive():
if thread_handler.keep_alive() and not thread_handler.is_alive():
logger.warn("{0} thread died, restarting".format(thread_handler.get_thread_name()))
thread_handler.start()

Expand Down

0 comments on commit be720fe

Please sign in to comment.