util/cephcmds: have GetOMapValue() return ErrPoolNotFound

On occasion the e2e tests fail as there is an unexpected error while
deleting an RBD image. The particular tests forcefully removes the pool
where the RBD image is stored. Deleting a volume that has been removed
already (or when its parent pool has been wiped), should succeed.

By catching the error that a pool does not exist (anymore), the
provisioner responds to the DeleteVolume request with succes.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-03-19 13:30:59 +01:00 committed by mergify[bot]
parent 02367c4a3f
commit 19cc28ddea
2 changed files with 14 additions and 4 deletions

View File

@ -182,6 +182,11 @@ func GetOMapValue(ctx context.Context, monitors string, cr *Credentials, poolNam
return "", ErrKeyNotFound{poolName + "/" + oMapName + "/" + oMapKey, err} return "", ErrKeyNotFound{poolName + "/" + oMapName + "/" + oMapKey, err}
} }
if strings.Contains(stdoutanderr, "error opening pool "+
poolName+": (2) No such file or directory") {
return "", ErrPoolNotFound{poolName, err}
}
// log other errors for troubleshooting assistance // log other errors for troubleshooting assistance
klog.Errorf(Log(ctx, "failed getting omap value for key (%s) from omap (%s) in pool (%s): (%v)"), klog.Errorf(Log(ctx, "failed getting omap value for key (%s) from omap (%s) in pool (%s): (%v)"),
oMapKey, oMapName, poolName, err) oMapKey, oMapName, poolName, err)

View File

@ -215,7 +215,8 @@ func (cj *CSIJournal) CheckReservation(ctx context.Context, monitors string, cr
if err != nil { if err != nil {
// error should specifically be not found, for volume to be absent, any other error // error should specifically be not found, for volume to be absent, any other error
// is not conclusive, and we should not proceed // is not conclusive, and we should not proceed
if _, ok := err.(ErrKeyNotFound); ok { switch err.(type) {
case ErrKeyNotFound, ErrPoolNotFound:
return "", nil return "", nil
} }
return "", err return "", err
@ -453,8 +454,10 @@ func (cj *CSIJournal) GetObjectUUIDData(ctx context.Context, monitors string, cr
if err != nil { if err != nil {
// if the key was not found, assume the default key + UUID // if the key was not found, assume the default key + UUID
// otherwise return error // otherwise return error
if _, ok := err.(ErrKeyNotFound); !ok { switch err.(type) {
default:
return "", "", "", "", err return "", "", "", "", err
case ErrKeyNotFound, ErrPoolNotFound:
} }
if snapSource { if snapSource {
@ -468,11 +471,13 @@ func (cj *CSIJournal) GetObjectUUIDData(ctx context.Context, monitors string, cr
encryptionKmsConfig, err = GetOMapValue(ctx, monitors, cr, pool, cj.namespace, encryptionKmsConfig, err = GetOMapValue(ctx, monitors, cr, pool, cj.namespace,
cj.cephUUIDDirectoryPrefix+objectUUID, cj.encryptKMSKey) cj.cephUUIDDirectoryPrefix+objectUUID, cj.encryptKMSKey)
if err != nil { if err != nil {
if _, ok := err.(ErrKeyNotFound); !ok { // ErrKeyNotFound means no encryption KMS was used
switch err.(type) {
default:
return "", "", "", "", fmt.Errorf("OMapVal for %s/%s failed to get encryption KMS value: %s", return "", "", "", "", fmt.Errorf("OMapVal for %s/%s failed to get encryption KMS value: %s",
pool, cj.cephUUIDDirectoryPrefix+objectUUID, err) pool, cj.cephUUIDDirectoryPrefix+objectUUID, err)
case ErrKeyNotFound, ErrPoolNotFound:
} }
// ErrKeyNotFound means no encryption KMS was used
} }
if snapSource { if snapSource {