Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ESAP DB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
ESCAPE WP5
ESAP DB
Commits
51e5b6c6
Commit
51e5b6c6
authored
3 years ago
by
Pierre Chanial
Browse files
Options
Downloads
Patches
Plain Diff
Raise error inside helper _find_best_project_server.
parent
555711fe
No related branches found
Branches containing commit
No related tags found
1 merge request
!9
Resolve "API to get a project"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/apis/v0/projects.py
+9
-10
9 additions, 10 deletions
app/apis/v0/projects.py
with
9 additions
and
10 deletions
app/apis/v0/projects.py
+
9
−
10
View file @
51e5b6c6
"""
Definitions of the endpoints related the projects.
"""
import
logging
from
typing
import
Any
,
Optional
from
typing
import
Any
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
status
from
sqlalchemy
import
create_engine
,
text
,
update
...
...
@@ -38,11 +38,6 @@ def create_project(
)
server
=
_find_best_project_server
(
session
,
project
)
if
server
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_507_INSUFFICIENT_STORAGE
,
detail
=
'
No database has enough storage for this project.
'
,
)
# preempt the required storage
_update_server_available_size
(
session
,
server
,
-
project
.
max_size
)
...
...
@@ -80,13 +75,17 @@ def create_project(
return
db_project
def
_find_best_project_server
(
session
:
Session
,
project
:
Project
)
->
Optional
[
DBProjectServer
]:
def
_find_best_project_server
(
session
:
Session
,
project
:
Project
)
->
DBProjectServer
:
stmt
=
select
(
DBProjectServer
).
where
(
DBProjectServer
.
available_size
>=
project
.
max_size
)
return
session
.
execute
(
stmt
).
scalars
().
first
()
server
=
session
.
execute
(
stmt
).
scalars
().
first
()
if
server
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_507_INSUFFICIENT_STORAGE
,
detail
=
'
No database has enough storage for this project.
'
,
)
return
server
def
_update_server_available_size
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment