feat(swift): add Connection pool and configurable ETag mismatch policy#13
Merged
Conversation
ee50e8e to
ad7f646
Compare
- Per-process Connection pool (gevent Queue with stdlib fallback) so concurrent greenlets/threads no longer share a single swiftclient.Connection. Fixes sporadic 400s, ConnectionReset and content corruption under gevent workers. - write() pre-computes content_length and ETag and verifies the ETag returned by Swift. New etag_mismatch_policy config (log default / raise / raise_and_delete) controls behavior on mismatch — legacy log-only kept as default. - read_chunks() releases the borrowed Connection back to the pool when the generator is exhausted or close() is called. - list_files() uses full_listing=True to enumerate containers with more than 10 000 objects. - New optional settings: pool_size (20), pool_timeout (30), timeout (60), retries (5), os_options (merged over tenant_name / region_name for Keystone v3). - Tests: app fixture now pushes test_request_context and sets SERVER_NAME so url_for / current_app / request work out of the box; crypto tests use tmp_path instead of leaking encrypted.bin / decrypted.txt in cwd; new tests/test_swift_pool.py covers concurrent writes, pool sizing and ETag mismatch handling. - Adds gevent>=24.0.0 to test requirements.
ad7f646 to
fde93e3
Compare
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.
Problem
SwiftBackend shares a single swiftclient.Connection across all calls. Under gevent or threaded workers, multiple greenlets/threads write to the same HTTP socket concurrently
and corrupt the auth-token state, which causes:
Solution
Per-process Connection pool + ETag verification with configurable policy + test fixture cleanup.
Swift backend
30s).
Tests
Compatibility
Tests