Deprecate disk exhausted errors
Some checks reported errors
continuous-integration/drone Build was killed

This commit is contained in:
Lauri Võsandi 2023-01-21 13:12:03 +02:00
parent 1a005c89e2
commit 9c4cda7c0a
4 changed files with 5 additions and 29 deletions

View File

@ -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

View File

@ -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,

View File

@ -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"]

View File

@ -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"]