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" PROVISIONER_VERSION = "0.8.0"
DATA_DIR = "/data" DATA_DIR = "/data"
CONFIG = {} CONFIG = {}
RESOURCE_EXHAUSTED_EXIT_CODE = 101
VOLUME_IN_USE_EXIT_CODE = 102 VOLUME_IN_USE_EXIT_CODE = 102

View File

@ -8,7 +8,6 @@ import rawfile_util
from consts import ( from consts import (
PROVISIONER_VERSION, PROVISIONER_VERSION,
PROVISIONER_NAME, PROVISIONER_NAME,
RESOURCE_EXHAUSTED_EXIT_CODE,
VOLUME_IN_USE_EXIT_CODE, VOLUME_IN_USE_EXIT_CODE,
) )
from csi import csi_pb2, csi_pb2_grpc 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?" grpc.StatusCode.INVALID_ARGUMENT, "Topology key not found... why?"
) )
try:
init_rawfile(volume_id=request.name, size=size), 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
return csi_pb2.CreateVolumeResponse( return csi_pb2.CreateVolumeResponse(
volume=csi_pb2.Volume( volume=csi_pb2.Volume(
@ -234,17 +225,9 @@ class RawFileControllerServicer(csi_pb2_grpc.ControllerServicer):
node_name = volume_to_node(volume_id) node_name = volume_to_node(volume_id)
size = request.capacity_range.required_bytes size = request.capacity_range.required_bytes
try:
run_on_node( run_on_node(
expand_rawfile.as_cmd(volume_id=volume_id, size=size), node=node_name 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
return csi_pb2.ControllerExpandVolumeResponse( return csi_pb2.ControllerExpandVolumeResponse(
capacity_bytes=size, capacity_bytes=size,

View File

@ -129,8 +129,4 @@ def get_volumes_stats() -> [dict]:
def get_capacity(): def get_capacity():
disk_free_size = path_stats(DATA_DIR)["fs_avail"] return 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

View File

@ -34,7 +34,6 @@ def init_rawfile(volume_id, size):
import rawfile_util import rawfile_util
from volume_schema import LATEST_SCHEMA_VERSION from volume_schema import LATEST_SCHEMA_VERSION
from util import run from util import run
from consts import RESOURCE_EXHAUSTED_EXIT_CODE
img_dir = rawfile_util.img_dir(volume_id) img_dir = rawfile_util.img_dir(volume_id)
img_dir.mkdir(exist_ok=True) img_dir.mkdir(exist_ok=True)
@ -66,7 +65,6 @@ def expand_rawfile(volume_id, size):
import rawfile_util import rawfile_util
from util import run from util import run
from consts import RESOURCE_EXHAUSTED_EXIT_CODE
img_file = rawfile_util.img_file(volume_id) img_file = rawfile_util.img_file(volume_id)
size_inc = size - rawfile_util.metadata(volume_id)["size"] size_inc = size - rawfile_util.metadata(volume_id)["size"]