karpor icon indicating copy to clipboard operation
karpor copied to clipboard

上传kubeconfig验证提示不符合真实情况

Open regend opened this issue 1 year ago • 3 comments

What happened?

上传kubeconfig验证的时候,api server地址无法连接,但是显示的是"KubeConfig 不符合要求,请上传合法的证书内容" 验证kubeconfig的时候,返回的状态码是400/500,但是前端没有适配,导致没有正常返回错误信息

What did you expect to happen?

显示具体的错误信息: 比如cannot connect to the cluster server

How can we reproduce it (as minimally and precisely as possible)?

上传一个apiserver ip无法访问的kubeconfig,点击验证并接入

Anything else we need to know?

在后端代码中,若验证出现异常,状态码会是400或者500. 但是前端的axios写法在出现异常状态的时候,是拿不到response的msg的. ui/src/pages/cluster/add/index.tsx
message.error( validateResponse?.message || t('KubeConfigDoesNotMeetTheRequirements'), ) 当400/500的时候,这里的validateResponse是个空对象. 解法1: 后端返回200,但是在success里标注false来判断是否异常 解法2:前端通过捕获异常的方式来处理响应 我个人倾向于方案1, 因为200里的异常是程序可以预知的,而500错误应该是没有预知的逻辑异常.并且这样对前端的处理比较友好

Karpor version

v0.1.0

OS version

No response

Install tools

No response

regend avatar Aug 15 '24 04:08 regend

@regend Nice Catch!描述十分详细,对于错误处理的优化已经在另外一个分支上在做了,我 at 前端同学来看下是不是 cover 了这个场景 cc @hai-tian

elliotxx avatar Aug 15 '24 06:08 elliotxx

@regend Hi 这个问题会在 PR 中修复,正在验证中,近期就会合并进去

elliotxx avatar Aug 15 '24 07:08 elliotxx

@regend 上面的 PR 已合并,可以使用 helm 安装最新版本试用,看还有没有问题哈

elliotxx avatar Aug 22 '24 06:08 elliotxx

@regend 上面的 PR 已合并,可以使用 helm 安装最新版本试用,看还有没有问题哈

没有问题了 谢谢

regend avatar Aug 26 '24 03:08 regend

好的,那这个 issue 就先关闭了

elliotxx avatar Aug 26 '24 16:08 elliotxx