Skip to content

Add win_wua reset/diagnostic-log functions for stuck Windows Updates - #70135

Open
twangboy wants to merge 3 commits into
saltstack:masterfrom
twangboy:feature/70101-wua-reset-and-logs
Open

Add win_wua reset/diagnostic-log functions for stuck Windows Updates#70135
twangboy wants to merge 3 commits into
saltstack:masterfrom
twangboy:feature/70101-wua-reset-and-logs

Conversation

@twangboy

Copy link
Copy Markdown
Contributor

What does this PR do?

Add reset_datastore, reset_catroot, and reset to run the standard Windows Update datastore/catalog-cache reset procedure (stop WU services, rename SoftwareDistribution/catroot2, restart services), and get_cbs_log / get_windows_update_log to retrieve CBS.log and the merged Windows Update log for diagnosis. Both log functions default to a bounded tail and support a substring pattern filter to stay event-bus-safe on large logs.

Motivated by #70101, where win_wua.install reports success for a previously-uninstalled KB but the update does not persist through a reboot. install()'s per-update ResultCode is already an honest result at call time; the failure happens later during the CBS commit phase, which these functions help diagnose (get_cbs_log/get_windows_update_log) and, as a last resort, recover from (reset*) without remoting into the box by hand.

Adds tests/pytests/unit/modules/test_win_wua.py coverage for all five functions and a changelog/70101.added.md fragment.

What issues does this PR fix or reference?

Fixes #70101

Merge requirements satisfied?

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

Commits signed with GPG?

Yes

@twangboy twangboy added this to the Potassium v3009.0 milestone Aug 25, 2026
@twangboy twangboy self-assigned this Aug 25, 2026
@twangboy
twangboy requested a review from a team as a code owner August 25, 2026 21:37
@twangboy twangboy added the test:full Run the full test suite label Aug 25, 2026
Add reset_datastore, reset_catroot, and reset to run the standard
Windows Update datastore/catalog-cache reset procedure (stop WU
services, rename SoftwareDistribution/catroot2, restart services),
and get_cbs_log / get_windows_update_log to retrieve CBS.log and the
merged Windows Update log for diagnosis. Both log functions default
to a bounded tail and support a substring pattern filter to stay
event-bus-safe on large logs.

Motivated by saltstack#70101, where win_wua.install reports success for a
previously-uninstalled KB but the update does not persist through a
reboot. install()'s per-update ResultCode is already an honest result
at call time; the failure happens later during the CBS commit phase,
which these functions help diagnose (get_cbs_log/get_windows_update_log)
and, as a last resort, recover from (reset*) without remoting into the
box by hand.

Adds tests/pytests/unit/modules/test_win_wua.py coverage for all five
functions and a changelog/70101.added.md fragment.
@twangboy
twangboy force-pushed the feature/70101-wua-reset-and-logs branch from bd661fa to 2964b73 Compare August 26, 2026 17:42
Replace a bare open() call with salt.utils.files.fopen() in
test_get_cbs_log_non_utf8_bytes_do_not_crash. saltpylint's
resource-leakage check (W8470) flags bare open() calls in test code,
which was failing the "Lint Salt's Test Suite" CI job.

Refs saltstack#70101
Add a File Handling note to agents/CLAUDE.md, agents/COPILOT.md,
agents/CURSOR.md, agents/GEMINI.md, and
agents/docs/module-templates.md instructing that
salt.utils.files.fopen() be used instead of the bare open() builtin.
saltpylint's resource-leakage check fails CI on any bare open() call,
in both source and test code, and this was missing from all four
agent instruction files.
@twangboy

Copy link
Copy Markdown
Contributor Author

Waiting for master to go green... then I'll rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: win_wua.install does not install patch when the patch was previously uninstalled

1 participant