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

WithExplicitStart clashes with WithLifetime(ContainerLifetime.Persistent) #8073

Open
1 task done
DavidZidar opened this issue Mar 14, 2025 · 3 comments
Open
1 task done
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Comments

@DavidZidar
Copy link

DavidZidar commented Mar 14, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

WithLifetime(ContainerLifetime.Persistent) is supposed to keep a container running even if you stop and restart Aspire. This isn't working properly in combination with WithExplicitStart() as this feature prevents Aspire from reflecting the proper state of the containers during startup and thus negates some of the benefit of persistent lifetimes.

For instance, dependent services don't start until a running container is explicitly started again.

Expected Behavior

I expect a container to require an initial explicit start due to WithExplicitStart() but then remain running and be available even if I restart Aspire due to WithLifetime(ContainerLifetime.Persistent).

Steps To Reproduce

  1. Use .WithLifetime(ContainerLifetime.Persistent).WithExplicitStart()
  2. Start Aspire
  3. Start the container
  4. Restart Aspire
  5. The container is now shown as stopped even though it should be running

Exceptions (if any)

No response

.NET Version info

.NET SDK:
 Version:           9.0.201
 Commit:            071aaccdc2
 Workload version:  9.0.200-manifests.a3a1a094
 MSBuild version:   17.13.13+1c2026462

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26100
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.201\

I'm using Aspire 9.1.

Anything else?

No response

@DavidZidar
Copy link
Author

DavidZidar commented Mar 14, 2025

Here's what I was trying to do, I wanted to be able to start Redis Insight on demand but then keep it running until no longer needed. But as soon as I restart Aspire I can no longer access Redis via Redis Insight and the Aspire UI is showing Redis Insight as stopped even though the container is actually still running.

var redis = builder.AddRedis("redis")
	.WithEndpoint(port: 6379, isProxied: false, name: "external")
	.WithLifetime(ContainerLifetime.Persistent)
	.WithRedisInsight(config => config.WithLifetime(ContainerLifetime.Persistent).WithExplicitStart());

@DavidZidar
Copy link
Author

Also, if I use .WithExplicitStart() on Redis itself then services that .WaitFor(redis) don't start after a restart of Aspire until I explicitly start Redis again even though it is actually already running.

@davidfowl davidfowl added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication and removed area-orchestrator labels Mar 14, 2025
@davidfowl
Copy link
Member

cc @JamesNK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

No branches or pull requests

2 participants