From 19cc28ddea6ae4d856938f400a2f1f70f197c9fe Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 19 Mar 2020 13:30:59 +0100 Subject: [PATCH] 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 --- pkg/util/cephcmds.go | 5 +++++ pkg/util/voljournal.go | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/util/cephcmds.go b/pkg/util/cephcmds.go index 387bbf3f7..f6704e66f 100644 --- a/pkg/util/cephcmds.go +++ b/pkg/util/cephcmds.go @@ -182,6 +182,11 @@ func GetOMapValue(ctx context.Context, monitors string, cr *Credentials, poolNam 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 klog.Errorf(Log(ctx, "failed getting omap value for key (%s) from omap (%s) in pool (%s): (%v)"), oMapKey, oMapName, poolName, err) diff --git a/pkg/util/voljournal.go b/pkg/util/voljournal.go index c1f6735ac..5aa6e1eb3 100644 --- a/pkg/util/voljournal.go +++ b/pkg/util/voljournal.go @@ -215,7 +215,8 @@ func (cj *CSIJournal) CheckReservation(ctx context.Context, monitors string, cr if err != nil { // error should specifically be not found, for volume to be absent, any other error // is not conclusive, and we should not proceed - if _, ok := err.(ErrKeyNotFound); ok { + switch err.(type) { + case ErrKeyNotFound, ErrPoolNotFound: return "", nil } return "", err @@ -453,8 +454,10 @@ func (cj *CSIJournal) GetObjectUUIDData(ctx context.Context, monitors string, cr if err != nil { // if the key was not found, assume the default key + UUID // otherwise return error - if _, ok := err.(ErrKeyNotFound); !ok { + switch err.(type) { + default: return "", "", "", "", err + case ErrKeyNotFound, ErrPoolNotFound: } 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, cj.cephUUIDDirectoryPrefix+objectUUID, cj.encryptKMSKey) 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", pool, cj.cephUUIDDirectoryPrefix+objectUUID, err) + case ErrKeyNotFound, ErrPoolNotFound: } - // ErrKeyNotFound means no encryption KMS was used } if snapSource {