mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #14372 from ioito/hotfix/qx-tag-lock
fix(region): 避免加锁导致设置标签超时
This commit is contained in:
@@ -22,8 +22,6 @@ import (
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -40,11 +38,6 @@ func (t TagsUpdateInfo) IsChanged() bool {
|
||||
}
|
||||
|
||||
func SetTags(ctx context.Context, res ICloudResource, managerId string, tags map[string]string, replace bool) error {
|
||||
// 避免同时设置多个资源标签出现以下错误
|
||||
// Code=ResourceInUse.TagDuplicate, Message=tagKey-tagValue have exists., RequestId=e87714c0-e50b-4241-b79d-32897437174d
|
||||
lockman.LockRawObject(ctx, SET_TAGS, managerId)
|
||||
defer lockman.ReleaseRawObject(ctx, SET_TAGS, managerId)
|
||||
|
||||
err := res.SetTags(tags, replace)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "SetTags")
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
sdkerrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
@@ -183,6 +184,9 @@ func (region *SRegion) createTag(key, value string) error {
|
||||
apiName := "CreateTag"
|
||||
_, err := region.client.tagRequest(apiName, params)
|
||||
if err != nil {
|
||||
if e, ok := errors.Cause(err).(*sdkerrors.TencentCloudSDKError); ok && e.Code == "ResourceInUse.TagDuplicate" {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, apiName)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user