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

Added ability to resolve target port #3305

Merged
merged 3 commits into from
Apr 3, 2024

Conversation

davidfowl
Copy link
Member

@davidfowl davidfowl commented Mar 31, 2024

  • Change how we process and expose target ports. This change makes it possible to avoid using any internals of DCP to access and resolve target ports from any resource.
  • More launch profile processing to the project resource defaults.
  • Remove logic in the manifest writing that wrote a special env variable. This should just work now like everything else.
  • Exposed TargetPort and Exists on EndpointReference.
  • Use this new target property with dapr.
  • Added a ReferenceExpressionBuilder which makes it possible to dynamically build a ReferenceExpression.
  • Endpoints and env are evaluated earlier now so change remove tests that add default launch profile on real projects without allocating those endpoints.

cc @DamianEdwards this should fix dapr and the tests.

Goal is to have this go into p6 (API fit and finish).

- Change how we process and expose target ports. This change makes it possible to avoid using any internals of DCP to access and resolve target ports from any resource.
- More launch profile processing to the project resource defaults.
- Remove logic in the manifest writing that wrote a special env variable. This should just work now  like everything else.
- Exposed TargetPort and Exists on EndpointReference.
- Use this new target property with dapr.
- Added a ReferenceExpressionBuilder which makes it possible to dynamically build a ReferenceExpression.
- Endpoints and env are evaulated earlier now so change remove
tests that add default launch profile on real projects
without allocating those endpoints.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 31, 2024
{
var launchProfile = project.GetEffectiveLaunchProfile();
if (launchProfile is not null && !string.IsNullOrWhiteSpace(launchProfile.CommandLineArgs))
var cmdArgs = launchProfile.CommandLineArgs.Split((string?)null, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
Copy link
Member Author

@davidfowl davidfowl Mar 31, 2024

Choose a reason for hiding this comment

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

This should move to the project defaults as well #3306. I have a local change on top of this PR with that working.

@davidfowl davidfowl added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Mar 31, 2024
@davidfowl davidfowl added this to the preview 6 (Apr) milestone Mar 31, 2024
Copy link
Member

@karolz-ms karolz-ms left a comment

Choose a reason for hiding this comment

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

This is pretty neat; I really like how all the DCP details were encapsulated in this change.

Approving assuming that the launch profile command line argument handling will also go to ProjectResourceBuilderExtensions.

@davidfowl davidfowl merged commit 9185d29 into main Apr 3, 2024
8 checks passed
@davidfowl davidfowl deleted the davidfowl/target-port-resolution branch April 3, 2024 03:15
@DamianEdwards
Copy link
Member

you going to backport to p6 @davidfowl?

Comment on lines +71 to +73
/// The associated service name created in DCP for this endpoint.
/// </summary>
public string? DcpServiceName { get; }
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is a great public name in our application model.

Users don't really know (and shouldn't know IMO) about DCP at all. Is there a better name we can use here?

Copy link
Member

Choose a reason for hiding this comment

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

OrchestratorServiceName?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately this isn’t generic even if we change the property name (which is fine).

Also we have lots of dcp in the config, logging etc do we want to do a single pass?

Copy link
Member

Choose a reason for hiding this comment

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

Can we make it internal for now? We can always make it public later.

Copy link
Member Author

@davidfowl davidfowl Apr 3, 2024

Choose a reason for hiding this comment

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

That makes it impossible to write a test. This is difficult because we need something that can appear in string interpolated expression. It doesn’t need to be the dcp expression but it has to be something that we can detect and replace with the dcp expression, at runtime .

There’s another alternative that comes to mind:

Make it internal: Delete the property:

Don’t evaluate this object inside of the IValueProvider implementation, but have that object flow all the way out to evaluation phase (GetValue) in ApplicationExecutor.

I think that means we’d need to manually process ReferenceExpressions in GetValue, handling target port specially.

radical pushed a commit to radical/aspire that referenced this pull request Apr 3, 2024
* Added ability to resolve target port
- Change how we process and expose target ports. This change makes it possible to avoid using any internals of DCP to access and resolve target ports from any resource.
- More launch profile processing to the project resource defaults.
- Remove logic in the manifest writing that wrote a special env variable. This should just work now  like everything else.
- Exposed TargetPort and Exists on EndpointReference.
- Use this new target property with dapr.
- Added a ReferenceExpressionBuilder which makes it possible to dynamically build a ReferenceExpression.
- Endpoints and env are evaulated earlier now so change remove
tests that add default launch profile on real projects
without allocating those endpoints.

* Remove more uses of TestProgram

* Fix tests
eerhardt pushed a commit to eerhardt/aspire that referenced this pull request Apr 5, 2024
* Added ability to resolve target port
- Change how we process and expose target ports. This change makes it possible to avoid using any internals of DCP to access and resolve target ports from any resource.
- More launch profile processing to the project resource defaults.
- Remove logic in the manifest writing that wrote a special env variable. This should just work now  like everything else.
- Exposed TargetPort and Exists on EndpointReference.
- Use this new target property with dapr.
- Added a ReferenceExpressionBuilder which makes it possible to dynamically build a ReferenceExpression.
- Endpoints and env are evaulated earlier now so change remove
tests that add default launch profile on real projects
without allocating those endpoints.

* Remove more uses of TestProgram

* Fix tests
davidfowl added a commit that referenced this pull request Apr 6, 2024
* Added ability to resolve target port (#3305)

* Added ability to resolve target port
- Change how we process and expose target ports. This change makes it possible to avoid using any internals of DCP to access and resolve target ports from any resource.
- More launch profile processing to the project resource defaults.
- Remove logic in the manifest writing that wrote a special env variable. This should just work now  like everything else.
- Exposed TargetPort and Exists on EndpointReference.
- Use this new target property with dapr.
- Added a ReferenceExpressionBuilder which makes it possible to dynamically build a ReferenceExpression.
- Endpoints and env are evaulated earlier now so change remove
tests that add default launch profile on real projects
without allocating those endpoints.

* Remove more uses of TestProgram

* Fix tests

* Rename DcpServiceName to TargetPortExpression (#3371)

This allows us to not leak "DCP" into the public API and keeps DCP-isms contained in the DCP code.

* Do not set TargetPort to Port when IsProxying is also set (#3372)

* Do not set TargetPort to Port when IsProxied is true

* Move TargetPort check to ApplicationExecutor

* Apply port selection logic to manifest publishing

(cherry picked from commit 09f5ae9)

* Update src/Aspire.Hosting/Dcp/ApplicationExecutor.cs

Co-authored-by: Eric Erhardt <[email protected]>

---------

Co-authored-by: Eric Erhardt <[email protected]>

---------

Co-authored-by: David Fowler <[email protected]>
Co-authored-by: Reuben Bond <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators May 4, 2024
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 breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants