Skip to content

fix: [OCISDEV-1761] use the context of the caller in the metadata storage - #874

Open
2403905 wants to merge 3 commits into
mainfrom
fix/OCISDEV-1761-metadata-caller-context
Open

2403905 wants to merge 3 commits into
mainfrom
fix/OCISDEV-1761-metadata-caller-context

Conversation

@2403905

@2403905 2403905 commented Nov 30, 2026 •

Copy link
Copy Markdown

Summary

The CS3 metadata storage ignores the cancel and the deadline of the caller.

PR still follows the 759 design. The Authenticate call keeps its own timeout, and the returned context has no added deadline. The only change is that the caller's cancel and deadline now flow through.
#759

Problem

  1. getAuthContext in pkg/storage/utils/metadata/cs3.go started from context.Background(). The cancel and the deadline of the caller did not reach the gRPC calls.
  2. Upload and Download used http.NewRequest without a context. The HTTP calls had no limit.

A caller that cancels its request did not stop the metadata calls. A caller with a deadline did not get an answer on time when a service was slow.

What changes

  1. getAuthContext derives the new context from the context of the caller. It keeps the cancel, the deadline, the span and the values.
  2. The new context starts with empty outgoing metadata, so the token of the caller does not reach the storage. The context value of the token is the machine token.
  3. The getAuthContext span covers only the Authenticate call. The returned context does not hold it, so the next calls are children of the span of the caller.
  4. The Authenticate call keeps its own timeout. The timeout does not live on the returned context.
  5. Upload and Download use http.NewRequestWithContext.

Tests

  • New tests in pkg/storage/utils/metadata/cs3_caller_context_internal_test.go: cancel and deadline in the gRPC call, the HTTP GET and the Authenticate call, and the token of the caller.
  • All six new tests fail without the fix and pass with it.
  • go test -race ./pkg/storage/utils/metadata/... and go test ./pkg/share/manager/jsoncs3/... pass.

Notes for the review

…rage

The metadata storage started the calls of each operation from
context.Background(). The HTTP calls of Upload and Download used no context.
So the cancel and the deadline of the caller did not reach any call.

Changes:

- getAuthContext derives the new context from the context of the caller. It
  starts with empty outgoing metadata, so the token of the caller does not
  reach the storage. It stores the machine token as the token of the context.
- The span of getAuthContext covers only the Authenticate call. The Authenticate
  call keeps its own timeout.
- Upload and Download use http.NewRequestWithContext.
- Add tests for cancel and deadline in the gRPC calls, the HTTP calls and the
  Authenticate call, and for the token of the caller.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@2403905
2403905 requested a review from a team as a code owner November 30, 2026 11:09
@kw-security

kw-security commented Nov 30, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@2403905
2403905 force-pushed the fix/OCISDEV-1761-metadata-caller-context branch from 27530d2 to 4cc5a7f Compare November 30, 2026 18:14
2403905 and others added 2 commits November 30, 2026 19:50
…etadata storage

- Set an empty autoprop meta in the context from getAuthContext.
  The autoprop values of the caller no longer reach the storage.
- Log a cancel of the caller at debug level, not at warning level.
- Return an error when the outgoing context has no access token.
  Upload and Download no longer panic.
- Add tests for autoprop isolation, failed authentication and the missing token.
- Make the test helpers stop on test end and widen the time limits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…leaves

- Drop the cancel of the caller in Upload. A write does not stop halfway.
- Bound Upload with a timeout of its own (60 seconds).
- Add tests for the cancel and for the timeout.
- Update the changelog entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@2403905
2403905 force-pushed the fix/OCISDEV-1761-metadata-caller-context branch from b4d9df9 to 5298d36 Compare November 30, 2026 22:20
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