Skip to content

Conversation

@Super-zhw
Copy link

No description provided.

@tencentblueking-adm
Copy link

tencentblueking-adm commented Sep 3, 2025

CLA assistant check
All committers have signed the CLA.

Super-zhw added a commit to Super-zhw/bk-hcm that referenced this pull request Sep 3, 2025
Super-zhw added a commit to Super-zhw/bk-hcm that referenced this pull request Sep 4, 2025
Signed-off-by: huiwenzhang <huiwenzhang@tencent.com>
Super-zhw added a commit to Super-zhw/bk-hcm that referenced this pull request Sep 4, 2025
Signed-off-by: huiwenzhang <1458070668@qq.com>
@Super-zhw Super-zhw force-pushed the cfs/dev branch 2 times, most recently from 4dbc341 to 269bb7a Compare September 4, 2025 06:38
Super-zhw added a commit to Super-zhw/bk-hcm that referenced this pull request Sep 4, 2025
Signed-off-by: Super-zhw <1458070668@qq.com>
Super-zhw added a commit to Super-zhw/bk-hcm that referenced this pull request Sep 16, 2025
Signed-off-by: Super-zhw <1458070668@qq.com>
Super-zhw added a commit to Super-zhw/bk-hcm that referenced this pull request Sep 19, 2025
Signed-off-by: Super-zhw <1458070668@qq.com>
Signed-off-by: Super-zhw <1458070668@qq.com>
logs.Errorf("create cfs storage request decode failed, err: %v, rid: %s", err, cts.Kit.Rid)
return nil, errf.NewFromErr(errf.DecodeRequestFailed, err)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

if err := req.Validate(); err != nil {
return nil, errf.NewFromErr(errf.InvalidParameter, err)
}
缺少参数校验逻辑

accountInfo, err := svc.client.DataService().Global.Cloud.GetResBasicInfo(cts.Kit, enumor.AccountCloudResType,
req.AccountID)
if err != nil {
logs.Errorf("get account basic info failed, err: %v, rid: %s", err, cts.Kit.Rid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

记录下accountID吧,方便排查哪个账号没查到

if err := cts.DecodeInto(req); err != nil {
logs.Errorf("delete cfs storage request decode failed, err: %v, rid: %s", err, cts.Kit.Rid)
return nil, errf.NewFromErr(errf.DecodeRequestFailed, err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上

return nil, errf.NewFromErr(errf.DecodeRequestFailed, err)
}

//// note: 暂时不验证权限
Copy link
Collaborator

Choose a reason for hiding this comment

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

加个TODO标识吧

//authRes := meta.ResourceAttribute{Basic: &meta.Basic{Type: meta.CfsStorage, Action: meta.Find,
// ResourceID: req.AccountID}}
//if err := svc.authorizer.AuthorizeWithPerm(cts.Kit, authRes); err != nil {
// logs.Errorf("list cfs storage auth failed, err: %v, account id: %s, rid: %s", err, req.AccountID, cts.Kit.Rid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

“get cfs storage auth failed”

accountInfo, err := svc.client.DataService().Global.Cloud.GetResBasicInfo(cts.Kit, enumor.AccountCloudResType,
req.AccountID)
if err != nil {
logs.Errorf("get account basic info failed, err: %v, rid: %s", err, cts.Kit.Rid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上

switch vendor {
case enumor.TCloud: // 只支持腾讯云
return createCfs[corecfs.TCloudCfsExtension](cts, svc, vendor)
//case enumor.Aws:
Copy link
Collaborator

Choose a reason for hiding this comment

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

注释内容可以去掉

if err := req.Validate(); err != nil {
return nil, errf.NewFromErr(errf.InvalidParameter, err)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

下面出现error的地方,适当补些日志吧

},
}, nil

//return &protocloud.CfsExtListResult[corecfs.TCloudCfsExtension]{Count: result.Count}, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

注释去掉吧

case enumor.TCloud:
return convCfsGetResult[corecfs.TCloudCfsExtension](base, cfsTable.Extension)

//case enumor.Aws:
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上

}

//// ListCfs cfs.
//func (svc *cfsSvc) ListCfs(cts *rest.Contexts) (interface{}, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

直接去掉

BkBizID: one.BkBizID,
AccountID: one.AccountID,
Vendor: one.Vendor,
//
Copy link
Collaborator

Choose a reason for hiding this comment

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

怎么有个//

tSdk, err := svc.ad.TCloud(cts.Kit, req.AccountID)
if err != nil {
logs.Errorf("request dataservice create tcloud cfs failed, rid: %s", cts.Kit.Rid)
return nil, errors.Wrapf(err, "request dataservice create tcloud cfs failed, rid: %s", cts.Kit.Rid)
Copy link
Collaborator

@ZQHcode ZQHcode Oct 22, 2025

Choose a reason for hiding this comment

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

err里不用带rid,下同

*tcloudResp.Cfs.FileSystemId, cts.Kit.Rid)
}
// 获取cfs
resp, err := svc.dc.TCloud.Cfs.GetCfs(cts.Kit.Ctx, cts.Kit.Header(), createResp.IDs[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

createResp.IDs[0]做一下长度判断吧,防止panic

}
// db删除
deleteReq := new(protocloud.CfsBatchDeleteReq)
deleteReq.Filter = tools.ContainersExpression("id", []string{resp.ID})
Copy link
Collaborator

Choose a reason for hiding this comment

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

只有一个的话,直接用tools.EqualExpression就好了

}
}

// 数据同步
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个是什么原因呢,为什么查询接口里会有数据同步逻辑?

logs.Errorf("ListTCloudCfs validate request failed, err: %v, rid: %s", err, cts.Kit.Rid)
return nil, errf.NewFromErr(errf.InvalidParameter, err)
}
//// 云上资源查询
Copy link
Collaborator

Choose a reason for hiding this comment

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

不需要的话就去掉吧

TieringState: info.Cfs.TieringState,
TieringDetail: info.Cfs.TieringDetail,
Version: info.Cfs.Version,
//MetaType: info.Cfs.MetaType,
Copy link
Collaborator

Choose a reason for hiding this comment

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

注释掉的统一去掉吧,下同

logs.Errorf("tcloud cfs create failed, err: %v, rid: %s", err, kt.Rid)
return nil, err
}
//respStr, _ := json.MarshalToString(createResp) // debug log
Copy link
Collaborator

@ZQHcode ZQHcode Oct 22, 2025

Choose a reason for hiding this comment

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

去掉,下同

return nil, err
}
if len(resp.SuccessCloudIDs) == 0 {
return nil, errors.Errorf("tcloud create cfs storage failed, cloudID: %s, result: %s, rid: %s",
Copy link
Collaborator

Choose a reason for hiding this comment

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

err里不带rid,下同

package cfs

import (
cfs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cfs/v20190719"
Copy link
Collaborator

Choose a reason for hiding this comment

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

导包顺序需要调整下,外部包放最下面

package cfs

import (
cfs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cfs/v20190719"
Copy link
Collaborator

Choose a reason for hiding this comment

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

导包顺序调整


import (
"fmt"
"github.com/pkg/errors"
Copy link
Collaborator

Choose a reason for hiding this comment

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

包顺序

sql := fmt.Sprintf(`INSERT INTO %s (%s) VALUES(%s)`, table.CfsTable, tablecfs.TableColumns.ColumnExpr(),
tablecfs.TableColumns.ColonNameExpr())

//logs.Infof("sql: %s, rid: %s", sql, kt.Rid) // note: debug log
Copy link
Collaborator

Choose a reason for hiding this comment

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

需要去掉,下同

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.

4 participants