Skip to content

Restore snapshot's relative path in quarantined requests

Sami Hiltunen requested to merge smh-extract-snapshot-path into master

Transactions in Gitaly operate against a snapshot of the repository to provide isolation. The snapshotting is done by copying the repository into a temporary directory and then rewriting the repository's relative path to point to the snapshot. The handler then operates on the rewritten request and targets the snapshot.

Writes may trigger the pre-receive hook. The pre-receive hook calls Rails to verify whether the change is allowed or not. These checks in Rails perform various follow up RPCs to Gitaly to verify whatever they need to verify. These follow up calls are configured with the quarantine directory sent from Gitaly to Rails. The quarantine paths are relative paths from the repository to the quarantine directory.

Before transactions, these quarantine paths were relative to the actual repository. As transactions operate against the snapshot repository, the quarantine paths are also relative to the snapshot repository. For the quarantine paths to apply correctly, the follow up requests from the access checks must also target the snapshot repository.

Rails has previously been updated to send the snapshot's relative path in a header to Gitaly. This commit changes Gitaly to extract the relative path from the header and use that in the request if the request has a quarantine configured. This ensures the quarantine path is correctly applied against the snapshot repository.

Tests exercising quarantining logic were updated to set the relative path metadata key as Rails would.

Edited by Sami Hiltunen

Merge request reports