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

feat: add the --redis-compress as the global flag to set redis compression. #21786

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nitishfy
Copy link
Member

@nitishfy nitishfy commented Feb 5, 2025

Closes #21742

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

After

> dist/argocd app resources guestbook                             
GROUP  KIND        NAMESPACE  NAME          ORPHANED
       Service     guestbook  guestbook-ui  No
apps   Deployment  guestbook  guestbook-ui  No
               
> dist/argocd app resources guestbook --core                      
GROUP  KIND        NAMESPACE  NAME          ORPHANED
       Service     guestbook  guestbook-ui  No
apps   Deployment  guestbook  guestbook-ui  No
               
> dist/argocd app resources guestbook --core --redis-compress none
Cache Key is missing.
Ensure that the Redis compression setting on the Application controller and CLI is same. See --redis-compress.
ERRO[0001] finished unary call with code Unknown         error="error getting cached app resource tree: cache: key is missing" grpc.code=Unknown grpc.method=ResourceTree grpc.service=application.ApplicationService grpc.start_time="2025-02-08T14:55:11+05:30" grpc.time_ms=886.494 span.kind=server system=grpc
FATA[0001] rpc error: code = Unknown desc = error getting cached app resource tree: cache: key is missing
               
>  k edit cm argocd-cmd-params-cm # enable the compression to none
configmap/argocd-cmd-params-cm edited
               
> dist/argocd app resources guestbook --core --redis-compress none
GROUP  KIND        NAMESPACE  NAME          ORPHANED
       Service     guestbook  guestbook-ui  No
apps   Deployment  guestbook  guestbook-ui  No

> dist/argocd app resources guestbook --core # why this succeeded even though the default compression type is 'gzip' ? Because the key was initially set in gzip when the compression on controller was gzip.  Hence, the key is present.            
GROUP  KIND        NAMESPACE  NAME          ORPHANED
       Service     guestbook  guestbook-ui  No
apps   Deployment  guestbook  guestbook-ui  No
               
> dist/argocd app resources guestbook        
GROUP  KIND        NAMESPACE  NAME          ORPHANED
       Service     guestbook  guestbook-ui  No
apps   Deployment  guestbook  guestbook-ui  No

@nitishfy nitishfy requested a review from a team as a code owner February 5, 2025 12:44
Copy link

bunnyshell bot commented Feb 5, 2025

🔴 Preview Environment stopped on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

// If we're not in core mode, this function call will do nothing. The Redis Compression has been set
// to GZip because it is the default compression type.
// https://github.com/argoproj/argo-cd/issues/13458
err := MaybeStartLocalServer(ctx, opts, ctxStr, nil, nil, cache.RedisCompressionGZip, nil)
Copy link
Member

Choose a reason for hiding this comment

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

It's probably better to make this a user configurable option with the default being gzip.

Copy link
Member Author

@nitishfy nitishfy Feb 5, 2025

Choose a reason for hiding this comment

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

We already have the --redis-compress flag for argocd admin dashboard command with default set to gzip - argocd admin dashboard --redis-compress gzip starts the Web UI with gzip compression.

Copy link
Member

Choose a reason for hiding this comment

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

So your command should be using the input from that flag and not hard coding the compression value like you are doing rn?

Copy link
Member

Choose a reason for hiding this comment

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

+1 to @gdsoumya 's question. Instead of setting the gzip compression directly here, should we pick it up from the value of --redis-compress?

Copy link
Member Author

@nitishfy nitishfy Feb 6, 2025

Choose a reason for hiding this comment

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

There are three ways to handle this scenario then:

  1. Search for the redis-compress flag using the flag.Visit() function and see if it has been set.
  2. Add the flag as a global flag to the root command which means adding it as a client option.
  3. Change the NewClientOrDie(opts *apiclient.ClientOptions, c *cobra.Command) function to accept compression type as an argument (but since this function is used at a lot of places, I'm afraid if making changes to this function would be beneficial).

I'd personally suggest leaving the compression type as it is if none of the above ways seems efficient. Any suggestions here? cc @crenshaw-dev

Copy link
Member Author

Choose a reason for hiding this comment

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

That's going to lead to a circular dependency in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Could we add the setting to apiclient.ClientOptions? That would keep the method signature the same but let us set the configurable value.

Copy link
Member

Choose a reason for hiding this comment

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

I think I just rephrased what you described as number 2. :-) We've got too many global flags, but if any global flags make sense, it's probably this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, that's what I was thinking to implement too. Thanks for confirming.

Copy link
Member

@gdsoumya gdsoumya Feb 7, 2025

Choose a reason for hiding this comment

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

That's going to lead to a circular dependency in that case|

I do not understand what you mean? We are already doing it just 2 lines above this to get the "context" flag.

ClientOptions was my initial suggestion but I removed it because we already have a flag and we can access it from there. If we can't then we can add a new field to clientopts.

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@5b79c34). Learn more about missing BASE report.

Files with missing lines Patch % Lines
cmd/argocd/commands/admin/cluster.go 0.00% 14 Missing ⚠️
cmd/argocd/commands/admin/dashboard.go 0.00% 4 Missing ⚠️
cmd/argocd/commands/headless/headless.go 0.00% 3 Missing ⚠️
server/application/application.go 0.00% 3 Missing ⚠️
cmd/argocd/commands/root.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #21786   +/-   ##
=========================================
  Coverage          ?   55.64%           
=========================================
  Files             ?      339           
  Lines             ?    56847           
  Branches          ?        0           
=========================================
  Hits              ?    31633           
  Misses            ?    22560           
  Partials          ?     2654           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nitishfy nitishfy requested a review from gdsoumya February 5, 2025 16:37
@nitishfy nitishfy force-pushed the fix-redis-compression-type branch from b3d13ad to 890a1c8 Compare February 8, 2025 08:35
@nitishfy nitishfy changed the title fix: change the redis compression type to gzip for core mode feat: add the --redis-compress as the global flag to set redis compression. Feb 8, 2025
Signed-off-by: nitishfy <[email protected]>

add --redis-compress flag

Signed-off-by: nitishfy <[email protected]>

remove comment

Signed-off-by: nitishfy <[email protected]>

fix lint checks

Signed-off-by: nitishfy <[email protected]>

run codegen

Signed-off-by: nitishfy <[email protected]>
@nitishfy nitishfy force-pushed the fix-redis-compression-type branch from 4ed23fb to ba1e892 Compare February 8, 2025 09:19
@nitishfy nitishfy requested a review from a team as a code owner February 8, 2025 09:19
Copy link
Member Author

@nitishfy nitishfy left a comment

Choose a reason for hiding this comment

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

An After section has been added in the PR title. PTAL.

Copy link
Member

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

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

Thanks @nitishfy, LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Argocd CLI with --core: key is missing
4 participants