Skip to content

Add ability to filter orchestrations at worker#443

Merged
halspang merged 5 commits into
microsoft:mainfrom
halspang:halspang/orchestration_filter
Jul 9, 2025
Merged

Add ability to filter orchestrations at worker#443
halspang merged 5 commits into
microsoft:mainfrom
halspang:halspang/orchestration_filter

Conversation

@halspang

@halspang halspang commented Jul 1, 2025

Copy link
Copy Markdown
Member

This change allows a user to set a lambda that acts a filter for orchestrations. If the lambda returns false, the orchestration will be abandoned, leaving it to be attempted again later.

In this initial commit, the filter can work off of the orchestration name and the orchestration tags.

halspang added 2 commits July 1, 2025 15:28
This change allows a user to set a lambda that acts a filter
for orchestrations. If the lambda returns false, the orchestration
will be abandoned, leaving it to be attempted again later.

In this initial commit, the filter can work off of the orchestration
name and the orchestration tags.

Signed-off-by: Hal Spang <halspang@microsoft.com>
Signed-off-by: Hal Spang <halspang@microsoft.com>
@cgillum

cgillum commented Jul 3, 2025

Copy link
Copy Markdown
Member

@halspang can you add a bit more context on how this is intended to be used in real-world situations?

Normally a filtering feature would be built on the server-side so that you don't waste cycles delivering and abandoning messages repeatedly (or infinitely in some cases). Is there a plan to add such functionality to DTS? And would the design change at all if/when we go down that path?

@halspang

halspang commented Jul 7, 2025

Copy link
Copy Markdown
Member Author

@halspang can you add a bit more context on how this is intended to be used in real-world situations?

Normally a filtering feature would be built on the server-side so that you don't waste cycles delivering and abandoning messages repeatedly (or infinitely in some cases). Is there a plan to add such functionality to DTS? And would the design change at all if/when we go down that path?

@cgillum - The general goal of this is to give users the ability to react to events that require they temporarily pause or block work. It's being done this way as it allows for users to hook in their own custom logic for how that filtering is achieved. The main scenario that I was presented to make this change was the ability to add a dynamic kill switch to a specific worker.

I agree that it would be good to do this at a server level, and I've long wanted to add more worker knowledge to the backend. That's the more correct path, but also the much longer path. Especially so when it comes to integrating this kind of filtering as it would require persisting data between the worker and scheduler. I have ideas for this but, again, it'll just take a bit longer.

Let me know what you think in terms of, should we do this to get the functionality out there and then follow up with backend support, or if we should just aim for the server-side solution from the start.

@cgillum

cgillum commented Jul 7, 2025

Copy link
Copy Markdown
Member

The main scenario that I was presented to make this change was the ability to add a dynamic kill switch to a specific worker.

I think the scenario is interesting, but I'm curious to understand how one would operationally implement a kill switch that only targets a specific worker. Can we clarify what "specific worker" means? For example, in an AKS context, is this a specific deployment, a specific pod, or perhaps a specific pod replica within the deployment?

This commit adds an Obsolete attribute to the new orchestration
filtering. This is being done because we want to provide the
functionality but also leave the implementation more open. This
marks the API as Obsolete("Experimental") to show that.

Signed-off-by: Hal Spang <halspang@microsoft.com>
Comment thread src/Worker/Core/DependencyInjection/DurableTaskWorkerBuilderExtensions.cs Outdated
Comment thread src/Worker/Core/DurableTaskWorkerOptions.cs
Comment thread src/Worker/Core/IOrchestrationFilter.cs
Comment thread src/Worker/Core/IOrchestrationFilter.cs Outdated
Comment thread src/Worker/Core/IOrchestrationFilter.cs Outdated
Comment thread src/Worker/Core/IOrchestrationFilter.cs Outdated
Comment thread src/Worker/Grpc/GrpcDurableTaskWorker.cs Outdated
Comment thread src/Worker/Grpc/Logs.cs
Comment thread test/Grpc.IntegrationTests/OrchestrationPatterns.cs
Comment thread src/Worker/Core/IOrchestrationFilter.cs Outdated
@halspang

halspang commented Jul 8, 2025

Copy link
Copy Markdown
Member Author

The main scenario that I was presented to make this change was the ability to add a dynamic kill switch to a specific worker.

I think the scenario is interesting, but I'm curious to understand how one would operationally implement a kill switch that only targets a specific worker. Can we clarify what "specific worker" means? For example, in an AKS context, is this a specific deployment, a specific pod, or perhaps a specific pod replica within the deployment?

That all depends on how they implement the interface. Deployment is easiest as you could just be deploying a different image with specific logic about how to approve/deny orchestrations. You could also pass in the pod/replica ID as an env var and use that in your service. We left it very open so the user can make all the choices here.

@halspang halspang requested a review from cgillum July 8, 2025 17:39
Comment thread test/Grpc.IntegrationTests/OrchestrationPatterns.cs Outdated
Comment thread test/Grpc.IntegrationTests/OrchestrationPatterns.cs Outdated
@halspang halspang force-pushed the halspang/orchestration_filter branch from d2325f4 to 53f5781 Compare July 8, 2025 23:42
@halspang halspang requested a review from cgillum July 8, 2025 23:42
Comment thread test/Grpc.IntegrationTests/OrchestrationPatterns.cs Outdated
Signed-off-by: Hal Spang <halspang@microsoft.com>
@halspang halspang force-pushed the halspang/orchestration_filter branch from 53f5781 to 790a293 Compare July 9, 2025 18:08
@halspang halspang merged commit 4197058 into microsoft:main Jul 9, 2025
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