Skip to content
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

Re-introduce default cancellationToken for PurgeInstanceAsync for backwards compatibility #276

Closed
wants to merge 1 commit into from

Conversation

davidmrdavid
Copy link
Member

@davidmrdavid davidmrdavid commented Mar 25, 2024

Follow-up to: #262

It would appear that in the refactoring above we accidentally made a breaking change to our PurgeInstancesAsync API, dropping the declaration of a PurgeInstanceAsync(string instanceId, CancellationToken cancellation = default) method, which is overriden here.

At a glance, I suspect this is the reason for our smoke test failures in the worker.extensions.durabletask package: https://github.com/Azure/azure-functions-durable-extension/actions/runs/8428205010/job/23080260061?pr=2772

Failure trace:

#10 7.776 /root/src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs(54,39): error CS0115: 'FunctionsDurableTaskClient.PurgeInstanceAsync(string, CancellationToken)': no suitable method found to override [/root/src/Worker.Extensions.DurableTask/Worker.Extensions.DurableTask.csproj]

This PR is a naive attempt at trying to fix them.

@@ -337,7 +337,7 @@ public virtual Task ResumeInstanceAsync(string instanceId, CancellationToken can
public abstract AsyncPageable<OrchestrationMetadata> GetAllInstancesAsync(OrchestrationQuery? filter = null);

/// <inheritdoc cref="PurgeInstanceAsync(string, PurgeInstanceOptions, CancellationToken)"/>
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation = default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a binary compatibility perspective, this is still a breaking change. We need to introduce a virtual method that doesn't include the CancellationToken parameter at all.

public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
    => this.PurgeInstanceAsync(instanceId, CancellationToken.None);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, maybe my suggestion isn't the right one. I'd need to double check where the failure is coming from.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be honest, I haven't had the chance to validate my diff yet either. Just FYI

@davidmrdavid
Copy link
Member Author

Before I forget - let's validate that there weren't other similar breaking changes (in other client methods) that the test didn't catch but still need resolving.

@@ -337,7 +337,7 @@ public virtual Task ResumeInstanceAsync(string instanceId, CancellationToken can
public abstract AsyncPageable<OrchestrationMetadata> GetAllInstancesAsync(OrchestrationQuery? filter = null);

/// <inheritdoc cref="PurgeInstanceAsync(string, PurgeInstanceOptions, CancellationToken)"/>
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation = default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the default param back will cause ambiguous overload resolution with

public virtual Task<PurgeResult> PurgeInstanceAsync(
        string instanceId, PurgeInstanceOptions? options = null, CancellationToken cancellation = default)

when calling .PurgeInstanceAsync(string) (which of the 2 default param methods is it to use?)

We will also need to remove the default param from options in that other method.

@@ -337,7 +337,7 @@ public virtual Task ResumeInstanceAsync(string instanceId, CancellationToken can
public abstract AsyncPageable<OrchestrationMetadata> GetAllInstancesAsync(OrchestrationQuery? filter = null);

/// <inheritdoc cref="PurgeInstanceAsync(string, PurgeInstanceOptions, CancellationToken)"/>
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation = default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! the error message you see of no overload resolution is because of the typo in #267

@davidmrdavid
Copy link
Member Author

Closing this as the expected bug fix was merged.

@davidmrdavid davidmrdavid deleted the dajusto/patch-purgeAsync branch March 26, 2024 22:59
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.

3 participants