aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-01-15 16:35:36 -0800
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-01-16 12:26:37 -0800
commitf9d0212e7edbabc554ca539e193b39f0b2cacdd7 (patch)
tree3474b04cd906072b65c54694709630530af22933 /src
parent8db0a40746925ffdd98c6b6718a05e31d17fc755 (diff)
Check if no document is returned before error
Check if no document is returned in SingleResult before throwing any error. Issue-ID: MULTICLOUD-435 Change-Id: I9d92ff325701c04af278ba7c9e2bf5a55fd4d9bd Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/k8splugin/db/mongo.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/k8splugin/db/mongo.go b/src/k8splugin/db/mongo.go
index 311f044c..65e721c3 100644
--- a/src/k8splugin/db/mongo.go
+++ b/src/k8splugin/db/mongo.go
@@ -224,6 +224,11 @@ func (m *MongoStore) Delete(coll, key, tag string) error {
keydata, err := decodeBytes(c.FindOneAndUpdate(ctx, filter, update,
options.FindOneAndUpdate().SetReturnDocument(options.Before)))
if err != nil {
+ //No document was found. Return nil.
+ if err == mongo.ErrNoDocuments {
+ return nil
+ }
+ //Return any other error that was found.
return pkgerrors.Errorf("Error decoding master table after update: %s",
err.Error())
}