Preserve EventPublisher setproctitle across MasterPubServerChannel respawns - #70124
Open
dwoz wants to merge 2 commits into
Open
Preserve EventPublisher setproctitle across MasterPubServerChannel respawns#70124dwoz wants to merge 2 commits into
dwoz wants to merge 2 commits into
Conversation
…spawns MasterPubServerChannel.pre_fork registers _publish_daemon with ProcessManager.add_process using name="EventPublisher", so the initial fork sets the process title to "EventPublisher". ProcessManager.restart_process, however, drops the name= kwarg when respawning, so after any restart the fallback __qualname__ (MasterPubServerChannel._publish_daemon) is used instead. Operator monitoring that greps for "EventPublisher" silently breaks after the first respawn. Set the process title explicitly at the top of _publish_daemon so both the initial fork and every respawn end up with the same "EventPublisher" title. Keep the name="EventPublisher" kwarg on the add_process call so the historical initial-fork label continues to appear as well. Sibling of PR saltstack#70111 (same bug pattern for FileserverUpdate).
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MasterPubServerChannel.pre_forkregisters_publish_daemonwithProcessManager.add_processusingname="EventPublisher", so theinitial fork sets the process title to
EventPublisher(the historicallabel kept for backwards compat with operator tooling).
ProcessManager.restart_process, however, drops thename=kwargwhen respawning — so after any restart the fallback
__qualname__(
MasterPubServerChannel._publish_daemon) is used instead. The samelogical process ends up with two different titles across its lifetime,
and any grep/pgrep/log-correlation monitoring keyed on
EventPublishersilently breaks the first time the daemon is restarted.
The fix sets the process title explicitly at the top of
_publish_daemonso both the initial fork and every respawn end up withthe same
EventPublisherstring. Thename="EventPublisher"kwarg onthe
add_processcall is intentionally left alone so the historicallabel continues to appear on initial fork too.
Sibling of #70111 (same bug pattern, different class —
FileserverUpdate).Test plan
tests/pytests/unit/channel/test_server.py::test_publish_daemon_sets_eventpublisher_process_titlepatches
setproctitle.setproctitleand asserts_publish_daemoncalls it with
"EventPublisher"before any other work.salt/channel/server.py(AssertionError on the
hasattr(server, "setproctitle")guard) andpasses with the fix applied.
pre-commit runclean on all changed files.test:fulllabel added).