mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rbd: fixed all potential crashing when decoding volume ID failed
Signed-off-by: HF <crazytaxii666@gmail.com>
This commit is contained in:
parent
97df4e79c6
commit
5411a69839
@ -243,7 +243,11 @@ func (rs *ReplicationServer) EnableVolumeReplication(ctx context.Context,
|
|||||||
defer rs.VolumeLocks.Release(volumeID)
|
defer rs.VolumeLocks.Release(volumeID)
|
||||||
|
|
||||||
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
||||||
defer rbdVol.Destroy()
|
defer func() {
|
||||||
|
if rbdVol != nil {
|
||||||
|
rbdVol.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, corerbd.ErrImageNotFound):
|
case errors.Is(err, corerbd.ErrImageNotFound):
|
||||||
@ -305,7 +309,11 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context,
|
|||||||
defer rs.VolumeLocks.Release(volumeID)
|
defer rs.VolumeLocks.Release(volumeID)
|
||||||
|
|
||||||
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
||||||
defer rbdVol.Destroy()
|
defer func() {
|
||||||
|
if rbdVol != nil {
|
||||||
|
rbdVol.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, corerbd.ErrImageNotFound):
|
case errors.Is(err, corerbd.ErrImageNotFound):
|
||||||
@ -376,7 +384,11 @@ func (rs *ReplicationServer) PromoteVolume(ctx context.Context,
|
|||||||
defer rs.VolumeLocks.Release(volumeID)
|
defer rs.VolumeLocks.Release(volumeID)
|
||||||
|
|
||||||
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
||||||
defer rbdVol.Destroy()
|
defer func() {
|
||||||
|
if rbdVol != nil {
|
||||||
|
rbdVol.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, corerbd.ErrImageNotFound):
|
case errors.Is(err, corerbd.ErrImageNotFound):
|
||||||
@ -472,7 +484,11 @@ func (rs *ReplicationServer) DemoteVolume(ctx context.Context,
|
|||||||
defer rs.VolumeLocks.Release(volumeID)
|
defer rs.VolumeLocks.Release(volumeID)
|
||||||
|
|
||||||
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
||||||
defer rbdVol.Destroy()
|
defer func() {
|
||||||
|
if rbdVol != nil {
|
||||||
|
rbdVol.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, corerbd.ErrImageNotFound):
|
case errors.Is(err, corerbd.ErrImageNotFound):
|
||||||
@ -585,7 +601,11 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
|
|||||||
}
|
}
|
||||||
defer rs.VolumeLocks.Release(volumeID)
|
defer rs.VolumeLocks.Release(volumeID)
|
||||||
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
||||||
defer rbdVol.Destroy()
|
defer func() {
|
||||||
|
if rbdVol != nil {
|
||||||
|
rbdVol.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, corerbd.ErrImageNotFound):
|
case errors.Is(err, corerbd.ErrImageNotFound):
|
||||||
@ -798,7 +818,11 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(ctx context.Context,
|
|||||||
}
|
}
|
||||||
defer rs.VolumeLocks.Release(volumeID)
|
defer rs.VolumeLocks.Release(volumeID)
|
||||||
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
rbdVol, err := corerbd.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
||||||
defer rbdVol.Destroy()
|
defer func() {
|
||||||
|
if rbdVol != nil {
|
||||||
|
rbdVol.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, corerbd.ErrImageNotFound):
|
case errors.Is(err, corerbd.ErrImageNotFound):
|
||||||
|
@ -1082,7 +1082,11 @@ func (cs *ControllerServer) CreateSnapshot(
|
|||||||
|
|
||||||
// Fetch source volume information
|
// Fetch source volume information
|
||||||
rbdVol, err := GenVolFromVolID(ctx, req.GetSourceVolumeId(), cr, req.GetSecrets())
|
rbdVol, err := GenVolFromVolID(ctx, req.GetSourceVolumeId(), cr, req.GetSecrets())
|
||||||
defer rbdVol.Destroy()
|
defer func() {
|
||||||
|
if rbdVol != nil {
|
||||||
|
rbdVol.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, ErrImageNotFound):
|
case errors.Is(err, ErrImageNotFound):
|
||||||
|
Loading…
Reference in New Issue
Block a user