Implicitly named volumes created by the WithDataVolume() method can collide across AppHost projects with the same name #5413
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
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.
The text was updated successfully, but these errors were encountered: