Repository: bentoml/BentoML

Issue:
Cannot delete bento that was created with same name:version as an older (deleted) bento
**Describe the bug**
After deleting a bento, I cannot delete another bento that was created with that same name:version.

**To Reproduce**
1. Create a bento with `name:1` through `model_service.save(version='1')`.
2. In a shell, `bentoml delete name:1`
3. Create a new bento with the same name, again with  `model_service.save(version='1')`.
4. Try to `bentoml delete name:1`

The error is the following:
```
Are you sure about delete name:1? This will delete the BentoService saved bundle files permanently [y/N]: y                                                                                                                                            
[2020-10-27 15:22:33,477] ERROR - RPC ERROR DangerouslyDeleteBento: Multiple rows were found for one()                                                                                                                                                    
Error: bentoml-cli delete failed: INTERNAL:Multiple rows were found for one() 
```
**Expected behavior**
I can endlessly delete and recreate bentos with the same name/version for testing.

**Environment:**
 - OS: Ubuntu 20.04
 - Python 3.8.5
 - BentoML Version 0.9.2



Discussion:
Thanks @timlod 

I found the issue and will submit a PR to fix this.

Resolving patch:
diff --git a/bentoml/yatai/repository/metadata_store.py b/bentoml/yatai/repository/metadata_store.py
--- a/bentoml/yatai/repository/metadata_store.py
+++ b/bentoml/yatai/repository/metadata_store.py
@@ -156,7 +156,7 @@ def get(self, bento_name, bento_version="latest"):
             try:
                 bento_obj = (
                     sess.query(Bento)
-                    .filter_by(name=bento_name, version=bento_version)
+                    .filter_by(name=bento_name, version=bento_version, deleted=False)
                     .one()
                 )
                 if bento_obj.deleted:
@@ -215,7 +215,7 @@ def dangerously_delete(self, bento_name, bento_version):
             try:
                 bento_obj = (
                     sess.query(Bento)
-                    .filter_by(name=bento_name, version=bento_version)
+                    .filter_by(name=bento_name, version=bento_version, deleted=False)
                     .one()
                 )
                 if bento_obj.deleted:


Test patch:
diff --git a/tests/yatai/client/test_bento_repository_api.py b/tests/yatai/client/test_bento_repository_api.py
--- a/tests/yatai/client/test_bento_repository_api.py
+++ b/tests/yatai/client/test_bento_repository_api.py
@@ -1,8 +1,14 @@
+import uuid
+import logging
+
 import pytest
 
 from bentoml.exceptions import InvalidArgument
+from bentoml.yatai.client import YataiClient
 from bentoml.yatai.label_store import _validate_labels
 
+logger = logging.getLogger('bentoml.test')
+
 
 def test_validate_labels_fails():
     with pytest.raises(InvalidArgument):
@@ -25,3 +31,17 @@ def test_validate_labels_pass():
     _validate_labels({'long_key_title': 'some_value', 'another_key': "value"})
     _validate_labels({'long_key-title': 'some_value-inside.this'})
     _validate_labels({'create_by': 'admin', 'py.version': '3.6.8'})
+
+
+def test_dangerously_delete(example_bento_service_class):
+    yc = YataiClient()
+    svc = example_bento_service_class()
+    version = f"test_{uuid.uuid4().hex}"
+    svc.set_version(version_str=version)
+    svc.save()
+    result = yc.repository.dangerously_delete_bento(svc.name, svc.version)
+    assert result.status.status_code == 0
+    logger.debug('Saving the bento service again with the same name:version')
+    svc.save()
+    second_delete_result = yc.repository.dangerously_delete_bento(svc.name, svc.version)
+    assert second_delete_result.status.status_code == 0