Skip to content

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented May 6, 2025

Description

URLs weren't populated for unstarted and waiting resources. This means they weren't properly linked to in traces.

Fix is to make sure ResourceUrlAnnotation values are populated before the snapshot is published.

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?

@JamesNK JamesNK requested review from davidfowl and karolz-ms May 6, 2025 14:09
@JamesNK JamesNK requested a review from mitchdenny as a code owner May 6, 2025 14:09
@JamesNK JamesNK added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label May 6, 2025
@JamesNK JamesNK changed the title Make URLs available on snapshot of waiting resources Make URLs available on snapshot of unstarted and waiting resources May 6, 2025
@davidfowl
Copy link
Member

Confused by this. Does that mean urls will be clickable before the resource starts?

@JamesNK
Copy link
Member Author

JamesNK commented May 6, 2025

Confused by this. Does that mean urls will be clickable before the resource starts?

No, because they're inactive. And the UI only displays active URLs.

But traces UI in the dashboard can use them to match requests to a resource. For example, if the catalogservice resource is waiting for the database resource to start, but a request is made that attempts to call it, the traces UI will know show catalogservice as the destination instead of localhost:5392 because it can use the inactive URL to make that connection.

@JamesNK
Copy link
Member Author

JamesNK commented May 6, 2025

This is basically an improvement to #7906. It now works for resources that have never been started, e.g. resource has explicit start annotation, or is in a waiting state.

@JamesNK
Copy link
Member Author

JamesNK commented May 6, 2025

Actually, my change in #7906 originally supported unstarted/waiting resources. But it was regressed in the change to support custom URLs: #8229

The fix for this regression is calling ProcessUrls before DCP info is pushed into the snapshot.

@davidfowl
Copy link
Member

cc @DamianEdwards


try
{
await ProcessUrls(resource, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

Does moving this to DcpExecutor impact adding URLs to custom resources? Or is the name just misleading 😁

Copy link
Member Author

@JamesNK JamesNK May 6, 2025

Choose a reason for hiding this comment

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

I moved ProcessUrls out of the OnResourceStarting method. That method is only called by the DCP. I believe this only would have been called for DCP resources.

Do you intend to ProcessUrls to be called for non-DCP resources? I assume non-DCP resources should have ResourceUrlAnnotation added to them directly.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm this might actually be an oversight in the original implementation. We had intended for URLs to be supported on any resource type, not just resources with endpoints (which is why the WithUrls extension method is only constrained to IResource) but the code in ApplicationOrchestrator is only calling callbacks for IResourceWithEndpoints resources. I'll log an issue to track this.

Copy link
Member

Choose a reason for hiding this comment

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

@JamesNK JamesNK merged commit 7f4bea1 into main May 6, 2025
170 checks passed
@JamesNK JamesNK deleted the jamesnk/waiting-populate-urls branch May 6, 2025 22:37
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 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.

5 participants