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

Make sure bind mount paths are relative to the app host directory #3467

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

davidfowl
Copy link
Member

@davidfowl davidfowl commented Apr 7, 2024

  • Made it so that bind mounts annotations are resolved relative to the app host directory by default.
  • Bind mounts without a rooted path will throw an error.
  • Removed logic from ApplicationExecutor that checks the annotation data since this is checked in the constructor.
  • Added tests (moved tests to Containers folder)

Fixes #3323

Microsoft Reviewers: Open in CodeFlow

- Made it so that bind mounts annotations are resolved relative to the app host directory by default.
- Bind mounts without a rooted path will throw an error.
- Removed logic from ApplicationExecutor that checks the annotation data since this is checked in the constructor.
- Added tests (moved tests to Containers folder)
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Apr 7, 2024
@mitchdenny
Copy link
Member

Looks pretty good. Just one comment about hard coding paths.

@@ -44,8 +44,10 @@ public void AddNatsContainerWithDefaultsAddsAnnotationMetadata()
[Fact]
public void AddNatsContainerAddsAnnotationMetadata()
{
var path = OperatingSystem.IsWindows() ? @"C:\tmp\dev-data" : "/tmp/dev-data";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't hard code these paths.

Copy link
Member Author

@davidfowl davidfowl Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? We need a well-formed path because we call GetFullPath on the input. This makes the assert a little more sane 😄

@davidfowl davidfowl requested a review from eerhardt April 8, 2024 17:47
internal string? ProjectDirectory => _projectDirectory.Value;
internal string? ProjectDirectory
{
get => _projectDirectory ?? _projectDirectoryLazy.Value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
get => _projectDirectory ?? _projectDirectoryLazy.Value;
get => _projectDirectory ??= _projectDirectoryLazy.Value;

Might as well set this after you evaluate it, right?

Another thought is to remove the field altogether. I don't see it being used in tests. Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea the property is being used in tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing to mark the field with the comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? This is only a field so we can set it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically when someone puts a comment like:

// for testing
internal Foo() {}

It means Foo is getting called/used by tests.

A whole other option is to just use a single field, and when it is null during get generate the value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A whole other option is to just use a single field, and when it is null during get generate the value.

But I guess the lazy value could be null, so that helps little.

}

[Fact]
public void EnsureContainerWithArgsEmitsContainerArgs()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this test get deleted? I don't see it on the "right" side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My goal is to move all tests (incrementally) to resource specific folders (projects). This manifest generation test needs to die 😄 (or only be used for testing cross cutting things like writing the entire manifest).

@davidfowl davidfowl merged commit 3175d71 into main Apr 8, 2024
8 checks passed
@davidfowl davidfowl deleted the davidfowl/relative-bind-mounts branch April 8, 2024 22:04
@davidfowl
Copy link
Member Author

/backport to release/8.0

Copy link
Contributor

github-actions bot commented Apr 8, 2024

Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8607190574

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