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

Implicitly named volumes created by the WithDataVolume() method can collide across AppHost projects with the same name #5413

Open
DamianEdwards opened this issue Aug 23, 2024 · 1 comment · May be fixed by #5779
Assignees
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. enhancement An enhancement to an existing feature or capability.
Milestone

Comments

@DamianEdwards
Copy link
Member

DamianEdwards commented Aug 23, 2024

The various WithDataVolume methods create a container volume that's implicitly named based on the App Host project name and resource name, e.g. if the App Host project is named "TestShop.AppHost" and the resource the method is called on is named "postgres", the implicit volume name will be "TestShop.AppHost-postgres-data".

This can lead to collisions of these implicit volume names when the App Host project is not named uniquely between different solutions. I'm seeing more customer solutions where the App Host project is simply named "AppHost". If there are resources named simply such as "postgres" across those App Host projects, their implicit data volume names will collide.

This issue can be worked around currently by the developer by passing a custom volume name to the WithDataVolume method, but then it's the responsibility of the developer to ensure volume names don't clash between any container resource with a volume (or indeed any other non-Aspire created volume).

We should consider updating the implicit volume naming logic to include a hash of the App Host project path, or some other deterministic, stable value derived from the App Host project. Note this would be a breaking behavior change although we could consider quirking it (i.e. allowing the user to specify what implicit volume naming strategy is used) or some other mitigation.

@DamianEdwards DamianEdwards added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. labels Aug 23, 2024
@DamianEdwards DamianEdwards added this to the 9.0 milestone Aug 23, 2024
@DamianEdwards DamianEdwards changed the title The implicitly named volumes created by the WithDataVolume() method can collide across AppHost projects with the same name Implicitly named volumes created by the WithDataVolume() method can collide across AppHost projects with the same name Aug 23, 2024
@davidfowl davidfowl added the enhancement An enhancement to an existing feature or capability. label Sep 5, 2024
@davidfowl
Copy link
Member

Consider also using the type of resource #3858

@davidfowl davidfowl self-assigned this Sep 19, 2024
davidfowl added a commit that referenced this issue Sep 19, 2024
- Follow a scheme similar to what we do for persistent containers. Use the first 10 characters of the SHA256 of the app host's physical path as the volume name prefix.
- This is a breaking change and the only workaround is the manually specify the volume name.

Fixes #5413
@davidfowl davidfowl linked a pull request Sep 19, 2024 that will close this issue
16 tasks
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 breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. enhancement An enhancement to an existing feature or capability.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants