Skip to content

Fix bundled waagent path resolution - #2211

Open
Linu George (linugeorgeofficial) wants to merge 2 commits into
Azure:masterfrom
linugeorgeofficial:fix/vmbackup-waagent-loading
Open

Fix bundled waagent path resolution#2211
Linu George (linugeorgeofficial) wants to merge 2 commits into
Azure:masterfrom
linugeorgeofficial:fix/vmbackup-waagent-loading

Conversation

@linugeorgeofficial

@linugeorgeofficial Linu George (linugeorgeofficial) commented Sep 7, 2026

Copy link
Copy Markdown
Member

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.

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>
@linugeorgeofficial Linu George (linugeorgeofficial) changed the title VMBackup Shellutil Bug fix Fix bundled waagent path resolution Sep 8, 2026
@linugeorgeofficial
Linu George (linugeorgeofficial) marked this pull request as ready for review September 8, 2026 05:50
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.

1 participant