-
Notifications
You must be signed in to change notification settings - Fork 44
feat: 对接腾讯云cfs --story=127069191 #1737
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: huiwenzhang <huiwenzhang@tencent.com>
Signed-off-by: huiwenzhang <1458070668@qq.com>
4dbc341 to
269bb7a
Compare
Signed-off-by: Super-zhw <1458070668@qq.com>
Signed-off-by: Super-zhw <1458070668@qq.com>
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) | ||
| } | ||
|
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) | ||
| } |
There was a problem hiding this comment.
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: 暂时不验证权限 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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) | ||
| } | ||
|
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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, | ||
| // |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有一个的话,直接用tools.EqualExpression就好了
| } | ||
| } | ||
|
|
||
| // 数据同步 |
There was a problem hiding this comment.
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) | ||
| } | ||
| //// 云上资源查询 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要去掉,下同
No description provided.