mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
perf(scheduler): update volume cache failed error replace with error code
@formatter:off Signed-off-by: JasonHu520 <huzongchao@oppo.com>
This commit is contained in:
parent
d3575df4d4
commit
2d90e0f96e
@ -91,7 +91,8 @@ var errCodeMap = map[int]string{
|
||||
CodeCMNodeSetNotFound: "nodeset not found",
|
||||
|
||||
// scheduler
|
||||
CodeNotingTodo: "nothing to do",
|
||||
CodeNotingTodo: "nothing to do",
|
||||
CodeUpdateVolCacheFreq: "update volume cache frequently",
|
||||
|
||||
// proxy
|
||||
CodeNoAvaliableVolume: "this codemode has no avaliable volume",
|
||||
|
||||
@ -19,7 +19,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
CodeNotingTodo = 700
|
||||
CodeNotingTodo = 700
|
||||
CodeUpdateVolCacheFreq = 701
|
||||
)
|
||||
|
||||
var (
|
||||
@ -29,5 +30,6 @@ var (
|
||||
ErrIllegalDiskID = errors.New("illegal disk id")
|
||||
|
||||
// error code
|
||||
ErrNothingTodo = Error(CodeNotingTodo)
|
||||
ErrNothingTodo = Error(CodeNotingTodo)
|
||||
ErrUpdateVolCacheFreq = Error(CodeUpdateVolCacheFreq)
|
||||
)
|
||||
|
||||
@ -722,7 +722,7 @@ func TestDeleteBlob(t *testing.T) {
|
||||
mgr.blobnodeCli = blobnodeCli
|
||||
|
||||
clusterTopology := NewMockClusterTopology(ctr)
|
||||
clusterTopology.EXPECT().UpdateVolume(any).Return(volume, ErrFrequentlyUpdate)
|
||||
clusterTopology.EXPECT().UpdateVolume(any).Return(volume, errcode.ErrUpdateVolCacheFreq)
|
||||
mgr.clusterTopology = clusterTopology
|
||||
|
||||
doneVolume, err := mgr.deleteBlob(ctx, volume, &proto.DeleteMsg{Bid: proto.BlobID(1)})
|
||||
|
||||
@ -24,6 +24,7 @@ import (
|
||||
|
||||
"golang.org/x/sync/singleflight"
|
||||
|
||||
cmerrors "github.com/cubefs/cubefs/blobstore/common/errors"
|
||||
"github.com/cubefs/cubefs/blobstore/common/proto"
|
||||
"github.com/cubefs/cubefs/blobstore/common/rpc"
|
||||
"github.com/cubefs/cubefs/blobstore/common/trace"
|
||||
@ -41,9 +42,6 @@ const (
|
||||
defaultCount = 1000
|
||||
)
|
||||
|
||||
// ErrFrequentlyUpdate frequently update
|
||||
var ErrFrequentlyUpdate = errors.New("frequently update")
|
||||
|
||||
var errVolumeMissmatch = errors.New("volume missmatch during running task")
|
||||
|
||||
// IClusterTopology define the interface og cluster topology
|
||||
@ -458,7 +456,7 @@ func (c *VolumeCache) GetVolume(vid proto.Vid) (*client.VolumeInfoSimple, error)
|
||||
// UpdateVolume this volume info cache.
|
||||
func (c *VolumeCache) UpdateVolume(vid proto.Vid) (*client.VolumeInfoSimple, error) {
|
||||
if !c.cache.Settable(vid) {
|
||||
return nil, ErrFrequentlyUpdate
|
||||
return nil, cmerrors.ErrUpdateVolCacheFreq
|
||||
}
|
||||
|
||||
val, err, _ := c.group.Do(fmt.Sprintf("volume-update-%d", vid), func() (interface{}, error) {
|
||||
|
||||
@ -19,12 +19,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
errcode "github.com/cubefs/cubefs/blobstore/common/errors"
|
||||
"github.com/cubefs/cubefs/blobstore/common/proto"
|
||||
"github.com/cubefs/cubefs/blobstore/scheduler/base"
|
||||
"github.com/cubefs/cubefs/blobstore/scheduler/client"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -175,7 +175,7 @@ func TestVolumeCache(t *testing.T) {
|
||||
|
||||
// update ErrFrequentlyUpdate
|
||||
_, err = volCache.UpdateVolume(1)
|
||||
require.ErrorIs(t, err, ErrFrequentlyUpdate)
|
||||
require.ErrorIs(t, err, errcode.ErrUpdateVolCacheFreq)
|
||||
|
||||
// list and get failed
|
||||
cmClient.EXPECT().ListVolume(any, any, any).AnyTimes().Return(nil, proto.Vid(0), errMock)
|
||||
|
||||
@ -297,7 +297,7 @@ func TestTryRepair(t *testing.T) {
|
||||
mgr.blobnodeCli = blobnode
|
||||
|
||||
clusterTopology := NewMockClusterTopology(ctr)
|
||||
clusterTopology.EXPECT().UpdateVolume(any).Return(volume, ErrFrequentlyUpdate)
|
||||
clusterTopology.EXPECT().UpdateVolume(any).Return(volume, errcode.ErrUpdateVolCacheFreq)
|
||||
mgr.clusterTopology = clusterTopology
|
||||
|
||||
doneVolume, err := mgr.tryRepair(ctx, volume, &proto.ShardRepairMsg{Bid: proto.BlobID(1), Vid: proto.Vid(1), BadIdx: []uint8{0}})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user