Repository navigation
Cherry pick #122697 to 26.9: Fix restoring a lightweight snapshot from Azure when the source disk has a key prefix - #124254
Merged
Conversation
…has a key prefix The snapshot manifest records the source disk's object namespace, which for Azure is `<container>/<prefix>` when the disk endpoint has a path below the container (`AzureObjectStorage::getObjectsNamespace`), while S3 records only the bucket. The Azure `snapshot_reader_creator` used that namespace verbatim as a container name, so the reader's container-level existence check went to `.../<container>/<prefix>/?restype=container` and Azure rejected it with `400 InvalidUri`. Split the namespace into `container_name` and `endpoint.prefix`, mark the container as existing, and keep a connection-string account URL as is. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Move the namespace split out of the Azure backup engine's snapshot reader creator into `makeSnapshotSourceConnectionParams` in `BackupIO_AzureBlobStorage`, and cover it with a gtest: a prefixed namespace is split into container and prefix, a plain container namespace is unchanged, the backup's own connection params are not mutated, and a connection-string account URL is kept. Co-Authored-By: Claude Fable 5.1 <[email protected]>
With connection-string auth `createForContainer` builds the client from the connection string and ignores `storage_account_url`, so the recorded `original_endpoint` cannot be applied; leaving it unused would silently read the backup's account instead of the snapshot's. Compare the recorded endpoint with the connection string's blob endpoint (SDK-canonical, trailing slashes ignored) and throw `BAD_ARGUMENTS` when they name different accounts. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review: the lightweight-snapshot code path it covers is used only in Cloud, so the test stays in the Cloud repo (sync PR) instead. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ction string Review: the same account is reachable through several hosts (a private link alias, Azurite by IP or by host name), so comparing the manifest endpoint with the connection string's blob endpoint as URLs rejected valid restores. Compare the account names instead: the connection string's AccountName (or the account its blob endpoint names) against the account the manifest endpoint names, the first host label for `<account>.blob.<suffix>` and `<account>.privatelink.blob.<suffix>` hosts or the first path segment of a path-style endpoint. A URL that does not reveal its account, such as a custom domain, is let through and a wrong account fails at the first read. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…pshot endpoints that reveal none storageAccountOfURL took any non-empty path as a path-style account name, so a host-style endpoint that carries a path, e.g. https://acct.blob.core.windows.net/container/data/, named `container` rather than `acct`, and a restore from the backup's own account was rejected as a cross-account one. The host is now consulted first (`<account>.blob|dfs.<suffix>` and the privatelink aliases), and the first path segment is only taken as the account when the host names none, which is how Azurite endpoints look. With connection-string auth an endpoint that does not reveal its account (a custom domain) was let through on the assumption that a wrong account fails at the first read. It does not: the container is marked as existing, so nothing probes the source, and another account with the same container and key layout would be restored from silently. Such an endpoint is now rejected with BAD_ARGUMENTS as well. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review: a `storage_account_url` is recorded verbatim and may be a proxy whose path prefix is not an account, so the first path segment of an arbitrary URL proves nothing. Take it only when the host is an IPv4 address or a bare name (Azurite, localhost); any other host that is not an Azure one reveals no account and the connection-string check rejects it as unverifiable, instead of reporting a mismatch against a made-up account. An emulator reached through a dotted host name is rejected the same way; by IP or by a bare name it still compares by account. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The connection-string branch tried to prove that the connection string's own endpoint is equivalent to the recorded one (URL equality, then account names, then host and path rules), and every rule had a shape it got wrong: host aliases, hosts that reveal no account, proxy path prefixes, service paths that CreateFromConnectionString() drops. Stop proving equivalence instead: CreateFromConnectionString() takes the endpoint from the connection string alone, so point the connection string at the recorded endpoint by replacing its BlobEndpoint and let the key or SAS it carries authorise the reads there, or fail with Azure's refusal if it belongs to another account. That is what every other auth method and the S3 reader already do through storage_account_url. The recorded endpoint is reduced to a service URL first: query parameters (a SAS of the source disk) are dropped, and an endpoint recorded as a connection string (a source disk configured with one) is reduced to its blob endpoint. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…pshot-reader-namespace-prefix Fix restoring a lightweight snapshot from Azure when the source disk has a key prefix
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.
Original pull-request #122697
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job