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

rest: add max inactivity period for interactive sessions to info endpoint #599

Merged
Merged
Show file tree
Hide file tree
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
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
12 changes: 12 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@
},
"type": "object"
},
"maximum_interactive_session_inactivity_period": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you modified the OpenAPI specification you have to call the generate_openapi_spec.py script to publish these changes to reana-commons (and create another PR there)

"properties": {
"title": {
"type": "string"
},
"value": {
"type": "string",
"x-nullable": true
}
},
"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_interactive_session_max_inactivity_period_env = os.getenv(
"REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD", "forever"
)
if _reana_interactive_session_max_inactivity_period_env == "forever":
REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD: Optional[str] = None
else:
REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD: Optional[
str
] = _reana_interactive_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
8 changes: 8 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_INTERACTIVE_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_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD,
),
)
return InfoSchema().dump(cluster_information)

Expand Down Expand Up @@ -180,3 +185,6 @@ 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(
StringNullableInfoValue
)