Skip to content

[13.4-stable] zedUpload: let the caller inject the request's context - #117

Merged
milan-zededa merged 1 commit into
lf-edge:13.4-stablefrom
christoph-zededa:backport-113-13.4-stable
Sep 29, 2026
Merged

milan-zededa merged 1 commit into
lf-edge:13.4-stablefrom
christoph-zededa:backport-113-13.4-stable

Conversation

@christoph-zededa

@christoph-zededa christoph-zededa commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport of #113 to 13.4-stable, git cherry-pick -x with one conflict, in
zedUpload/datastore_http.go on the four zedHttp.ExecCmd(...) calls: this
branch passes neither the resumable-download parts nor the auth header that
main passes there. The resolution keeps the branch's calls as they are and
only renames req.cancelContext to req.ctx in them, the same four one-word
changes the commit makes on main. The S3, GCS and request files applied
cleanly. The four touched files are identical on 13.4-stable and
14.5-stable, so this is the same resolution as #116.

DronaRequest.WithCancel always derived a new cancellable context from the
one it was given and kept it in an unexported field, so a caller that has to
wait on the same context the transfer runs under, EVE's downloader while it
retries a submission the transport refused, had no way to get at it and ended
up with two stacked contexts. The commit replaces WithCancel and Cancel
with WithContext, which stores the caller's context as it is, and has every
transport (HTTP, S3, GCS) run under that field, renamed from cancelContext
to ctx. The caller owns the context, selects on its Done channel and
cancels it, and the transport observes the same cancellation.

This is an API change for the library's consumer: WithCancel and Cancel
are gone. EVE's 13.4-stable downloader calls both, in
pkg/pillar/cmd/downloader/download.go, so the eve-libs bump on EVE's
13.4-stable has to land together with the downloader change from the
backport of lf-edge/eve#6651, which switches it to WithContext; the bump
cannot be taken on its own. EVE's 13.4-stable pins eve-libs at
ccb82e5 today, seven commits behind the current tip of this branch.

How to test and validate this PR

go build ./... && go vet ./... && go test ./zedUpload/: the change is a
field rename, the removal of two methods and one new method; the existing
tests cover the transports' request handling. All three pass on this branch
locally, as does golangci-lint run --new-from-rev=HEAD~1 ./zedUpload/...
with no issues.

In EVE, after the bump, cancelling the downloader's request context must
still abort a running HTTP transfer and wake a submission waiting for room in
the transport queue.

PR Backports

Checklist

  • I've provided a proper description
  • I've added the proper documentation — the exported method carries its doc comment
  • I've tested my PR on amd64 device — library change, unit tests only
  • I've tested my PR on arm64 device — not applicable
  • I've written the test verification instructions
  • I've set the proper labels to this PR — left to the maintainers
  • I've checked the boxes above, or I've provided a good reason why I didn't check them

For backport PRs:

  • I've added a reference link to the original PR
  • PR's title follows the template

🤖 Generated with Claude Code

DronaRequest.WithCancel always derives a new cancellable context from
the one it is given and keeps it in an unexported field, so a caller
that has to wait on the same context the transfer runs under, for
example while retrying a refused submission, had no way to get at it
and ended up with two stacked contexts.

DronaRequest.WithCancel is not needed anymore, so I removed it.

Add WithContext, which stores the caller's context as it is, and have
every transport run under that field, renamed from cancelContext to ctx
since it no longer implies a cancel function of its own. This enables
dependency injection of a context: the caller owns it, selects on its
Done channel and cancels it, and the transport observes the same
cancellation. WithCancel and Cancel keep working as before for callers
that want the request to own the cancellation.

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit a59ba20)
@milan-zededa
milan-zededa merged commit 06fd0b6 into lf-edge:13.4-stable Sep 29, 2026
4 checks passed
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