diff --git a/consts.py b/consts.py index b34e658..9509ed1 100644 --- a/consts.py +++ b/consts.py @@ -4,5 +4,4 @@ PROVISIONER_NAME = os.getenv("PROVISIONER_NAME", "rawfile.csi.openebs.io") PROVISIONER_VERSION = "0.8.0" DATA_DIR = "/data" CONFIG = {} -RESOURCE_EXHAUSTED_EXIT_CODE = 101 VOLUME_IN_USE_EXIT_CODE = 102 diff --git a/rawfile_servicer.py b/rawfile_servicer.py index 3823cdc..f4037e7 100644 --- a/rawfile_servicer.py +++ b/rawfile_servicer.py @@ -8,7 +8,6 @@ import rawfile_util from consts import ( PROVISIONER_VERSION, PROVISIONER_NAME, - RESOURCE_EXHAUSTED_EXIT_CODE, VOLUME_IN_USE_EXIT_CODE, ) from csi import csi_pb2, csi_pb2_grpc @@ -192,15 +191,7 @@ class RawFileControllerServicer(csi_pb2_grpc.ControllerServicer): grpc.StatusCode.INVALID_ARGUMENT, "Topology key not found... why?" ) - try: - init_rawfile(volume_id=request.name, size=size), - except CalledProcessError as exc: - if exc.returncode == RESOURCE_EXHAUSTED_EXIT_CODE: - context.abort( - grpc.StatusCode.RESOURCE_EXHAUSTED, "Not enough disk space" - ) - else: - raise exc + init_rawfile(volume_id=request.name, size=size), return csi_pb2.CreateVolumeResponse( volume=csi_pb2.Volume( @@ -234,17 +225,9 @@ class RawFileControllerServicer(csi_pb2_grpc.ControllerServicer): node_name = volume_to_node(volume_id) size = request.capacity_range.required_bytes - try: - run_on_node( - expand_rawfile.as_cmd(volume_id=volume_id, size=size), node=node_name - ) - except CalledProcessError as exc: - if exc.returncode == RESOURCE_EXHAUSTED_EXIT_CODE: - context.abort( - grpc.StatusCode.RESOURCE_EXHAUSTED, "Not enough disk space" - ) - else: - raise exc + run_on_node( + expand_rawfile.as_cmd(volume_id=volume_id, size=size), node=node_name + ) return csi_pb2.ControllerExpandVolumeResponse( capacity_bytes=size, diff --git a/rawfile_util.py b/rawfile_util.py index c4aa5cc..dab4f31 100644 --- a/rawfile_util.py +++ b/rawfile_util.py @@ -129,8 +129,4 @@ def get_volumes_stats() -> [dict]: def get_capacity(): - disk_free_size = path_stats(DATA_DIR)["fs_avail"] - capacity = disk_free_size - for volume_stat in get_volumes_stats().values(): - capacity -= volume_stat["total"] - volume_stat["used"] - return capacity + return path_stats(DATA_DIR)["fs_avail"] diff --git a/remote.py b/remote.py index 20499b0..66ede9c 100644 --- a/remote.py +++ b/remote.py @@ -34,7 +34,6 @@ def init_rawfile(volume_id, size): import rawfile_util from volume_schema import LATEST_SCHEMA_VERSION from util import run - from consts import RESOURCE_EXHAUSTED_EXIT_CODE img_dir = rawfile_util.img_dir(volume_id) img_dir.mkdir(exist_ok=True) @@ -66,7 +65,6 @@ def expand_rawfile(volume_id, size): import rawfile_util from util import run - from consts import RESOURCE_EXHAUSTED_EXIT_CODE img_file = rawfile_util.img_file(volume_id) size_inc = size - rawfile_util.metadata(volume_id)["size"]