Fail fast on unresolvable master DNS in forked minion workers#69660
Open
twangboy wants to merge 2 commits into
Open
Fail fast on unresolvable master DNS in forked minion workers#69660twangboy wants to merge 2 commits into
twangboy wants to merge 2 commits into
Conversation
sujitdb
approved these changes
Jul 2, 2026
sujitdb
left a comment
Collaborator
There was a problem hiding this comment.
LGTM , lets wait for the test to pass
A forked per-job worker inherits the minion's default retry_dns=30 / retry_dns_count=None settings. If the job it runs resolves the master DNS (e.g. status.ping_master or master-alive checks) while the master hostname is unresolvable, resolve_dns() enters its unbounded while-True retry loop and the worker never returns. The loop's abort hook (_RESOLVE_DNS_ABORT, saltstack#69466) cannot rescue it: the event is a module-level threading.Event and a forked child holds its own dead copy that the parent's SIGTERM handler can never set. The wedged worker is therefore only killable via SIGKILL, and since SubprocessList cleanup only reaps already-exited processes, hung workers accumulate. A minion pointed at an unresolvable master leaked hundreds of workers and ~10GB of RAM over a couple of days. Bound DNS retries in the worker preamble (Minion._target): when the operator has not set retry_dns_count, force it to 0 so resolve_dns raises SaltMasterUnresolvableError on the first attempt, the worker exits, and it is reaped normally. An explicit retry_dns_count is still honored. This only shortcuts DNS-resolution failure, never job execution time, so it cannot kill a legitimate long-running job. The main minion process is unchanged (still retries by default; bounded opt-in via retry_dns_count), mirroring the existing failover path that already forces retry_dns=0.
pre-commit's black hook collapses the patch.object/patch context manager in test_target_bounds_worker_dns_retry onto black's preferred line layout. No functional change.
10a4659 to
cadcfcb
Compare
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.
What does this PR do?
A forked per-job worker inherits the minion's default retry_dns=30 / retry_dns_count=None settings. If the job it runs resolves the master DNS (e.g. status.ping_master or master-alive checks) while the master hostname is unresolvable, resolve_dns() enters its unbounded while-True retry loop and the worker never returns.
The loop's abort hook (_RESOLVE_DNS_ABORT, #69466) cannot rescue it: the event is a module-level threading.Event and a forked child holds its own dead copy that the parent's SIGTERM handler can never set. The wedged worker is therefore only killable via SIGKILL, and since SubprocessList cleanup only reaps already-exited processes, hung workers accumulate. A minion pointed at an unresolvable master leaked hundreds of workers and ~10GB of RAM over a couple of days.
Bound DNS retries in the worker preamble (Minion._target): when the operator has not set retry_dns_count, force it to 0 so resolve_dns raises SaltMasterUnresolvableError on the first attempt, the worker exits, and it is reaped normally. An explicit retry_dns_count is still honored. This only shortcuts DNS-resolution failure, never job execution time, so it cannot kill a legitimate long-running job. The main minion process is unchanged (still retries by default; bounded opt-in via retry_dns_count), mirroring the existing failover path that already forces retry_dns=0.
What issues does this PR fix or reference?
Fixes #69659
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes