Load-import failed due to lack of space in /scratch

During a load-import operation, the iso file is copied to /scratch,
a temporary folder (https://docs.starlingx.io/planning/kubernetes/storage-planning-storage-on-worker-hosts.html#root-filesystem-storage).
Before the operation, it is checked if this folder has a free space of
at least 3 times the ISO file, if not the load-import is aborted.

This change enhances the message displayed to the user in order to
give him some context and two solutions:
  - Delete some unused files from /scratch
  - Increase /scratch size

Test Plan:
  PASS: After adding more free space to /scratch, the load-import
operation must pass without error

Related to: https://review.opendev.org/c/starlingx/config/+/899865
Partial-bug: 2031941

Change-Id: Iff99e8793ab6fa5c812648bba4d93e8eab22a6b5
Signed-off-by: Lindley Werner <Lindley.Vieira@windriver.com>
This commit is contained in:
Lindley Werner 2023-10-06 11:39:18 -03:00 committed by Lindley Werner Soares Vieira
parent a1a3f93085
commit 37d93277d5
2 changed files with 11 additions and 6 deletions

View File

@ -585,9 +585,9 @@ class SysinvAPIController(APIController):
os.path.basename(src_filepath))
shutil.copyfile(src_filepath, load_file_path)
LOG.info("copied %s to %s" % (src_filepath, load_file_path))
except Exception:
except Exception as e:
msg = _("Failed to store load in vault. Please check "
"dcorch log for details.")
"dcorch log for more details: %s" % e)
raise webob.exc.HTTPInsufficientStorage(explanation=msg)
return load_file_path
@ -714,8 +714,8 @@ class SysinvAPIController(APIController):
error = False
except webob.exc.HTTPInternalServerError:
raise
except Exception:
msg = _("Unexpected error copying load to vault")
except Exception as e:
msg = _("Unexpected error copying load to vault: %s" % e)
raise webob.exc.HTTPInternalServerError(explanation=msg)
finally:
if error and os.path.exists(proxy_consts.LOAD_FILES_STAGING_DIR):

View File

@ -74,8 +74,13 @@ class ApiFiller(Middleware):
# 1 time on internal temporary copy to be shared with sysinv
if not utils.is_space_available("/scratch",
3 * req.content_length):
msg = _("Insufficient space on /scratch for request %s"
% req.path)
msg = _(
"Insufficient space on /scratch for request %s, "
"/scratch must have at least %d bytes of free space. "
"You can delete unused files from /scratch or increase the size of it "
"with: 'system host-fs-modify <hostname> scratch=<new_size_in_GiB>'"
) % (req.path, 3 * req.content_length)
raise webob.exc.HTTPInternalServerError(explanation=msg)
if ('HTTP_USER_HEADER' in req.environ and