-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add tenant headers support to BackgroundWorkflowCancellationDispatcher #7040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tenant headers support to BackgroundWorkflowCancellationDispatcher #7040
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds tenant header support to BackgroundWorkflowCancellationDispatcher to fix issue #7034, ensuring that tenant context is properly propagated when canceling suspended workflows using the default cancellation dispatcher.
Key Changes:
- Added
ITenantAccessordependency injection toBackgroundWorkflowCancellationDispatcher - Added imports for tenant-related namespaces (
Elsa.Common.MultitenancyandElsa.Tenants.Mediator) - Implemented
CreateHeaders()method to generate tenant headers from the current tenant context
src/modules/Elsa.Workflows.Runtime/Services/BackgroundWorkflowCancellationDispatcher.cs
Outdated
Show resolved
Hide resolved
src/modules/Elsa.Workflows.Runtime/Services/BackgroundWorkflowCancellationDispatcher.cs
Outdated
Show resolved
Hide resolved
4e58970 to
ae1bb77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
|
@sfmskywalker would it be possible to still sneak this in 3.6 😄? |
|
Yes! Please try targeting the release/3.6.0 branch, hopefully it’s not too divergent :) |
|
@Sverre-W @sfmskywalker We’re seeing the same issue in a multi-tenant setup, so this would be a much-appreciated fix 😄 |
bc70bef
into
elsa-workflows:release/3.6.0
* Add tenant headers support to BackgroundWorkflowCancellationDispatcher (#7040) * Add tenant headers support to BackgroundWorkflowCancellationDispatcher * Fix 'CreateHeaders' call * Fix memory leak: Dispose IronCompressResult in Zstd codec (#7193) * Initial plan * Fix memory leak: Dispose IronCompressResult in Zstd codec and add tests Co-authored-by: sfmskywalker <[email protected]> * Refactor tests to be more DRY using Theory and InlineData Co-authored-by: sfmskywalker <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: sfmskywalker <[email protected]> * Introduce `IMaterializerRegistry` to manage workflow materializers and ensure availability checks. * Extend `IWorkflowDefinitionService` and `CachingWorkflowDefinitionService` with workflow graph lookup methods (`TryFindWorkflowGraphAsync`). Refactor caching and materialization logic for consistency. * Refactor caching interface and implementation: add `FindOrCreateAsync`, update `GetOrCreateAsync` to ensure non-null results, and improve exception handling. * Refactor `GetWorkflowGraphAsync` to use `TryFindWorkflowGraphAsync` and improve exception handling for missing workflow definitions and materializers. * Refactor caching logic to replace `GetOrCreateAsync` with `FindOrCreateAsync` for improved clarity and consistency. * Update workflow model, add event, and mark exception obsolete Updated `TimestampFilter.Column` to use a `null!` default value for clarity. Added `Event1` in the `hello-world.elsa` workflow and removed an unused folder entry from the project. Marked `WorkflowGraphNotFoundException` as obsolete with guidance to use `WorkflowDefinitionNotFoundException` instead. * Add new workflow files and exception classes for Elsa Introduced a workflow definition file "eventing.json" and new exception classes (`WorkflowDefinitionNotFoundException` and `WorkflowMaterializerNotFoundException`) to enhance handling of workflow-related errors. Also added a `WorkflowGraphFindResult` model for better workflow graph management. These changes improve the structure and functionality of the workflow system. * Add unit tests for `CachingWorkflowDefinitionService` and related helpers Introduce comprehensive unit tests to validate caching logic, workflow graph/materialization behavior, and cache key generation in `CachingWorkflowDefinitionService`. Add `WorkflowDefinitionServiceTests` and helper methods for streamlined test setup. * Enable `UseElsaScriptBlobStorage` in workflow server configuration * Refactor `BackgroundWorkflowCancellationDispatcher` to simplify object initialization and clean up XML documentation comments * Address PR #7195 review feedback: optimize caching, improve exceptions, add test coverage (#7196) * Initial plan * Apply PR review feedback: Fix exceptions, optimize caching, improve error handling Co-authored-by: sfmskywalker <[email protected]> * Add unit tests for MaterializerRegistry and LocalWorkflowClient exception handling Co-authored-by: sfmskywalker <[email protected]> * Add unit tests for BackgroundWorkflowCancellationDispatcher tenant headers Co-authored-by: sfmskywalker <[email protected]> * Refactor `WorkflowMaterializerNotFoundException` to improve structure and usability, update related references, and simplify object initialization in test cases. * Update `WorkflowDefinitionServiceTests` to use `WorkflowMaterializerNotFoundException` in place of `InvalidOperationException` for materializer not found scenario --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: sfmskywalker <[email protected]> Co-authored-by: Sipke Schoorstra <[email protected]> * Potential fix for pull request finding 'Inefficient use of ContainsKey' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Refactor tests and services: simplify object initialization, use target-typed `new()` syntax, and replace `CancellationToken` with `CancellationToken.None` where applicable. * Refactor tests in `BackgroundWorkflowCancellationDispatcherTests`: improve tenant initialization and optimize header checks by replacing `TryGetValue` with `ContainsKey`. --------- Co-authored-by: Sverre Winkelmans <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: sfmskywalker <[email protected]> Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This PR fixes #7034. By passing in the tenant headers when executing Cancel to a suspended workflow with the default cancellation dispatcher.
This change is