Skip to content

feat(sandbox): sync latest public APIs - #474

Merged
miclle merged 3 commits into
qiniu:masterfrom
miclle:feat/sandbox-api-spec-sync
Nov 12, 2026
Merged

miclle merged 3 commits into
qiniu:masterfrom
miclle:feat/sandbox-api-spec-sync

Conversation

@miclle

@miclle miclle commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

The Sandbox SDK still uses the deprecated connect endpoint and lacks the latest snapshot, lifecycle, injection, and template options. This updates it against qiniu/api-specs at 6cb3b18a89584b0cd05f94c2d0a85aa7926c9f05 and adds the corresponding tests, examples, and usage documentation.

Changes

  • Add persistent snapshot creation and paginated listing, with caller-owned idempotency keys, snapshot-specific retries bounded by the 35-minute idempotency window, interrupted-response replay, and validated Retry-After handling. Send validated UTF-8 key bytes so Unicode keys work through real HTTP transport.
  • Use Connect v2, support memory/filesystem-only pause, and expose automatic pause/resume configuration while preserving explicit false values.
  • Add HTTP JSON body matching/injection, template tag listing, and minimum total/free disk constraints.
  • Add and update examples for snapshots, lifecycle, template builds, and injection configuration, including resource cleanup.

Compatibility

  • Omitting a connect timeout now uses the server default of 300 seconds. Connection extends TTL without shortening it.
  • Template creation rejects the removed disk_size_mb / diskSizeMB option with migration guidance. Use min_disk_mb for minimum total size or min_free_disk_mb for minimum free space.

Validation

  • Current-head GitHub CI: all 10 Linux/Windows matrix jobs passed (Linux Python 2.7 and 3.4–3.9; Windows Python 2.7, 3.5, and 3.9).
  • Combined SingleFlight and Sandbox regression run on Python 3.9: 248 tests passed, covering retry sleep isolation from background threads.
  • Python 3.9 and 3.11: 244 local Sandbox tests passed on each, including retry deadline boundaries, malformed/oversized Retry-After, and real HTTP regressions for Unicode keys and interrupted response bodies. The raw-byte HTTP test server supports legacy Python header handling.
  • At the preceding feature commit 590eb9e, four focused live integration cases passed: memory and filesystem snapshot recovery, minimum-disk template building, and HTTP body injection configuration. Created resources were cleaned up.
  • At 590eb9e, four examples ran successfully against the service: snapshots, lifecycle, template lifecycle, and runtime configuration.
  • Flake8 and git diff --check passed.

The repository-wide integration suite was not run to completion, and historical examples were not all executed individually.

Sync Sandbox API changes from qiniu/api-specs at 6cb3b18.
Add persistent snapshots, Connect v2, pause/resume options, JSON body
injections, template tags, and minimum disk constraints with tests and examples.

Send snapshot idempotency keys as UTF-8 bytes and cover real HTTP transport,
including retries with Unicode and byte-string keys.

BREAKING CHANGE: replace disk_size_mb/diskSizeMB with min_disk_mb or
min_free_disk_mb for template creation. Omitted connect timeouts now use
the server default of 300 seconds.
@qiniu-prow qiniu-prow Bot added the size/XL label Nov 12, 2026

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed every changed file, traced the affected callers and API contracts, and found three defects in snapshot retry handling. The sandbox suite passes with 224 tests passed and 11 credential-dependent integration tests skipped; targeted reproductions confirm the interrupted-response and Retry-After failures.

Reviewed head commit: 590eb9e75105458daae423104b229c04ad37a02f

  • [P2] Bound snapshot retries by the idempotency retention window (qiniu/services/sandbox/client.py:529-533) — see inline comment
  • [P2] Retry interrupted snapshot response bodies (qiniu/services/sandbox/client.py:503-507) — see inline comment
  • [P3] Guard Retry-After conversion against malformed numeric values (qiniu/services/sandbox/client.py:400-403) — see inline comment

Comment thread qiniu/services/sandbox/client.py Resolved
Comment thread qiniu/services/sandbox/client.py Resolved
Comment thread qiniu/services/sandbox/client.py Resolved
Keep automatic retries within the idempotency retention window, replay interrupted responses, and validate Retry-After safely. Cover retry deadlines and raw HTTP transport across supported Python versions.
@miclle

miclle commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@fennoai review

@fennoai

fennoai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

All 244 local Sandbox tests passed on Python 3.10, and the fixed diff passed whitespace checks. I found no actionable regressions; I’m submitting a non-blocking review noting that live service integration tests were not run.

View task

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete diff at f03de75, including snapshot idempotency and retry boundaries, Connect v2, lifecycle options, pagination, template disk constraints, and HTTP body injection; no actionable regressions found. All 244 local Sandbox tests passed on Python 3.10, and the fixed diff passed whitespace checks. Live service integration tests were not run.

Patch the client time namespace instead of the shared time module so Python 2 ThreadPool background sleeps cannot contaminate retry assertions.
@miclle

miclle commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@fennoai review

@fennoai

fennoai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The updated tests isolate mocked retry sleeps to the client module, leaving other threads’ timing intact. All 244 local Sandbox tests passed, and the fixed diff passed whitespace checks. I found no actionable regressions and will submit the review.

View task

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete fixed diff at 2a4d421, including snapshot retry safety, lifecycle and Connect v2 behavior, pagination, template options, injection serialization, and the updated isolation of mocked retry sleeps. No actionable regressions found; all 244 local Sandbox tests passed on Python 3.10, and the diff passed whitespace checks. Live service integration tests and Python 2 execution were not performed.

@miclle
miclle merged commit 2301fc0 into qiniu:master Nov 12, 2026
10 checks passed
@miclle
miclle deleted the feat/sandbox-api-spec-sync branch November 12, 2026 08:39
@miclle miclle mentioned this pull request Nov 12, 2026
miclle added a commit that referenced this pull request Nov 12, 2026
Prepare Python SDK 7.19.0 with the Sandbox changes merged since v7.18.2:
idempotent creation/connection, resource APIs, persistent snapshots,
Connect v2, pause/resume options, HTTP JSON body injection, and template
disk constraints/tags.

The changelog documents the removed `disk_size_mb` / `diskSizeMB`
options and the server-default connect timeout. The release also
isolates the Kodo signature test from
`DISABLE_QINIU_TIMESTAMP_SIGNATURE`, reproducing and fixing the sole
failure reported by the completed master CI jobs after #474.

### Validation

- Python 3.9 and 3.11: 244 local Sandbox tests passed on each, with
`DISABLE_QINIU_TIMESTAMP_SIGNATURE=True` to exercise the regression.
- Flake8 and `git diff --check` passed.
- `setup.py --version`, package metadata, and changelog agree on 7.19.0.
- Wheel and sdist built; Twine checks passed with the existing missing
`long_description_content_type` warning.
- The wheel installed in a separate environment; importing qiniu reports
7.19.0 and exposes the snapshot client API.

### Release

After merge, tag the release commit as v7.19.0 and publish the GitHub
Release with compatibility notes. This follows the repository's previous
release process; the repository has no PyPI publishing workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant