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

Problems Using Garnet Images in Aspire.Hosting.Redis #7024

Open
calmbino opened this issue Jan 5, 2025 · 2 comments
Open

Problems Using Garnet Images in Aspire.Hosting.Redis #7024

calmbino opened this issue Jan 5, 2025 · 2 comments
Labels
untriaged New issue has not been triaged

Comments

@calmbino
Copy link

calmbino commented Jan 5, 2025

I tried to use Garnet image on Aspire.Hosting.Redis as follows.

var cache = builder.AddRedis("cache")
                   .WithImageRegistry("ghcr.io")
                   .WithImage("microsoft/garnet")
                   .WithImageTag("latest")
                   .WithRedisInsight();

It runs normally and well. However, if you try to set the volume or mount for persistence, it will cause problems.

var cache = builder.AddRedis("cache")
                   .WithImageRegistry("ghcr.io")
                   .WithImage("microsoft/garnet")
                   .WithImageTag("latest")
                   .WithDataBindMount("../../docker/garnet/data")
                   .WithPersistence(TimeSpan.FromSeconds(10), 5)
                   .WithRedisInsight()

I refer to the execution log and the source code, I think the cause of the problem is that Garnet does not support the -- save option

Image

src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs

public static IResourceBuilder<RedisResource> WithPersistence(this IResourceBuilder<RedisResource> builder, TimeSpan? interval = null, long keysChangedThreshold = 1)
    {
        ArgumentNullException.ThrowIfNull(builder);

        return builder.WithAnnotation(new CommandLineArgsCallbackAnnotation(context =>
        {
            context.Args.Add("--save"); // <--
            context.Args.Add(
                (interval ?? TimeSpan.FromSeconds(60)).TotalSeconds.ToString(CultureInfo.InvariantCulture));
            context.Args.Add(keysChangedThreshold.ToString(CultureInfo.InvariantCulture));
            return Task.CompletedTask;
        }), ResourceAnnotationMutationBehavior.Replace);
    }

Of course, the above issue will be easily resolved by not using Garnet images or by using Aspire.Hosting.Garnet instead of Aspire.Hosting.Redis.

But I think I can face the above problem situation because I know garnet is compatible with redis.

Anyway, if I want to use Garnet for now, would it be best to use Aspire.Hosting.Garnet?

And I was wondering if Aspire.Hosting.Garnet has any plans to add dashboard options like RedisInsight or RedisCommander

@Alirexaa
Copy link
Contributor

Alirexaa commented Jan 6, 2025

@calmbino, Why do you use Aspire.Hosting.Redis instead of Aspire.Hosting.Garnet?

Garnet is not fully compatible with Redis.
See:
https://microsoft.github.io/garnet/docs#api-coverage.

Garnet uses different approaches to persist data, Therefore you should use Aspire.Hosting.Garnet.

And I was wondering if Aspire.Hosting.Garnet has any plans to add dashboard options like RedisInsight or RedisCommander.

I'm not sure RedisInsight is compatible with Garnet. Have you tried using RedisInsight to connect to Garnet (outside of Aspire, e.g., using docker-compose)?
I could send PR for that if RedisInsight is compatible with Garnet.

See #4519 for RedisCommander.

@calmbino
Copy link
Author

calmbino commented Jan 7, 2025

@Alirexaa , First of all, thank you for your answer.

Why do you use Aspire.Hosting.Redis instead of Aspire.Hosting.Garnet?

The answer to the above question is as follows.

  • I watched the tutorial uploaded to YouTube and followed it. He used Garnet images while using Aspire.Hosting.Redis
  • After that, I found out that Aspire.Hosting.Garnet exists. But as I asked above, I wanted to use Dashboard, so I wanted to use Aspire.Hosting.Redis

I'm not sure RedisInsight is compatible with Garnet. Have you tried using RedisInsight to connect to Garnet (outside of Aspire, e.g., using docker-compose)?

I'm not exactly sure about this question. I haven't tested it outside of Aspire by connecting Garnet and RedisInsight. However, I applied the Garnet image to Aspire.Hosting.Redis and WithRedisInsight. When I used commands like set and get on the Dashboard, it worked fine and I don't think Garnet and RedisInsight were exactly compatible because it was a very simple test.

In conclusion, I'm not arguing that "Aspire.Hosting.Redis should support Garnet." I found a problem with a situation found during the testing process, and I wanted to communicate this situation.

Now I know that if I have to use Garnet, I have to use Aspire.Hosting.Garnet.

@joperezr joperezr added the untriaged New issue has not been triaged label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged New issue has not been triaged
Projects
None yet
Development

No branches or pull requests

3 participants