Skip to content

fix(notifier): decouple immediate notifications from request context#776

Merged
notandy merged 1 commit into
mainfrom
fix/notifier-context-canceled
May 20, 2026
Merged

fix(notifier): decouple immediate notifications from request context#776
notandy merged 1 commit into
mainfrom
fix/notifier-context-canceled

Conversation

@notandy
Copy link
Copy Markdown
Collaborator

@notandy notandy commented May 20, 2026

The immediate-notification gocron job captured the HTTP request context, which net/http cancels the moment the handler returns. The async DB lookup and Campfire send then failed with context canceled every time.

ScheduleImmediate no longer takes a caller context; gocron supplies a job-scoped context to the task at execution time, bounded by a 30s timeout.

Subject rendering is split into its own embedded template; the outbound MIME type is now configurable.

Tightens service-endpoint:read-global to cloud_admin in policy.json.

The immediate-notification gocron job captured the HTTP request context, which
net/http cancels as soon as the handler returns. The async job then failed its
DB lookup and Campfire send with "context canceled" every time.

ScheduleImmediate no longer takes a caller context; gocron supplies a job-scoped
context to the task at execution time, bounded by a 30s timeout. Subject rendering
is split into its own embedded template, and the MIME type for outbound mail is
configurable.

Also tightens service-endpoint:read-global to cloud_admin in policy.json.
@notandy notandy requested review from a team, m-kratochvil, notque and ronchi-oss as code owners May 20, 2026 20:50
@github-actions
Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/sapcc/archer/internal/config 0.00% (ø)
github.com/sapcc/archer/internal/controller 0.00% (ø)
github.com/sapcc/archer/internal/notifier 0.00% (ø)
github.com/sapcc/archer/restapi 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/sapcc/archer/internal/config/config.go 0.00% (ø) 0 0 0
github.com/sapcc/archer/internal/controller/endpoint.go 0.00% (ø) 0 0 0
github.com/sapcc/archer/internal/notifier/notifier.go 0.00% (ø) 0 0 0
github.com/sapcc/archer/internal/notifier/templates.go 0.00% (ø) 0 0 0
github.com/sapcc/archer/restapi/configure_archer.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/sapcc/archer/internal/notifier/notifier_test.go
  • github.com/sapcc/archer/internal/notifier/templates_test.go

@notandy notandy merged commit 7b47ef6 into main May 20, 2026
6 checks passed
@notandy notandy deleted the fix/notifier-context-canceled branch May 20, 2026 20:53
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