Skip to content

Allow disabling proxy for persistent lifetime container endpoints#7232

Merged
davidfowl merged 11 commits intomicrosoft:mainfrom
danegsta:dev/danegsta/persistentProxy
Jan 28, 2025
Merged

Allow disabling proxy for persistent lifetime container endpoints#7232
davidfowl merged 11 commits intomicrosoft:mainfrom
danegsta:dev/danegsta/persistentProxy

Conversation

@danegsta
Copy link
Copy Markdown
Member

@danegsta danegsta commented Jan 24, 2025

Description

The endpoint port assignment for persistent lifetime containers can be confusing due to Aspire creating proxied endpoints for all resources by default. This means that the ports reported for persistent containers in the Aspire dashboard are only valid while the App Host is running and the only way to access persistent containers while the App Host is not running is to inspect them and figure out what random port the container endpoint was exposed on.

This PR adds a new opt-in (and experimental) resource builder API .WithEndpointProxySupport(false) that can disable all proxies for the endpoints of a given container resource. In the long run we'd like to make this the new default behavior for persistent containers, but there is additional service discovery work that will need to happen before we can safely make proxy-less persistent containers the default behavior.

The main thing to be aware of when applying .WithEndpointProxySupport(false) to a container resource is that by default Aspire will attempt to use the (internal container) target port as the host port to expose the service. This significantly increases the risk of port conflicts or other issues allocating ports with the default behavior endpoint behavior. It's recommended that any resources being run with endpoint proxies disabled has explicit (unique) host ports set for all its endpoints.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Comment thread src/Aspire.Hosting/Dcp/ApplicationExecutor.cs Outdated
Comment thread src/Aspire.Hosting/Dcp/ApplicationExecutor.cs Outdated
@davidfowl
Copy link
Copy Markdown
Contributor

@JamesNK moved stuff around 😄

Comment thread src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs Outdated
@danegsta danegsta force-pushed the dev/danegsta/persistentProxy branch from f55adeb to 9e040d5 Compare January 24, 2025 18:27
Comment thread src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs Outdated
Comment thread src/Aspire.Hosting.Kafka/KafkaBuilderExtensions.cs
Comment thread src/Aspire.Hosting.Kafka/KafkaBuilderExtensions.cs Outdated
Comment thread src/Aspire.Hosting/ResourceBuilderExtensions.cs
Comment thread src/Aspire.Hosting/ResourceBuilderExtensions.cs Outdated
@danegsta danegsta requested a review from mitchdenny as a code owner January 27, 2025 23:01
@danegsta
Copy link
Copy Markdown
Member Author

/AzurePipelines run

@azure-pipelines
Copy link
Copy Markdown

Pull request contains merge conflicts.

@danegsta danegsta changed the title Disable proxy for persistent lifetime container endpoints Allow disabling proxy for persistent lifetime container endpoints Jan 27, 2025
@davidfowl davidfowl merged commit 3342152 into microsoft:main Jan 28, 2025
@davidfowl
Copy link
Copy Markdown
Contributor

@danegsta good discussion and tradeoffs 😄. Can you make sure we document and update the relevant issue in 9.1?

@github-actions github-actions Bot locked and limited conversation to collaborators Feb 27, 2025
@github-actions github-actions Bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 10, 2025
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

Development

Successfully merging this pull request may close these issues.

2 participants