pyocf: fix error handling in Cache::stop()

Write error in cache stop means the instance was in fact stopped.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-12-20 15:25:38 +01:00
parent ed5185e870
commit 7f60aa0dd6
2 changed files with 6 additions and 1 deletions

View File

@ -700,7 +700,8 @@ class Cache:
self.owner.lib.ocf_mngt_cache_stop(self.cache_handle, c, None)
c.wait()
if c.results["error"]:
err = OcfErrorCode(-1 * c.results["error"])
if err != OcfErrorCode.OCF_OK and err != OcfErrorCode.OCF_ERR_WRITE_CACHE:
self.write_unlock()
raise OcfError("Failed stopping cache", c.results["error"])
@ -712,6 +713,9 @@ class Cache:
self.owner.caches.remove(self)
if err != OcfErrorCode.OCF_OK:
raise OcfError("Failed stopping cache", c.results["error"])
def flush(self):
self.write_lock()

View File

@ -12,6 +12,7 @@ from ..utils import Size as S
class OcfErrorCode(IntEnum):
OCF_OK = 0
OCF_ERR_INVAL = 1000000
OCF_ERR_AGAIN = auto()
OCF_ERR_INTR = auto()