Skip to content

Commit

Permalink
Fixes for broken periodic tasks, errors during project creation + oth…
Browse files Browse the repository at this point in the history
…er small fixes (#239)
  • Loading branch information
akochari authored Oct 15, 2024
1 parent 58cf9e1 commit 3c8af40
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 20 deletions.
4 changes: 3 additions & 1 deletion apps/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def update_permission(sender, instance, created, **kwargs):

access = getattr(instance, "access", None)

if access is None:
if access is None and instance.name not in ["project-vol", "project-netpolicy"]:
logger.error(f"Access not found in {instance}")
# We do not expect there to be access in case of project-vol and project-netpolicy
# so we do not show a warning when these are deployed.
return

if access == "private":
Expand Down
4 changes: 2 additions & 2 deletions apps/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def get_threshold(threshold):
old_develop_apps = orm_model.objects.filter(created_on__lt=get_threshold(7), app__category__name="Develop")

for app_ in old_develop_apps:
delete_resource.delay(app_.pk)
delete_resource.delay(app_.serialize())

# Handle deletion of non persistent file managers
old_file_managers = FilemanagerInstance.objects.filter(
created_on__lt=timezone.now() - timezone.timedelta(days=1), persistent=False
)
for app_ in old_file_managers:
delete_resource.delay(app_.pk)
delete_resource.delay(app_.serialize())


def helm_install(release_name, chart, namespace="default", values_file=None, version=None):
Expand Down
10 changes: 0 additions & 10 deletions fixtures/projects_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
"app": "rstudio",
"image": "serve-rstudio:231030-1146",
"repository": "ghcr.io/scilifelabdatacentre"
},
"MLflow Serving": {
"app": "mlflow-serve",
"image": "serve-mlflow:231030-1149",
"repository": "ghcr.io/scilifelabdatacentre"
},
"Python Serving": {
"app": "python-serve",
"image": "serve-python:latest",
"repository": "ghcr.io/scilifelabdatacentre"
}
},
"volumes": {
Expand Down
2 changes: 1 addition & 1 deletion projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FlavorForm(forms.Form):

cpu_lim = forms.CharField(label="CPU limit", max_length=10, initial="2000m")
mem_lim = forms.CharField(label="Memory limit", max_length=15, initial="4Gi")
ephmem_req = forms.CharField(label="Ephemeral storage limit", max_length=15, initial="1000Mi")
ephmem_req = forms.CharField(label="Ephemeral storage limit", max_length=15, initial="5000Mi")


class ImageUpdateForm(forms.Form):
Expand Down
17 changes: 17 additions & 0 deletions projects/migrations/0007_alter_flavor_ephmem_lim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.1.1 on 2024-10-10 15:01

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("projects", "0006_alter_flavor_cpu_lim_alter_flavor_cpu_req_and_more"),
]

operations = [
migrations.AlterField(
model_name="flavor",
name="ephmem_lim",
field=models.TextField(blank=True, default="5000Mi", null=True, verbose_name="Ephemeral storage limit"),
),
]
2 changes: 1 addition & 1 deletion projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Flavor(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
cpu_lim = models.TextField("CPU limit", blank=True, null=True, default="2000m")
gpu_lim = models.TextField(blank=True, null=True, default="0")
ephmem_lim = models.TextField("Ephemeral storage limit", blank=True, null=True, default="1000Mi")
ephmem_lim = models.TextField("Ephemeral storage limit", blank=True, null=True, default="5000Mi")
mem_lim = models.TextField("Memory limit", blank=True, null=True, default="4Gi")
cpu_req = models.TextField("CPU request", blank=True, null=True, default="200m")
gpu_req = models.TextField(blank=True, null=True, default="0")
Expand Down
2 changes: 1 addition & 1 deletion projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def get(self, request, project_slug):
)
class GrantAccessToProjectView(View):
def post(self, request, project_slug):
selected_username = request.POST["selected_user"]
selected_username = request.POST["selected_user"].lower()
qs = User.objects.filter(username=selected_username)

if len(qs) == 1:
Expand Down
3 changes: 2 additions & 1 deletion static/common/universities.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"kth": "KTH Royal Institute of Technology",
"liu": "Link\u00f6pings University",
"lnu": "Linnaeus University",
"lth": "LTH Lund University",
"ltu": "Lule\u00e5 University of Technology",
"lu": "Lunds University",
"lu": "Lund University",
"mau": "Malm\u00f6 University",
"mdu": "M\u00e4lardalen University",
"miun": "Mid Sweden University",
Expand Down
2 changes: 1 addition & 1 deletion static/js/form-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ window.onload = (event) => {
const request_account_label = document.querySelector('label[for="id_why_account_needed"]');
const department_label = document.querySelector('label[for="id_department"]');

const domainRegex = /^(?:(?!\b(?:student|stud)\b\.)[A-Z0-9](?:[\.A-Z0-9-]{0,61}[A-Z0-9])?\.)*?(uu|lu|gu|su|umu|liu|ki|kth|chalmers|ltu|hhs|slu|kau|lnu|oru|miun|mau|mdu|bth|fhs|gih|hb|du|hig|hh|hkr|his|hv|ju|sh)\.se$/i;
const domainRegex = /^(?:(?!\b(?:student|stud)\b\.)[A-Z0-9](?:[\.A-Z0-9-]{0,61}[A-Z0-9])?\.)*?(uu|lu|gu|su|umu|liu|ki|kth|chalmers|ltu|hhs|slu|kau|lth|lnu|oru|miun|mau|mdu|bth|fhs|gih|hb|du|hig|hh|hkr|his|hv|ju|sh)\.se$/i;

function changeVisibility() {
let shouldHide = false;
Expand Down
3 changes: 2 additions & 1 deletion templates/projects/grant_revoke_access.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ <h5 class="card-title mb-0">Grant or revoke access</h5>
<div class="mb-3">
<label class="form-label" for="id_selected_user">Email</label>
<input type="text" placeholder="Email" name="selected_user" id="id_selected_user"
class="form-control">
class="form-control"
style="text-transform: lowercase" onchange="this.value = this.value.toLowerCase();">
</div>
</div>
<div class="card-footer d-flex justify-content-end">
Expand Down
2 changes: 1 addition & 1 deletion templates/projects/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h5 class="card-title mb-0">Flavors</h5>
</div>
<div class="mb-3">
<label for="mem_lim">Ephemeral storage limit</label>
<input type="text" name="ephmem_lim" id="ephmem_lim" value="1000Mi" class="form-control" />
<input type="text" name="ephmem_lim" id="ephmem_lim" value="5000Mi" class="form-control" />
</div>
<button type="submit" class="btn btn-square btn-primary">Create flavor</button>
</form>
Expand Down

0 comments on commit 3c8af40

Please sign in to comment.