Skip to content

Retry stale service-credential 403s on the internal backbeat routes - #2793

Draft
delthas wants to merge 2 commits into
development/9.5from
improvement/BB-832/retry-stale-credential-403
Draft

Retry stale service-credential 403s on the internal backbeat routes#2793
delthas wants to merge 2 commits into
development/9.5from
improvement/BB-832/retry-stale-credential-403

Conversation

@delthas

@delthas delthas commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Artesca regenerates builtin service-account keys on every overlay write (PSVAPI-134). Backbeat and cloudserver each snapshot authdata at process start and neither reloads it, so during the rolling restarts that follow a rotation cloudserver returns 403 InvalidAccessKeyId on internal calls.

Smithy classifies a 403 as non-retryable (lib/clients/utils.js), every retry wrapper gates on err.retryable, and BackbeatConsumer commits the offset regardless — so a replication-status entry is destroyed outright. The failure lands in _refreshSourceEntry, upstream of every FAILED bookkeeping step, so the object keeps its PENDING status, never enters the failed-CRR sorted set, and is invisible to crrRetry.

A census on the ticket (10 CTST runs, 100 rejected requests, 8 skew episodes) found 95 % of these are cloudserver-stale — so a retry in backbeat can succeed — and that staleness is a per-request property: internal-cloudserver runs 4 replicas to backbeat's 1 and rolls a pod at a time, so a later attempt can be served by an already-updated pod. One backbeat pod was observed both failing and succeeding within the same second.

Changes

lib/util/staleCredentialError.js (new) — isStaleCredentialError() matching InvalidAccessKeyId and SignatureDoesNotMatch, and retryOnStaleCredentials(), a stateful predicate that preserves the existing err.retryable behaviour and adds a bounded number of stale-credential retries. AccessDenied is deliberately excluded: on an internal route it is the existing signal for a misconfigured source role (lib/util/replicationPermissionError.js) and must keep failing fast.

lib/BackbeatMetadataProxy.js — the three source-metadata calls (getMetadata, putMetadata, headLocation) use that predicate. A fresh one per retry() call, so the budget applies to a single logical operation.

extensions/replication/tasks/MultipleBackendTask.js_handleReplicationOutcome listed InvalidAccessKeyId as a permanent failure and returned a bare done(), committing the offset with no status published. ReplicateObject already omits it and publishes FAILED with committable: false; the subclass now matches, so an entry whose retries are exhausted stays visible to crrRetry.

Notes for review

  • Timing. The proxy calls super() with no retryParams, so it uses the defaults (min: 1000, factor: 1.5): attempts at 1 s, 2.5 s, 4.75 s, 8.1 s, 13.2 s — ~13 s total, ~20x under max.poll.interval.ms (300 s). This matters because the failure is correlated across all concurrency: 10 slots during a skew window. A unit test guards the property.
  • The backend-specific budgets are not reachable. The 60000 ms backoff / 900 s timeout picked in ReplicateObject.js:67-71 belongs to the task instances and only governs retries those tasks start themselves. MultipleBackendTask._refreshSourceEntry calls the proxy directly, so a stale-credential retry runs on the proxy's own params regardless of destination type.
  • committable: false defers the commit, it does not withhold it_publishReplicationStatus calls onEntryCommittable in the producer callback whether the produce succeeded or not, and this is already the path taken by every COMPLETED and FAILED outcome. No new stall mode; the change removes a special case that bypassed the normal path.
  • No change to isRetryableMiddleware, so a customer-destination 403 stays permanent by construction. The four call sites that opt in only ever talk to the internal endpoint.

Deliberately out of scope

  • The 24 % of census rejections that arrived on the ordinary S3 route (GetBucketReplication in _setupRolesOnce) are not retried. With the second commit they become visible FAILED entries rather than silent losses.
  • The ~5 % backbeat-stale direction still needs a pod restart; an operatorBackend credential reload would close it.
  • What the status processor should do when retries are exhausted — collides with BB-772's commit-on-poison-pill decision.
  • Backports: 9.2 can take the same patch; 9.1 is on aws-sdk v2 and needs a variant.

Issue: BB-832

delthas added 2 commits August 5, 2026 13:00
A credential rotation leaves backbeat and cloudserver disagreeing until both
have restarted, so cloudserver rejects the key it does not know with a 403.
Smithy marks a 403 non-retryable, which is right for a customer endpoint but
drops the replication-status entry on the internal routes: the object keeps a
PENDING status, is never marked FAILED, and is invisible to crrRetry.

Retry InvalidAccessKeyId and SignatureDoesNotMatch a bounded number of times on
the three BackbeatMetadataProxy source-metadata calls. internal-cloudserver runs
several replicas and rolls one pod at a time, so a later attempt can be served
by an already-updated pod. AccessDenied stays non-retryable: on an internal
route it is the signal for a misconfigured source role.

The budget is scoped to the stale-credential class by a stateful predicate, so
the existing err.retryable behaviour is unchanged, and it spans ~13s on the
proxy's default backoff, far below max.poll.interval.ms.

Issue: BB-832
MultipleBackendTask._handleReplicationOutcome listed InvalidAccessKeyId as a
permanent failure and returned a bare done(): the offset was committed with no
status published, so the object stayed PENDING and never reached the failed-CRR
listing.

ReplicateObject already omits it and falls through to publishing FAILED with
committable: false. Align the subclass with its parent so an entry whose retries
were exhausted stays visible to crrRetry instead of being lost silently.

Issue: BB-832
@bert-e

bert-e commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Hello delthas,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request.
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.64%. Comparing base (99c1281) to head (00abc8e).
⚠️ Report is 10 commits behind head on development/9.5.

Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
...xtensions/replication/tasks/MultipleBackendTask.js 61.25% <ø> (+1.21%) ⬆️
lib/BackbeatMetadataProxy.js 68.10% <100.00%> (+18.95%) ⬆️
lib/util/staleCredentialError.js 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

Components Coverage Δ
Bucket Notification 80.22% <ø> (ø)
Core Library 81.65% <100.00%> (+0.27%) ⬆️
Ingestion 70.13% <ø> (ø)
Lifecycle 80.25% <ø> (ø)
Oplog Populator 85.83% <ø> (ø)
Replication 62.16% <ø> (+0.14%) ⬆️
Bucket Scanner 85.76% <ø> (ø)
@@                 Coverage Diff                 @@
##           development/9.5    #2793      +/-   ##
===================================================
+ Coverage            75.50%   75.64%   +0.14%     
===================================================
  Files                  201      202       +1     
  Lines                13928    13932       +4     
===================================================
+ Hits                 10516    10539      +23     
+ Misses                3402     3383      -19     
  Partials                10       10              
Flag Coverage Δ
api:retry 9.08% <71.42%> (+0.03%) ⬆️
api:routes 8.85% <42.85%> (+0.01%) ⬆️
bucket-scanner 85.76% <ø> (ø)
ft_test:queuepopulator 9.12% <0.00%> (-1.01%) ⬇️
ingestion 12.25% <0.00%> (-0.01%) ⬇️
lib 8.77% <0.00%> (-0.01%) ⬇️
lifecycle 19.26% <42.85%> (+0.01%) ⬆️
notification 1.00% <0.00%> (-0.01%) ⬇️
oplogPopulator 0.13% <0.00%> (-0.01%) ⬇️
replication 18.85% <71.42%> (+0.03%) ⬆️
unit 55.02% <100.00%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@scality scality deleted a comment from bert-e Aug 5, 2026
@bert-e

bert-e commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

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