Skip to content

fix(logging): tolerate unset options dict in worker bootstrap#69081

Open
TeddyAndrieux wants to merge 1 commit intosaltstack:masterfrom
TeddyAndrieux:bugfix/none-opts-when-set-logging
Open

fix(logging): tolerate unset options dict in worker bootstrap#69081
TeddyAndrieux wants to merge 1 commit intosaltstack:masterfrom
TeddyAndrieux:bugfix/none-opts-when-set-logging

Conversation

@TeddyAndrieux
Copy link
Copy Markdown
Contributor

@TeddyAndrieux TeddyAndrieux commented May 7, 2026

What does this PR do?

CLI parsers seed salt._logging's global options dict at startup via LogLevelMixIn.__setup_logging_config(). Non-CLI consumers (RunnerClient.asynchronous, SSHClient, salt.utils.process.Process subclasses, parallel states) have no parser, so the dict stays None.

Process.new snapshots that None into instance.logging_config; wrapped_run_func then calls set_logging_options_dict(None) defensively, which forwards to set_lowest_log_level_by_opts(None).get(...) and AttributeErrors on the worker. The parent exits 0 with a misleading "Target did not return any data" / dead jid / 'result': None.

Make set_logging_options_dict(None) and setup_logging() (when nothing has been seeded) no-op gracefully. Workers fall back to whatever logger configuration they inherited from the parent. CLI tools always seed before calling and are unaffected.

What issues does this PR fix or reference?

Fixes #68332

Previous Behavior

When using salt without CLI (using python API) some call throw errors during setup_logging phase.

New Behavior

No more error when setting up logging when using salt with python directly

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

CLI parsers seed salt._logging's global options dict at startup via
LogLevelMixIn.__setup_logging_config(). Non-CLI consumers
(RunnerClient.asynchronous, SSHClient, salt.utils.process.Process
subclasses, parallel states) have no parser, so the dict stays None.

Process.__new__ snapshots that None into instance.__logging_config__;
wrapped_run_func then calls set_logging_options_dict(None) defensively,
which forwards to set_lowest_log_level_by_opts(None).get(...) and
AttributeErrors on the worker. The parent exits 0 with a misleading
"Target did not return any data" / dead jid / 'result': None.

Make set_logging_options_dict(None) and setup_logging() (when nothing
has been seeded) no-op gracefully. Workers fall back to whatever logger
configuration they inherited from the parent. CLI tools always seed
before calling and are unaffected.

Fixes saltstack#68332

Signed-off-by: Teddy Andrieux <teddy.andrieux@scality.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: RunnerClient.asynchronous throws exception

1 participant