Skip to content

Commit

Permalink
models: add default quota limits per resource type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidalgarcia committed Oct 20, 2020
1 parent eb76b1f commit 48fcf22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions reana_db/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
"disk": "shared storage",
}
"""Default quota resources to fill Resource table."""

DEFAULT_QUOTA_LIMITS = {
"cpu": int(float(os.getenv("REANA_DEFAULT_QUOTA_CPU_LIMIT", 0))),
"disk": int(float(os.getenv("REANA_DEFAULT_QUOTA_DISK_LIMIT", 0))),
}
"""Default CPU (in milliseconds) and disk (in bytes) quota limits."""
4 changes: 2 additions & 2 deletions reana_db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from sqlalchemy_utils.models import Timestamp
from sqlalchemy_utils.types.encrypted.encrypted_type import AesEngine

from reana_db.config import DB_SECRET_KEY, DEFAULT_QUOTA_RESOURCES
from reana_db.config import DB_SECRET_KEY, DEFAULT_QUOTA_LIMITS, DEFAULT_QUOTA_RESOURCES
from reana_db.utils import (
build_workspace_path,
store_workflow_disk_quota,
Expand Down Expand Up @@ -224,7 +224,7 @@ def initialize_user_quota_limits(self):
UserResource(
user_id=self.id_,
resource_id=resource.id_,
quota_limit=0,
quota_limit=DEFAULT_QUOTA_LIMITS[resource.type_.name],
quota_used=0,
)
)
Expand Down

0 comments on commit 48fcf22

Please sign in to comment.