Fix Azure snapshot create payload for azure-mgmt-compute 38+#1188
Open
jihokim-tibero wants to merge 1 commit into
Open
Fix Azure snapshot create payload for azure-mgmt-compute 38+#1188jihokim-tibero wants to merge 1 commit into
jihokim-tibero wants to merge 1 commit into
Conversation
azure-mgmt-compute 38.0.0 ships a stricter request deserializer that rejects the flat dict barman previously passed to `snapshots.begin_create_or_update`: ERROR: Backup failed uploading data ((InvalidRequestContent) The request content was invalid and could not be deserialized: 'Could not find member 'incremental' on object of type 'ResourceDefinition'. Path 'incremental', line 1, position 45.'.) `Snapshot._attribute_map` puts `incremental` and `creation_data` under `properties.*` on the wire, so the flat dict is neither a Snapshot instance nor wire-format JSON. Build the payload with the `Snapshot`/`CreationData` model objects instead — that works on both the lenient and strict deserializer tracks. Closes EnterpriseDB#1186.
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
Fixes #1186 —
barman-cloud-backup --cloud-provider azure-blob-storage --snapshot-instance ...fails immediately on a fresh install becauseazure-mgmt-compute>=38.0.0ships a stricter request deserializer that rejects the flat dict barman passes tosnapshots.begin_create_or_update:Snapshot._attribute_mapputsincrementalandcreation_dataunderproperties.*on the wire, so the flat dict is neither aSnapshotmodel instance nor wire-format JSON. Older azure-mgmt-compute releases accepted it leniently; 38.0.0 does not.Change
Build the request payload with the
Snapshot/CreationDatamodel objects fromazure.mgmt.compute.modelsinstead of a flat dict. Model objects are unambiguous regardless of the SDK's deserializer mode and work on both old and newazure-mgmt-computereleases.The model classes are resolved via the existing
import_azure_mgmt_compute()helper to preserve the deferred-import pattern this module already uses.Test plan
pytest tests/test_cloud_snapshot_interface.py— 172 passed (locally, Python 3.11)pytest tests/test_cloud_snapshot_interface.py::TestAzureCloudSnapshotInterface— 29 passedazure-mgmt-compute==38.0.0— installing this branch alongsideazure-mgmt-compute==38.0.0and re-running the originalbarman-cloud-backupcommand produces a successful snapshot.Related
setup.py'sazure-snapshotsextra has no upper bound onazure-mgmt-compute, so a freshpip installauto-picks the broken version. With this fix applied that pin is no longer strictly required, but a documented lower bound (or short-term upper bound until this lands in a release) may still be worth considering — happy to open a follow-up if you'd like.cc @didorgas @martinmarques