-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow workstation editors to launch debug sessions (#2772)
This PR allows workstation editors to set the region and add extra environment variables for a new session. Limitation is that the editor cannot have more than 1 session running to prevent flooding of the server and confusion about env vars being passed, so they may have to wait for a workstation session to finish. Workstation detail view:  The form (with validation):  The env vars being passed:  Note that the env vars editors set here are used as the default environment variables, we will overwrite some keys if editors try to set them (e.g. `GRAND_CHALLENGE_UNSAFE`, `GRAND_CHALLENGE_AUTHORIZATION`, `GRAND_CHALLENGE_API_ROOT`). Editors can only create debug sessions for themselves so should be safe. Also removes `WORKSTATIONS_DNS_RESOLVER` which is no longer used. Old style forms and tests are used for consistency with the rest of the workstations application.
- Loading branch information
Showing
13 changed files
with
343 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
app/grandchallenge/workstations/migrations/0016_auto_20230214_1453.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Generated by Django 3.2.18 on 2023-02-14 14:53 | ||
|
||
from django.db import migrations, models | ||
|
||
import grandchallenge.core.validators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
( | ||
"workstations", | ||
"0015_feedbackgroupobjectpermission_feedbackuserobjectpermission_sessiongroupobjectpermission_sessionusero", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="historicalsession", | ||
name="extra_env_vars", | ||
field=models.JSONField( | ||
blank=True, | ||
default=list, | ||
help_text="Extra environment variables to include in this session", | ||
validators=[ | ||
grandchallenge.core.validators.JSONValidator( | ||
schema={ | ||
"$schema": "http://json-schema.org/draft-06/schema", | ||
"description": "Defines environment variable names and values", | ||
"items": { | ||
"$id": "#/items", | ||
"additionalProperties": False, | ||
"description": "Defines an environment variable", | ||
"properties": { | ||
"name": { | ||
"$id": "#/items/properties/name", | ||
"default": "ENV_VAR", | ||
"description": "The name of this environment variable", | ||
"examples": ["ENV_VAR"], | ||
"pattern": "^[A-Z0-9\\_]+$", | ||
"title": "The Name Schema", | ||
"type": "string", | ||
}, | ||
"value": { | ||
"$id": "#/items/properties/value", | ||
"default": "env_var_value", | ||
"description": "The value of this environment variable", | ||
"examples": ["env_var_value"], | ||
"title": "The Value Schema", | ||
"type": "string", | ||
}, | ||
}, | ||
"required": ["name", "value"], | ||
"title": "The Environment Variable Schema", | ||
"type": "object", | ||
}, | ||
"title": "The Environment Variables Schema", | ||
"type": "array", | ||
} | ||
) | ||
], | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="session", | ||
name="extra_env_vars", | ||
field=models.JSONField( | ||
blank=True, | ||
default=list, | ||
help_text="Extra environment variables to include in this session", | ||
validators=[ | ||
grandchallenge.core.validators.JSONValidator( | ||
schema={ | ||
"$schema": "http://json-schema.org/draft-06/schema", | ||
"description": "Defines environment variable names and values", | ||
"items": { | ||
"$id": "#/items", | ||
"additionalProperties": False, | ||
"description": "Defines an environment variable", | ||
"properties": { | ||
"name": { | ||
"$id": "#/items/properties/name", | ||
"default": "ENV_VAR", | ||
"description": "The name of this environment variable", | ||
"examples": ["ENV_VAR"], | ||
"pattern": "^[A-Z0-9\\_]+$", | ||
"title": "The Name Schema", | ||
"type": "string", | ||
}, | ||
"value": { | ||
"$id": "#/items/properties/value", | ||
"default": "env_var_value", | ||
"description": "The value of this environment variable", | ||
"examples": ["env_var_value"], | ||
"title": "The Value Schema", | ||
"type": "string", | ||
}, | ||
}, | ||
"required": ["name", "value"], | ||
"title": "The Environment Variable Schema", | ||
"type": "object", | ||
}, | ||
"title": "The Environment Variables Schema", | ||
"type": "array", | ||
} | ||
) | ||
], | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/grandchallenge/workstations/templates/workstations/session_debug_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{% extends "base.html" %} | ||
{% load crispy_forms_tags %} | ||
{% load static %} | ||
|
||
{% block title %}Create Debug Session - {{ block.super }}{% endblock %} | ||
|
||
{% block breadcrumbs %} | ||
<ol class="breadcrumb"> | ||
<li class="breadcrumb-item"><a href="{% url 'workstations:list' %}">Viewers</a> | ||
</li> | ||
<li class="breadcrumb-item"><a | ||
href="{{ object.workstation.get_absolute_url }}">{{ object.workstation.title }}</a> | ||
</li> | ||
<li class="breadcrumb-item"><a | ||
href="{{ object.get_absolute_url }}">{{ object }}</a> | ||
</li> | ||
<li class="breadcrumb-item active" | ||
aria-current="page">Create Debug Session | ||
</li> | ||
</ol> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h2>Create Debug Session</h2> | ||
|
||
{% if unsupported_browser_message %} | ||
<div class="alert alert-danger">{{ unsupported_browser_message }}</div> | ||
{% endif %} | ||
|
||
{% crispy form %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.