fix(clustermgr): fix chunk report err return

with #23020436

Signed-off-by: tangdeyi <tangdeyi@oppo.com>
This commit is contained in:
tangdeyi 2025-02-07 10:47:20 +08:00 committed by slasher
parent 1cdfd8f95a
commit c48913bc24
2 changed files with 11 additions and 4 deletions

View File

@ -298,7 +298,7 @@ func (v *VolumeMgr) applyChunkReport(ctx context.Context, chunks *cmapi.ReportCh
}
idx := chunk.Vuid.Index()
err = vol.withLocked(func() error {
err_ := vol.withLocked(func() error {
if int(idx) >= len(vol.vUnits) {
return errors.Newf("report vuid: %d is invalid", chunk.Vuid)
}
@ -337,8 +337,9 @@ func (v *VolumeMgr) applyChunkReport(ctx context.Context, chunks *cmapi.ReportCh
}
return nil
})
if err != nil {
span.Warn("applyChunkReport", err)
if err_ != nil {
span.Warn("applyChunkReport", err_)
continue
}
// put on dirty volumes and flush asynchronously

View File

@ -409,11 +409,17 @@ func TestVolumeMgr_applyChunkReport(t *testing.T) {
require.Equal(t, unit.vuInfo.Free, uint64(1024*1024))
}
// invalid vuid case
// invalid vuid case: several chunks
args[1].Vuid = proto.EncodeVuid(proto.EncodeVuidPrefix(44, 2), 1)
args[2].Vuid = proto.EncodeVuid(proto.EncodeVuidPrefix(2, 200), 1)
err = mockVolumeMgr.applyChunkReport(context.Background(), &clustermgr.ReportChunkArgs{ChunkInfos: args})
require.NoError(t, err)
// invalid vuid case: one chunk
args = args[:1]
args[0].Vuid = proto.EncodeVuid(proto.EncodeVuidPrefix(2, 200), 1)
err = mockVolumeMgr.applyChunkReport(context.Background(), &clustermgr.ReportChunkArgs{ChunkInfos: args})
require.NoError(t, err)
}
func TestVolumeMgr_applyChunkReportWithVolumeOverbought(t *testing.T) {