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

WaitForCompletion not working as (I) expected with SQL Projects #373

Open
ErikEJ opened this issue Jan 8, 2025 · 7 comments · May be fixed by #380
Open

WaitForCompletion not working as (I) expected with SQL Projects #373

ErikEJ opened this issue Jan 8, 2025 · 7 comments · May be fixed by #380
Assignees

Comments

@ErikEJ
Copy link
Contributor

ErikEJ commented Jan 8, 2025

Describe the bug

I have 2 SQL projects, where one has references to the other, and the other therefore must be present in order for deployment to complete.

But both projects start "publishing" right away, not waiting for each other

@jmezach FYI

Regression

No response

Steps to reproduce

var builder = DistributedApplication.CreateBuilder(args);

var sqlServer = builder.AddSqlServer("sql");

var wfDatabase = sqlServer.AddDatabase("WF");

var wf2Database = sqlServer.AddDatabase("Default");

var wfSqlProject = builder.AddSqlProject<Projects.Workflow_Database_WF>("wfsqlproj")
    .WithReference(wfDatabase);

var wf2SqlProject = builder
    .AddSqlProject<Projects.Workflow_Database>("wf2sqlproj")
    .WithReference(wf2Database)
    .WaitForCompletion(wfSqlProject);

Expected behavior

I was naively expecting WaitForCompletion to work in this scenario.

Screenshots

No response

IDE and version

VS 2022

IDE version

17.12.3

Nuget packages

<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" />
    <PackageVersion Include="CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects" Version="9.0.0" />

Additional context

No response

Help us help you

Yes, but only if others can assist

@aaronpowell
Copy link
Member

So wf2SqlProject shouldn't start until wfSqlProject is running?

Could a test be written to demonstrate this behaviour, it'd be easier to debug, as you'll likely have to debug this method to figure out why it's thinking it's "done" when it's not: https://github.com/dotnet/aspire/blob/main/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs#L186-L229

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Jan 9, 2025

So wf2SqlProject shouldn't start until wfSqlProject is running?

Correct, until wfSqlProject is "Finished"

@jmezach
Copy link
Contributor

jmezach commented Jan 10, 2025

@ErikEJ Do you see anything in the logs for the wf2sqlproj resource regarding it waiting for something?

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Jan 10, 2025

@jmezach It goes to publishing right away:

2025-01-10T14:20:29 Message SQL73001: Initializing deployment (Start)

@jmezach
Copy link
Contributor

jmezach commented Jan 10, 2025

Hmm, so it looks like we are doing the publish as soon as the target database resource is ready as can be seen here. Perhaps we should add a call to WaitForDependencies there like this.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Jan 10, 2025

Yes, well spotted!

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Jan 10, 2025

@jmezach PR coming up!

@ErikEJ ErikEJ self-assigned this Jan 11, 2025
ErikEJ added a commit to ErikEJ/AspireCommunityToolkit that referenced this issue Jan 11, 2025
@ErikEJ ErikEJ linked a pull request Jan 11, 2025 that will close this issue
6 tasks
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 a pull request may close this issue.

3 participants