cleanup: add a helper function storeImageID

added a helper function storeImageID to reduce
code duplication.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2020-12-04 14:06:05 +05:30
committed by mergify[bot]
parent b2fb43b335
commit 43fde0a30a
3 changed files with 19 additions and 29 deletions

View File

@ -494,15 +494,8 @@ func (cs *ControllerServer) createBackingImage(ctx context.Context, cr *util.Cre
}
}
}()
err = rbdVol.getImageID()
err = rbdVol.storeImageID(ctx, j)
if err != nil {
util.ErrorLog(ctx, "failed to get volume id %s: %v", rbdVol, err)
return status.Error(codes.Internal, err.Error())
}
err = j.StoreImageID(ctx, rbdVol.JournalPool, rbdVol.ReservedID, rbdVol.ImageID)
if err != nil {
util.ErrorLog(ctx, "failed to reserve volume %s: %v", rbdVol, err)
return status.Error(codes.Internal, err.Error())
}