Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Oct 22, 2024

Description

With this PR, when using WithRedisInsight(...) the list of databases will be fetched from the RedisInsight instance and where they overlap with the names of the Redis Instances running already it will delete them so that the subsequent import won't result in duplicated entries.

Fixes #6111

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?
    • Yes
      • Link to aspire-docs issue:
    • No
Microsoft Reviewers: Open in CodeFlow

@mitchdenny mitchdenny self-assigned this Oct 22, 2024
@mitchdenny mitchdenny added this to the 9.0 milestone Oct 22, 2024
@eerhardt
Copy link
Member

Can you add some tests for this?

@mitchdenny
Copy link
Member Author

@eerhardt working on it. Turns out we don't have any tests for WithLifetime(...) so I'm having to tackle a few first of a kind problems:

  1. ResourceNameSuffix variations whilst under test.
  2. Cleaning up "persistent" containers after the test.

@mitchdenny
Copy link
Member Author

mitchdenny commented Oct 23, 2024

OK for the time being I've done a bit of a hack to make sure we have test coverage here. See the introduction of ApplicationExecutorProxy. Check out #6455 for more details on what I think the post 9.0 solution should look like.

NOTE: It was important to make sure we clean up these container that is running because due to persistence it would never have gotten cleaned up. So a dev running tests locally would just continue to accumulate Redis Insight instances - and if we did more persistent lifetime checks in CI we might end up running out of resources on the CI agent/Helix machines.

@mitchdenny mitchdenny requested a review from davidfowl October 23, 2024 10:14
@mitchdenny mitchdenny requested a review from eerhardt October 23, 2024 21:56

foreach (var redisResource in redisInstances)
{
if (lookup is { } && lookup.Contains(redisResource.Name))
Copy link
Member

Choose a reason for hiding this comment

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

Why are we deleting the servers that are already there, only to add them again?

Wouldn't the more appropriate approach be "if the server already exists, don't add it again" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the credentials could have changed. Using the api/databases call we don't have a mechanism to check that the credentials are the same, so we just blow it away and recreate.

Copy link
Member

Choose a reason for hiding this comment

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

It would be good to add this in a comment. I don't think this algorithm is intuitive.

Copy link
Member

@eerhardt eerhardt Oct 24, 2024

Choose a reason for hiding this comment

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

It would be good to add this in a comment. I don't think this algorithm is intuitive.

Did this ever happen?

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

The change looks fine. I'd just add some comments on why we are doing it this way.

@mitchdenny mitchdenny merged commit 9cfbdca into main Oct 24, 2024
9 checks passed
@mitchdenny mitchdenny deleted the mitchdenny/redisinsight-with-lifetime branch October 24, 2024 01:19
@mitchdenny
Copy link
Member Author

/backport to release/9.0

Copy link
Contributor

Started backporting to release/9.0: https://github.com/dotnet/aspire/actions/runs/11490840397

@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2024
@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-integrations Issues pertaining to Aspire Integrations packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WithRedisInsight and ContainerLifetime.Persistent causes multiple instances to show up
3 participants