Fix port mismatch for bait-and-switch resources in Kubernetes publisher#14651
Closed
joperezr wants to merge 4 commits intorelease/13.2from
Closed
Fix port mismatch for bait-and-switch resources in Kubernetes publisher#14651joperezr wants to merge 4 commits intorelease/13.2from
joperezr wants to merge 4 commits intorelease/13.2from
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14651Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14651" |
Member
Author
|
Closing for now — the revert PR needs to merge first to avoid conflicts. Will recreate after that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #14590 into release/13.2.
The original PR was accidentally retargeted from main to release/13.2, which brought all main branch commits along. This PR contains only the original commits by @bbartels with the fix.
Description
The Kubernetes publisher uses a
Dictionary<IResource, KubernetesResource>cache inKubernetesEnvironmentContextkeyed by object identity. WhenPublishAsDockerFile()replaces anExecutableResourcewith anExecutableContainerResource(the 'bait and switch' pattern), other resources still holdEndpointReferenceobjects pointing to the original. The cache misses on the original vs replacement, creating twoKubernetesResourceobjects for the same logical resource, each allocating a different port from the sharedPortAllocator. This causes the referencing resource to get a different port than the one in the service/deployment YAML.The fix applies the same
ResourceNameComparerpattern already used by the Docker Compose, Azure App Service, and Azure Container Apps publishers.Fixes #9226