Skip to content

Phase: renew S3 credentials during long copies - #1687

Merged
neuromechanist merged 5 commits into
feature/issue-1671-epic-bru-upload-fixesfrom
feature/issue-1644-s3-credential-refresh
Oct 9, 2026
Merged

neuromechanist merged 5 commits into
feature/issue-1671-epic-bru-upload-fixesfrom
feature/issue-1644-s3-credential-refresh

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Change

This phase continues Bru's fix from PR #1648 for issue #1644. The main dataset upload now copies pending files in batches capped at 200 paths or 50 GiB (a single larger object runs alone). Before each batch it refreshes the STS lease when the remaining time is less than the 20-minute margin plus the longest batch seen so far. After each attempt, the git-annex location log determines which paths remain; an expired-token response triggers a fresh lease and retries only those paths. The existing #1647 whole-upload location-log verification and final recorded-content checks remain in place and use the latest credentials.

The integration test uses real dev API-issued credentials and a real git-annex process, with S3 requests routed only to a loopback stand-in. It keeps returning ExpiredToken for the first renewed access-key ID, then verifies that the application renews again and completes both copies. The stand-in records access-key IDs and one-way session-token fingerprints; it does not validate the SigV4 signature or contact S3.

Scope and limits

  • This covers the main dataset upload transfer. Update, push, sandbox, and E2E copy paths keep their existing credential lifecycle.
  • The proposed deadline-kill was dropped because the upload STS policy does not allow AbortMultipartUpload; killing git-annex at expiry could leave an incomplete multipart upload. A single object that repeatedly expires before completion cannot resume its multipart upload across copy runs; the bounded retry path returns an error.
  • Renewals are capped at 48 per upload. If the API omits or returns an invalid expiration, the lease is conservatively treated as 55 minutes.

The first commit preserves Bru's authorship. The follow-up commits correct the batch progress handling and expand the real integration proof.

Part of #1644 and epic #1671. Supersedes contributor PR #1648.

Review record

Independent pipeline, lease/integration, and security reviews found no remaining actionable findings after the fixes. Review fixes included matching the renewed test lease duration, exercising an actual ExpiredToken retry, checking that refreshed session tokens reach git-annex without logging token material, and requiring HTTPS for the dev API test target.

Verification

  • bun test test/upload-s3-copy-step.unit.test.ts test/upload-sts-refresh.integration.test.ts — 41 pass, 1 skipped locally. The live API test is skipped because this checkout has no dev test credentials; integration-dev must run it before merge.
  • bun test --path-ignore-patterns='run_every_scrub_suite' ././test/scrub/s3/standin.test.ts — 6 pass.
  • bun test --path-ignore-patterns='run_every_scrub_suite' ././test/scrub/s3/credentials.test.ts — 6 pass.
  • bun run typecheck, bun run lint, bun run lint:scrub, Biome on all changed files, and git diff --check passed.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Independent review record

Reviewers checked the upload pipeline/location-log behavior, lease renewal and integration coverage, and credential handling.

  • Lease-test mismatch — resolved: the first version expected multiple renewals but the renewal callback used the API's default two-hour duration. It now requests the same 900-second lease for every renewal and expects the proactive renewal, the ExpiredToken-triggered renewal, and the next batch's proactive renewal.
  • Expiry retry coverage — resolved: the loopback S3 stand-in persistently returns ExpiredToken for PutObject calls signed with the first renewed access key, including git-annex's own retries. The real transfer succeeds only after the application obtains another API-issued lease. Assertions check the failed and successful requests against access-key IDs and SHA-256 fingerprints of session-token headers. Token values are not stored or printed.
  • HTTPS guard — resolved: the live integration test now requires HTTPS and the exact dev API hostname before it can send the admin test key.
  • Pipeline review — no remaining findings: each batch re-reads the location log, and the existing whole-upload verification still decides whether the transfer is complete.

The stand-in does not validate the SigV4 signature. The integration test demonstrates that the refreshed access key and session token reach git-annex's S3 requests; it does not claim that the stand-in proves AWS accepted the signature.

Local validation: typecheck and lint passed; upload/location-log tests passed (41), stand-in and credential suites passed (6 each). The real API integration test is safety-skipped locally because this checkout has no dev test credentials; the required integration-dev check must execute it before merge.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

CI follow-up for 21d0bdba

The first CI run on e05427c5 exposed a real short-lease edge case in integration-dev: the test expected three credential mints but observed four. After an ExpiredToken refresh, the copy loop immediately ran its proactive-expiry check again; because the test lease is only 15 minutes and the safety margin is 20 minutes, it discarded the newly refreshed credentials before using them.

Commit 21d0bdba records that the next attempt should use the just-renewed lease once, then resumes proactive checks on the following batch. The integration assertions now cover both the successful retry with that lease and proactive renewal before a later batch. The commit is pushed; this PR now points at 21d0bdba74c5a8311d12d1d6eac6c100afb9ff78 and needs a fresh green run before merge.

Local verification after the fix: focused unit/integration files reported 41 passed and 1 safety-skipped; both S3 stand-in suites reported 6 passed each; Biome, typecheck, and git diff --check passed. The live dev integration was not run locally because the required staging key was unavailable. The stand-in confirms the session-token header reaches the subprocess using a one-way fingerprint, but it does not independently validate the SigV4 signature.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1687

Version: 0.10.16-PR1687.ce8f138
Commit: ce8f138


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Sandbox E2E result on 21d0bdba

The e2e-sandbox job did not reach its tests. At 07:28:35Z, its npm-tag lookup returned 0.10.16-PR1687.21d0bdb; the immediately following bun install -g nemar-cli@PR1687 failed with Package "nemar-cli" with tag "PR1687" not found, but package exists. This is a publish/read-after-write availability failure at the CLI install step; it does not exercise the upload change. The sandbox E2E coverage gap remains documented per the chosen scope. I am treating this job as unverified, not as a passing E2E result.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Integration test accounting fix on ce8f138e

The integration-dev run on 21d0bdba reached the renewed-copy assertions and consistently saw three successful PutObject requests instead of two. Independent review and a local real-git-annex/loopback reproduction showed the extra request is nm099999/objects/annex-uuid, written by git annex initremote under the initial lease; the two dataset objects then succeed under the reactive and next-batch proactive leases. The lease/copy behavior is correct; the test had counted remote initialization as a payload copy.

Commit ce8f138e asserts the annex-uuid setup write separately, derives the two expected S3 keys from the real annexed paths, and requires both data objects to have successful writes under the renewed sessions. No application code changed for this test-accounting correction.

Local Biome, typecheck, and git diff --check passed. The focused integration test safety-skipped locally because staging credentials are unavailable; the diagnostic reproduction used real git-annex and the loopback stand-in with dummy credentials only. Fresh CI on ce8f138e must verify the live integration path. The earlier e2e-sandbox setup failure remains documented as unverified, as requested.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Exact-head validation and merge record

Validated PR head ce8f138e3fc05a965f9e191aa3fe13eda5c18d51 on run 37900471061; the npm publish preview also passed on run 37900467784.

  • unit-pure, integration-dev, api-test, lint, zenodo-sandbox-test, e2e-sandbox, and all five scrub shards passed.
  • e2e-sandbox used PR1687 at 0.10.16-PR1687.ce8f138, matching this head. The separate owner-selected sandboxCommand acceptance gap remains documented and was not run.
  • Independent pipeline, lease/integration, and security reviews have no remaining actionable findings. The integration accounting test now distinguishes the annex-uuid initialization write from the two payload objects and verifies renewed credentials on the payload copies.

The integration test exercised the dev-issued credential path with S3 requests routed to the loopback stand-in; it did not contact live S3 or validate SigV4 signatures.

@neuromechanist
neuromechanist merged commit 717e85b into feature/issue-1671-epic-bru-upload-fixes Oct 9, 2026
18 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1644-s3-credential-refresh branch October 9, 2026 08:04

This branch was previously deployed

1 inactive deployment
npm — ce8f138e Deployed Oct 9, 2026 by neuromechanist via publish #3284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants