Skip to content

Commit

Permalink
rest: add max inactivity period for interactive sessions to info endp…
Browse files Browse the repository at this point in the history
…oint

Adds the `maximum_interactive_session_inactivity_period` value to the ones returned by `/api/info`.

Closes reanahub/reana-client#657
  • Loading branch information
giuseppe-steduto committed Jun 9, 2023
1 parent f3bc632 commit cdd9b48
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changes
Version 0.9.1 (UNRELEASED)
--------------------------

- Changes OpenAPI specification with respect to return the maximum inactivity time before automatic closure of interactive sessions in ``info`` endpoint.
- Adds the content of the ``REANA_GITLAB_HOST`` environment variable to the list of GitLab instances from which it is possible to launch a workflow.
- Adds new ``prune_workspace`` endpoint to allow users to delete all the files of a workflow, specifying whether to also delete the inputs and/or the outputs.
- Adds ``interactive-session-cleanup`` command that can be used by REANA administrators to close interactive sessions that are inactive for more than the specified number of days.
Expand Down
11 changes: 11 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,17 @@
},
"type": "object"
},
"maximum_interactive_session_inactivity_period": {
"properties": {
"title": {
"type": "string"
},
"value": {
"type": "string"
}
},
"type": "object"
},
"maximum_kubernetes_jobs_timeout": {
"properties": {
"title": {
Expand Down
16 changes: 14 additions & 2 deletions reana_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def _(x):
APP_DEFAULT_SECURE_HEADERS["content_security_policy"] = {}
APP_HEALTH_BLUEPRINT_ENABLED = False


# Rate limiting configuration using invenio-app
# ===========================

Expand Down Expand Up @@ -328,12 +329,10 @@ def _get_rate_limit(env_variable: str, default: str) -> str:
REANA_GITLAB_HOST = os.getenv("REANA_GITLAB_HOST", None)
REANA_GITLAB_URL = "https://{}".format((REANA_GITLAB_HOST or "CHANGE ME"))


# Email configuration
# ===================
ADMIN_EMAIL = os.getenv("REANA_EMAIL_SENDER", "CHANGE_ME")


# Workflow scheduler
# ==================
REANA_SCHEDULER_REQUEUE_SLEEP = float(os.getenv("REANA_SCHEDULER_REQUEUE_SLEEP", "15"))
Expand Down Expand Up @@ -389,6 +388,19 @@ def _get_rate_limit(env_variable: str, default: str) -> str:
DEFAULT_WORKSPACE_RETENTION_RULE = "**/*"
"""Workspace retention rule which will be applied to all the workflows by default."""

# Interactive sessions configuration
# ==================
_reana_session_max_inactivity_period_env = os.getenv(
"REANA_SESSION_MAX_INACTIVITY_PERIOD", "forever"
)
if _reana_session_max_inactivity_period_env == "forever":
REANA_SESSION_MAX_INACTIVITY_PERIOD: Optional[str] = None
else:
REANA_SESSION_MAX_INACTIVITY_PERIOD: Optional[
str
] = _reana_session_max_inactivity_period_env
"""Maximum allowed period (in days) for interactive session inactivity before automatic closure."""

# Kubernetes jobs timeout
# ==================
REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT = os.getenv("REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT")
Expand Down
6 changes: 6 additions & 0 deletions reana_server/rest/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
REANA_KUBERNETES_JOBS_MEMORY_LIMIT,
REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT,
REANA_KUBERNETES_JOBS_MAX_USER_TIMEOUT_LIMIT,
REANA_SESSION_MAX_INACTIVITY_PERIOD,
)
from reana_server.decorators import signin_required

Expand Down Expand Up @@ -140,6 +141,10 @@ def info(user, **kwargs): # noqa
title="Maximum timeout for Kubernetes jobs",
value=REANA_KUBERNETES_JOBS_MAX_USER_TIMEOUT_LIMIT,
),
maximum_interactive_session_inactivity_period=dict(
title="Maximum inactivity period in days before automatic closure of interactive sessions",
value=REANA_SESSION_MAX_INACTIVITY_PERIOD,
),
)
return InfoSchema().dump(cluster_information)

Expand Down Expand Up @@ -180,3 +185,4 @@ class InfoSchema(Schema):
maximum_workspace_retention_period = fields.Nested(StringNullableInfoValue)
default_kubernetes_jobs_timeout = fields.Nested(StringInfoValue)
maximum_kubernetes_jobs_timeout = fields.Nested(StringInfoValue)
maximum_interactive_session_inactivity_period = fields.Nested(StringInfoValue)

0 comments on commit cdd9b48

Please sign in to comment.