Add win_wua reset/diagnostic-log functions for stuck Windows Updates - #70135
Open
twangboy wants to merge 3 commits into
Open
Add win_wua reset/diagnostic-log functions for stuck Windows Updates#70135twangboy wants to merge 3 commits into
twangboy wants to merge 3 commits into
Conversation
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
force-pushed
the
feature/70101-wua-reset-and-logs
branch
from
August 26, 2026 17:42
bd661fa to
2964b73
Compare
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.
Contributor
Author
|
Waiting for master to go green... then I'll rebase |
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?
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