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

Re-execute envvar and arg callbacks when restarting resources #7329

Merged
merged 4 commits into from
Feb 7, 2025

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Jan 30, 2025

Description

When a resource is first started by DCP it applies envvar and arg settings based on values from callbacks. Restarting a resource now reuses the same code to apply values again.

Also in this PR is a refactor of how callbacks are executed and applied. They're moved to new methods and reused between containers and executables.

Fixes #5879

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 added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jan 30, 2025
@JamesNK JamesNK requested review from davidfowl and eerhardt January 30, 2025 09:41
@JamesNK JamesNK requested a review from mitchdenny as a code owner January 30, 2025 10:38
@JamesNK JamesNK force-pushed the jamesnk/dcpexecutor-cleanup branch from 40b15e6 to 1c0cf60 Compare January 30, 2025 13:46
@JamesNK
Copy link
Member Author

JamesNK commented Jan 31, 2025

The isinitialized check isn’t needed anymore after the last dcp refactor. Resource is now initialized on every start

@davidfowl
Copy link
Member

Need to rewrite this against my refactor #7360

@danmoseley danmoseley added the needs-author-action An issue or pull request that requires more info or actions from the author. label Feb 2, 2025
@danmoseley danmoseley requested a review from Copilot February 3, 2025 21:08
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (4)

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1248

  • The variable 'value' is cast to 'string' without checking if it is indeed a 'string'. This could potentially cause a runtime error. Ensure 'value' is a 'string' before casting.
var resolvedValue = value switch

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1258

  • The variable 'resolvedValue' is cast to 'string' without checking if it is indeed a 'string'. This could potentially cause a runtime error. Ensure 'resolvedValue' is a 'string' before casting.
specs.Add((string)resolvedValue);

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1221

  • [nitpick] The error message 'Failed to apply argument '{ConfigKey}'' should be more specific about which argument failed. Consider including the argument name or value in the message.
resourceLogger.LogCritical(ex, "Failed to apply argument '{ConfigKey}'. A dependency may have failed to start.", value);

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1263

  • [nitpick] The error message 'Failed to apply container runtime argument '{ConfigKey}'' should be more specific about which argument failed. Consider including the argument name or value in the message.
resourceLogger.LogCritical(ex, "Failed to apply container runtime argument '{ConfigKey}'. A dependency may have failed to start.", value);

@JamesNK JamesNK force-pushed the jamesnk/dcpexecutor-cleanup branch from 1c0cf60 to 308dbcd Compare February 6, 2025 15:40
@JamesNK JamesNK removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Feb 6, 2025
@JamesNK
Copy link
Member Author

JamesNK commented Feb 6, 2025

@davidfowl Updated. Please take a look.

@davidfowl davidfowl requested a review from karolz-ms February 6, 2025 15:57
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.

Makes a lot of sense

@davidfowl
Copy link
Member

Where are the conflicts??

@davidfowl
Copy link
Member

Oh @adamint 's change 😄

@adamint
Copy link
Member

adamint commented Feb 6, 2025

😄

@JamesNK JamesNK force-pushed the jamesnk/dcpexecutor-cleanup branch from 308dbcd to 3b32398 Compare February 7, 2025 00:22
@JamesNK
Copy link
Member Author

JamesNK commented Feb 7, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JamesNK
Copy link
Member Author

JamesNK commented Feb 7, 2025

Are these real test failures or no?

@davidfowl
Copy link
Member

No, #7448

@davidfowl davidfowl merged commit dd868c2 into main Feb 7, 2025
57 of 62 checks passed
@davidfowl davidfowl deleted the jamesnk/dcpexecutor-cleanup branch February 7, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

Make it possible to start and stop containers and executables that aren't weren't fully initialized by DCP
5 participants