Fix bundled waagent path resolution - #2211
Open
Linu George (linugeorgeofficial) wants to merge 2 commits into
Open
Fix bundled waagent path resolution#2211Linu George (linugeorgeofficial) wants to merge 2 commits into
Linu George (linugeorgeofficial) wants to merge 2 commits into
Conversation
Resolve bundled handler files relative to their source modules and tolerate an unset PYTHONPATH during waagent lookup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover bundled waagent loading from independent working directories and tolerate an unset PYTHONPATH. Document the VMBackup layout and standard-library test workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Linu George (linugeorgeofficial)
marked this pull request as ready for review
September 8, 2026 05:50
Linu George (linugeorgeofficial)
requested a review
from a team
as a code owner
September 8, 2026 05:50
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
• Resolve the bundled WaagentLib.py relative to WAAgentUtil.py instead of the process current working directory.
• Resolve handle.sh relative to handle.py .
• Treat an unset PYTHONPATH as an empty search path instead of raising KeyError .
• Add focused unittest coverage and document the VMBackup test workflow.
Problem
WAAgentUtil.py currently locates the bundled main/WaagentLib.py through os.getcwd() . When the extension process starts from a different working directory, that lookup fails and VMBackup can fall back to the guest-installed waagent. Guest waagent versions are independently updated and may not be loadable as standalone modules; affected restore-point operations have failed with name 'shellutil' is not defined .
The fallback searches also index os.environ['PYTHONPATH'] directly. If that variable is unset, module initialization can instead fail with KeyError: 'PYTHONPATH' .
Scope
This refreshes the production changes from #2160 on the current master branch. The system-waagent and PYTHONPATH fallback behavior is intentionally retained to keep this PR scoped to correcting path resolution and the unset-environment failure. Removing those fallbacks changes recovery behavior when the bundled file is unavailable and should be evaluated separately.
README.txt is replaced with README.md to document the extension layout and dependency-free unit-test command. Packaging continues to exclude the existing VMBackup/test directory.