Skip to content

[ESM] Remove warning when worker shutdown is graceful #12307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def __init__(
function_version = get_function_version_from_arn(self.esm_config["FunctionArn"])
self._state = lambda_stores[function_version.id.account][function_version.id.region]

# HACK: Flag used to check if a graceful shutdown was triggered.
self._graceful_shutdown_triggered = False

@property
def uuid(self) -> str:
return self.esm_config["UUID"]
Expand All @@ -83,6 +86,7 @@ def stop_for_shutdown(self):
# Signal the worker's poller_loop thread to gracefully shutdown
# TODO: Once ESM state is de-coupled from lambda store, re-think this approach.
self._shutdown_event.set()
self._graceful_shutdown_triggered = True

def create(self):
if self.enabled:
Expand Down Expand Up @@ -166,7 +170,9 @@ def poller_loop(self, *args, **kwargs):
self.current_state = EsmState.DISABLED
self.state_transition_reason = self.user_state_reason
self.update_esm_state_in_store(EsmState.DISABLED)
else:
elif not self._graceful_shutdown_triggered:
# HACK: If we reach this state and a graceful shutdown was not triggered, log a warning to indicate
# an unexpected state.
LOG.warning(
"Invalid state %s for event source mapping %s.",
self.current_state,
Expand Down
Loading