Skip to content

Commit df22189

Browse files
committed
Remove Suspend versioning option
Signed-off-by: halspang <[email protected]>
1 parent 395b4d8 commit df22189

File tree

4 files changed

+14
-68
lines changed

4 files changed

+14
-68
lines changed

src/Client/Core/DurableTaskClient.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,19 +399,6 @@ public virtual Task<PurgeResult> PurgeAllInstancesAsync(
399399
throw new NotSupportedException($"{this.GetType()} does not support purging of orchestration instances.");
400400
}
401401

402-
/// <summary>
403-
/// Abandons a task orchestration work item to be re-enqueued at a later time.
404-
/// </summary>
405-
/// <param name="completionToken">The completion token that was given when the WorkItem was fetched.</param>
406-
/// <param name="cancellation">
407-
/// A <see cref="CancellationToken"/> that can be used to cancel the purge operation.
408-
/// </param>
409-
/// <returns>A task that completes when the WorkItem has been abandoned.</returns>
410-
public virtual Task AbandonOrchestrationTask(string completionToken, CancellationToken cancellation = default)
411-
{
412-
throw new NotSupportedException($"{this.GetType()} does not support abandoning task orchestration work items.");
413-
}
414-
415402
// TODO: Create task hub
416403

417404
// TODO: Delete task hub

src/Client/Grpc/GrpcDurableTaskClient.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,6 @@ public override Task<PurgeResult> PurgeAllInstancesAsync(
396396
return this.PurgeInstancesCoreAsync(request, cancellation);
397397
}
398398

399-
/// <inheritdoc/>
400-
public override async Task AbandonOrchestrationTask(string completionToken, CancellationToken cancellation = default)
401-
{
402-
P.AbandonOrchestrationTaskRequest request = new()
403-
{
404-
CompletionToken = completionToken,
405-
};
406-
407-
await this.sidecarClient.AbandonTaskOrchestratorWorkItemAsync(request, cancellationToken: cancellation);
408-
}
409-
410399
static AsyncDisposable GetCallInvoker(GrpcDurableTaskClientOptions options, out CallInvoker callInvoker)
411400
{
412401
if (options.Channel is GrpcChannel c)

src/Worker/Core/DurableTaskWorkerOptions.cs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace Microsoft.DurableTask.Worker;
1010
/// </summary>
1111
public class DurableTaskWorkerOptions
1212
{
13-
readonly VersioningOptions versioning = new();
1413
DataConverter dataConverter = JsonDataConverter.Default;
1514

1615
/// <summary>
@@ -44,15 +43,10 @@ public enum VersionFailureStrategy
4443
/// </summary>
4544
Reject = 0,
4645

47-
/// <summary>
48-
/// Suspend the orchestration if the version does not adhere to the matching strategy.
49-
/// </summary>
50-
Suspend = 1,
51-
5246
/// <summary>
5347
/// Fail the orchestration if the version does not adhere to the matching strategy.
5448
/// </summary>
55-
Fail = 2,
49+
Fail = 1,
5650
}
5751

5852
/// <summary>
@@ -144,24 +138,7 @@ public DataConverter DataConverter
144138
/// version of the worker, the versions that can be worked on, and what to do in case a version does not comply
145139
/// with the given options.
146140
/// </remarks>
147-
public VersioningOptions Versioning
148-
{
149-
get => this.versioning;
150-
set
151-
{
152-
if (value is not null)
153-
{
154-
this.IsVersioningSet = true;
155-
this.Versioning.Version = value.Version;
156-
this.Versioning.MatchStrategy = value.MatchStrategy;
157-
this.Versioning.FailureStrategy = value.FailureStrategy;
158-
}
159-
else
160-
{
161-
this.IsVersioningSet = false;
162-
}
163-
}
164-
}
141+
public VersioningOptions? Versioning { get; set; }
165142

166143
/// <summary>
167144
/// Gets a value indicating whether versioning is explicitly set or not.

src/Worker/Grpc/GrpcDurableTaskWorker.Processor.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ async Task OnRunOrchestratorAsync(
299299
? new(this.internalOptions.InsertEntityUnlocksOnCompletion)
300300
: null;
301301

302+
DurableTaskWorkerOptions.VersioningOptions? versioning = this.worker.workerOptions.Versioning;
303+
bool versionFailure = false;
302304
try
303305
{
304306
OrchestrationRuntimeState runtimeState = await this.BuildRuntimeStateAsync(
@@ -308,11 +310,11 @@ async Task OnRunOrchestratorAsync(
308310

309311

310312
// If versioning has been explicitly set, we attempt to follow that pattern. If it is not set, we don't compare versions here.
311-
if (this.worker.workerOptions.IsVersioningSet)
313+
if (versioning != null)
312314
{
313-
int versionComparison = TaskOrchestrationVersioningUtils.CompareVersions(runtimeState.Version, this.worker.workerOptions.Versioning.Version);
315+
int versionComparison = TaskOrchestrationVersioningUtils.CompareVersions(runtimeState.Version, versioning.Version);
314316

315-
switch (this.worker.workerOptions.Versioning.MatchStrategy)
317+
switch (versioning.MatchStrategy)
316318
{
317319
case DurableTaskWorkerOptions.VersionMatchStrategy.None:
318320
// No versioning, breakout.
@@ -324,7 +326,7 @@ async Task OnRunOrchestratorAsync(
324326
failureDetails = new P.TaskFailureDetails
325327
{
326328
ErrorType = "VersionMismatch",
327-
ErrorMessage = $"The orchestration version '{runtimeState.Version}' does not match the worker version '{this.worker.grpcOptions.Versioning.Version}'.",
329+
ErrorMessage = $"The orchestration version '{runtimeState.Version}' does not match the worker version '{versioning.Version}'.",
328330
IsNonRetriable = true,
329331
};
330332
}
@@ -337,7 +339,7 @@ async Task OnRunOrchestratorAsync(
337339
failureDetails = new P.TaskFailureDetails
338340
{
339341
ErrorType = "VersionMismatch",
340-
ErrorMessage = $"The orchestration version '{runtimeState.Version}' is greater than the worker version '{this.worker.grpcOptions.Versioning.Version}'.",
342+
ErrorMessage = $"The orchestration version '{runtimeState.Version}' is greater than the worker version '{versioning.Version}'.",
341343
IsNonRetriable = true,
342344
};
343345
}
@@ -348,11 +350,13 @@ async Task OnRunOrchestratorAsync(
348350
failureDetails = new P.TaskFailureDetails
349351
{
350352
ErrorType = "VersionError",
351-
ErrorMessage = $"The version match strategy '{this.worker.workerOptions.Versioning.MatchStrategy}' is unknown.",
353+
ErrorMessage = $"The version match strategy '{versioning.MatchStrategy}' is unknown.",
352354
IsNonRetriable = true,
353355
};
354356
break;
355357
}
358+
359+
versionFailure = failureDetails != null;
356360
}
357361

358362
// Only continue with the work if the versioning check passed.
@@ -415,9 +419,9 @@ async Task OnRunOrchestratorAsync(
415419
completionToken,
416420
entityConversionState);
417421
}
418-
else if (failureDetails != null && failureDetails.ErrorType == "VersionMismatch")
422+
else if (versioning != null && failureDetails != null && versionFailure)
419423
{
420-
if (this.worker.workerOptions.Versioning.FailureStrategy == DurableTaskWorkerOptions.VersionFailureStrategy.Fail)
424+
if (versioning.FailureStrategy == DurableTaskWorkerOptions.VersionFailureStrategy.Fail)
421425
{
422426
response = new P.OrchestratorResponse
423427
{
@@ -436,17 +440,6 @@ async Task OnRunOrchestratorAsync(
436440
},
437441
};
438442
}
439-
else if (this.worker.workerOptions.Versioning.FailureStrategy == DurableTaskWorkerOptions.VersionFailureStrategy.Suspend)
440-
{
441-
await this.client.SuspendInstanceAsync(
442-
new P.SuspendRequest
443-
{
444-
InstanceId = request.InstanceId,
445-
Reason = "Version mismatch",
446-
},
447-
cancellationToken: cancellationToken);
448-
return;
449-
}
450443
else
451444
{
452445
await this.client.AbandonTaskOrchestratorWorkItemAsync(

0 commit comments

Comments
 (0)