argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18.01k stars 5.49k forks source link

fix: Fix repeated 403 due to app namespace being undefined (#20699) #20819

Closed andrii-korotkov-verkada closed 5 days ago

andrii-korotkov-verkada commented 1 week ago

Fixes #20699

Constructor may not get called every time the application changes, so previous this.appNamespace could be stale. But the update to use this.props.match.params.appnamespace could also fail if it's undefined. As a fix, create and use a helper function getAppNamespace which has a special case handling for undefined.

Also, use a namespaced endpoint when namespace is not undefined.

It needs to be cherry-picked to v2.11-2.13.

Checklist:

bunnyshell[bot] commented 1 week ago

:x: Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

andrii-korotkov-verkada commented 1 week ago

✅ Preview Environment deployed on Bunnyshell

Component Endpoints argocd https://argocd-m3vpi2.bunnyenv.com/ argocd-ttyd https://argocd-web-cli-m3vpi2.bunnyenv.com/

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

* 🔴 `/bns:stop` to stop the environment

* 🚀 `/bns:deploy` to redeploy the environment

* ❌ `/bns:delete` to remove the environment

/bns:deploy

crenshaw-dev commented 1 week ago

✅ Preview Environment deployed on Bunnyshell

Component Endpoints argocd https://argocd-m3vpi2.bunnyenv.com/ argocd-ttyd https://argocd-web-cli-m3vpi2.bunnyenv.com/ See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

/bns:deploy

andrii-korotkov-verkada commented 1 week ago

I've checked Bunnyshell and didn't get any 403 while inspecting network stuff. The resource tree endpoint returns 200.

pasha-codefresh commented 1 week ago

Asked UI team to help with review. Thanks Andrii for fixing it, once we cherry-pick it , i will create release

andrii-korotkov-verkada commented 1 week ago

@pasha-codefresh, let's also include https://github.com/argoproj/gitops-engine/pull/640 and follow-up PR to use it. That's another nasty bug that should be fixed in 2.13.1

andrii-korotkov-verkada commented 6 days ago

@oleksandr-codefresh, @plakyda-codefresh, I've addressed the feedback. Thanks!

andrii-korotkov-verkada commented 6 days ago

Hm, jest is unhappy with using lodash-es. Also, it uses

function isUndefined(value) {
  return value === undefined;
}

which may not work in older browsers. I'll switch back to using a custom implementation.

pasha-codefresh commented 6 days ago

/bns:deploy

oleksandr-codefresh commented 6 days ago

@andrii-korotkov-verkada still, create dedicated utils function isUndefined to avoid duplication

andrii-korotkov-verkada commented 6 days ago

But it's so simple, that it'd be more code to import a helper function and use it comparing to just check inline.

andrii-korotkov-verkada commented 6 days ago

@pasha-codefresh, the bns commands on PR don't seem to do anything. And it seems not possible to comment on comment.

pasha-codefresh commented 6 days ago

@andrii-korotkov-verkada let me know once it is ready to review, i will run it locally and see if it works

andrii-korotkov-verkada commented 6 days ago

@pasha-codefresh, it should be ready to review.

pasha-codefresh commented 5 days ago

/bns:deploy

pasha-codefresh commented 5 days ago

✅ Preview Environment deployed on Bunnyshell

Component Endpoints argocd https://argocd-m3vpi2.bunnyenv.com/ argocd-ttyd https://argocd-web-cli-m3vpi2.bunnyenv.com/ See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

/bns:deploy

pasha-codefresh commented 5 days ago

@andrii-korotkov-verkada i am fine with this fix, but any reason why appNamespace should be undefined when you use search bar? i think we also should fix this in order to make it consistent. I can take a look into it

pasha-codefresh commented 5 days ago

/cherry-pick release-2.13

andrii-korotkov-verkada commented 5 days ago

@pasha-codefresh, I haven't figured that out.

pasha-codefresh commented 5 days ago

I will check it