-
Notifications
You must be signed in to change notification settings - Fork 496
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
Add WithVolumeMountForData #1317
Add WithVolumeMountForData #1317
Conversation
Thanks for this. We should add overloads of this method that support the other database container resources too, with the appropriate path in those cases. |
Before adding the others i would wait for the discussion on the issue (#837 (comment)). If this is still the approch we stick too i will continue adding the overloads. |
223216d
to
3a22a40
Compare
@josephaw1022 created a second (duplicate) PR for this one: #1447 |
Probably we should wait for #1521 and then see how it affects this pr (especially the volume/bind mount stuff) |
@stbau04 Would you like to resurrect this PR? |
@DamianEdwards wdyt? |
@davidfowl yeah I like this a lot actually. @stbau04 if you're around it would be great if you could update this for changes since Dec (mainly the split out of |
@davidfowl @DamianEdwards Yes sure, i'll update it |
I'm gonna assign this to you @stbau04. Thanks! |
There are the following container resources that might support some of the methods (the checked ones are implemented): |
Seems you did a merge instead of a rebase so this PR is showing up as including all changes on main since you originally created it! Can you go back to before you merged and do a rebase on main instead, and then force push to your fork/branch? |
@DamianEdwards @mitchdenny Do we want to align here with the aspire/src/Aspire.Hosting.Azure/Extensions/AzureStorageExtensions.cs Lines 123 to 128 in 1d868e8
Feels like we should have a consistent pattern. The above picks a default name as well. |
I'm not sure I like the interfaces in this PR. It seems to me that persistence for each container is a fairly container specific thing and we might want to have a specific extension method for each container. Perhaps in that case the overload takes a |
Thinking about this some more, I think what we want here is a per container type extension that takes into consideration the various quirks assocaited with each container. So instead of a pattern that would seem people doing this: builder.AddRedis("redis").WithBindMountForLogs(path).WithBindMountForInit(path).WithBindMountForData(path) We could just do this: builder.AddRedis("redis").WithPersistence(path); The benefit is that it is a simpler gesture for the consumer of the container and it allows us to abstract away wierdness that some containers might have. For example, the Cosmos container which we use for the emulator doesn't seem to work with bind mounts -- so this mechanism wouldn't work. Instead for that we'd need to implement a So in summary ... its good to make it easy for people to turn on persistence for a given container (we should do that!) but lets not make it generic when it probably isn't because we have to live with this abstraction for a while ;) |
I think we need more than a single method if for no other reason than to support bind mounts vs. volumes. Perhaps it's just two overloads (one accepting a path and another not) but I think that's less clear than the proposed methods. Personally not a fan of the |
Perhaps a simple change to |
db89bd9
to
d896322
Compare
To address @mitchdenny's concerns here I think a good compromise would be to get rid of the interfaces and just establish a pattern for these kind of container-based resources by adding methods like For init and logs, I think it only makes sense to have support for bind mounts for init, and both volume and bind mounts for logs. Reasoning being that init is all about an input to the container (run these scripts) whereas data and logs are potentially input and output. In the case of volumes, we should support auto-generating a name based on the resource name or specifying a name. So we'd end up with methods like the following on the relevant container-based resources:
Open question is whether we should support auto-generating a source location for the bind mount methods (like the azurite one does). I'm not particularly fussed on that, could take it or leave it. Perhaps we leave it for now and can always add it later. |
@stbau04 are you able to update your approach here to what I described above? |
@DamianEdwards Yes sure |
Is that the desired approach we should follow? |
That is what I'm currently proposing, Would be good to explicitly hear from @mitchdenny if he has any concerns with that approach. |
@DamianEdwards @mitchdenny I've applied the proposed approach to the first few containers. If you are fine with this solution i would continue implementing it for the remaining resources. Do you have any imput for me? Especially what about the naming for the volumes, is the default name ok like that? If we keep it as it is, you cannot run a project twice on the same host - or have resources with the same name in different projects - if you want to use the auto-generated name. Are we fine with that? |
@stbau04 thanks for the updates! Were there more resource types you were planning to apply this pattern to? |
I would leave the azure resources as they are currently being renovated by @mitchdenny. @mitchdenny you can take this pattern to the existing emulators. |
@stbau04 I think this is ready to review now? |
@DamianEdwards I could maybe add some methods for the following: KafkaServerResource, MongoExpressContainerResource, PhpMyAdminContainerResource, OracleDatabaseServerResource, PgAdminContainerResource and RedisCommandResource (might take me some time to figure out the correct paths) |
KafkaServerResource - 👍🏾 The rest I would skip. |
@DamianEdwards I've added some method for the KafkaServer and OracleDatabaseServer resoures. I think it should be ready for review now |
@mitchdenny We need to change cosmos and azure storage to use the same pattern yes? |
Seq differs a little here:
We should make this follow the same pattern I think. |
It can be a follow up though |
Thanks @stbau04 !!!! |
Make it easier to use external volumes for database containers:
Fixes #837
Microsoft Reviewers: Open in CodeFlow