CommunityToolkit / Aspire

A community project with additional components and extensions for .NET Aspire
MIT License
218 stars 27 forks source link

Waiting on Ollama model resources blocks download #256

Closed aaronpowell closed 22 hours ago

aaronpowell commented 5 days ago

Describe the bug

When using the WaitFor API on a resource that depends on the model resource from Ollama, the model will never be downloaded.

Regression

No response

Steps to reproduce

1. Add `WaitFor(llama)` on the Ollama demo app
1. Launch the sample
1. Observe the model never downloading

Expected behavior

The model should download and the resource waiting for it shouldn't start until the model is ready.

Screenshots

No response

IDE and version

Other

IDE version

No response

Nuget packages

Nuget package version(s)

9.0.0

Additional context

This is because the lifecycle hook relies on AfterResourcesCreatedAsync which doesn't execute until after the resources have started, but since we have a resource waiting on health from the model resource, it doesn't start, resulting in a race condition.

Instead, we should use the new eventing API and the ResourceReadyEvent.

Help us help you

Yes, I'd like to be assigned to work on this item