Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csi: Allow over-provisioning for external volume #1041

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions csi/controllerserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,10 @@ def CreateVolume(self, request, context):

if not is_hosting_volume_free(ext_volume['name'], pvsize):

logging.error(logf(
"Hosting volume is full. Add more storage",
logging.info(logf(
"Hosting volume is full...Over-provisioning!",
volume=ext_volume['name']
))
errmsg = "External resource is exhausted"
context.set_details(errmsg)
context.set_code(grpc.StatusCode.RESOURCE_EXHAUSTED)
return csi_pb2.CreateVolumeResponse()

if pvtype in [PV_TYPE_VIRTBLOCK, PV_TYPE_RAWBLOCK]:
vol = create_block_volume(
Expand Down Expand Up @@ -303,6 +299,8 @@ def CreateVolume(self, request, context):
duration_seconds=time.time() - start_time
))

update_free_size(ext_volume['name'], request.name, -pvsize)

send_analytics_tracker("pvc-external-kadalu", uid)
# Pass required argument to get mount working on
# nodeplugin through volume_context
Expand Down Expand Up @@ -645,19 +643,25 @@ def ControllerExpandVolume(self, request, context):
mntdir = os.path.join(HOSTVOL_MOUNTDIR, hostvol)
use_gluster_quota = False

hostvoltype = existing_volume.extra['hostvoltype']

# Check free-size in storage-pool before expansion
# For external volume we allow over-provisioning
if not is_hosting_volume_free(hostvol, additional_pvsize_required):

logging.error(logf(
"Hosting volume is full. Add more storage",
volume=hostvol
))
errmsg = "Host volume resource is exhausted"
context.set_details(errmsg)
context.set_code(grpc.StatusCode.RESOURCE_EXHAUSTED)
return csi_pb2.CreateVolumeResponse()

hostvoltype = existing_volume.extra['hostvoltype']
if hostvoltype != 'External':
logging.error(logf(
"Hosting volume is full. Add more storage",
volume=hostvol
))
errmsg = "Host volume resource is exhausted"
context.set_details(errmsg)
context.set_code(grpc.StatusCode.RESOURCE_EXHAUSTED)
return csi_pb2.CreateVolumeResponse()
else:
logging.info(logf(
"Hosting volume is full...Over-provisioning!",
volume=hostvol
))

if pvtype == PV_TYPE_SUBVOL:
update_subdir_volume(
Expand Down