Skip to content

Commit 7d86e63

Browse files
authored
Merge pull request #516 from serverlessworkflow/fix-workflow-routing
Fixed the operator to ignore workflows and workflow instances marked with mismatching `synapse.io/operator` labels
2 parents b92f584 + a08adff commit 7d86e63

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/operator/Synapse.Operator/Services/WorkflowController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected virtual async Task<bool> TryClaimAsync(Workflow workflow, Cancellation
9595
{
9696
ArgumentNullException.ThrowIfNull(workflow);
9797
if (this.Operator == null) throw new Exception("The controller must be started before attempting any operation");
98-
if (workflow.Metadata.Labels != null && workflow.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName) && operatorQualifiedName == this.Operator.Resource.GetQualifiedName()) return true;
98+
if (workflow.Metadata.Labels != null && workflow.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName)) return operatorQualifiedName == this.Operator.Resource.GetQualifiedName();
9999
try
100100
{
101101
var originalResource = workflow.Clone();
@@ -120,7 +120,7 @@ protected virtual async Task<bool> TryClaimAsync(Workflow workflow, Cancellation
120120
protected virtual async Task<bool> TryReleaseAsync(Workflow workflow, CancellationToken cancellationToken)
121121
{
122122
ArgumentNullException.ThrowIfNull(workflow);
123-
if (workflow.Metadata.Labels != null && workflow.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName) && operatorQualifiedName == this.Operator.Resource.GetQualifiedName()) return true;
123+
if (workflow.Metadata.Labels != null && workflow.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName)) return operatorQualifiedName == this.Operator.Resource.GetQualifiedName();
124124
try
125125
{
126126
var originalResource = workflow.Clone();

src/operator/Synapse.Operator/Services/WorkflowInstanceController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected virtual async Task<WorkflowInstanceHandler> CreateWorkflowInstanceHand
8787
protected virtual async Task<bool> TryClaimAsync(WorkflowInstance resource, CancellationToken cancellationToken)
8888
{
8989
ArgumentNullException.ThrowIfNull(resource);
90-
if (resource.Metadata.Labels != null && resource.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName) && operatorQualifiedName == this.Operator.Resource.GetQualifiedName()) return true;
90+
if (resource.Metadata.Labels != null && resource.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName)) return operatorQualifiedName == this.Operator.Resource.GetQualifiedName();
9191
try
9292
{
9393
var originalResource = resource.Clone();
@@ -112,7 +112,7 @@ protected virtual async Task<bool> TryClaimAsync(WorkflowInstance resource, Canc
112112
protected virtual async Task<bool> TryReleaseAsync(WorkflowInstance resource, CancellationToken cancellationToken)
113113
{
114114
ArgumentNullException.ThrowIfNull(resource);
115-
if (resource.Metadata.Labels != null && resource.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName) && operatorQualifiedName == this.Operator.Resource.GetQualifiedName()) return true;
115+
if (resource.Metadata.Labels != null && resource.Metadata.Labels.TryGetValue(SynapseDefaults.Resources.Labels.Operator, out var operatorQualifiedName)) return operatorQualifiedName == this.Operator.Resource.GetQualifiedName();
116116
try
117117
{
118118
var originalResource = resource.Clone();

0 commit comments

Comments
 (0)