Skip to content

Commit

Permalink
Add computed column for infrastructure errors
Browse files Browse the repository at this point in the history
Instead of manually filtering these out in metabase, this introduces
a DB computed column that will handle that logic.
  • Loading branch information
mvandenburgh committed Jan 3, 2025
1 parent 4244e71 commit 5e6004c
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 5.1.4 on 2025-01-03 16:02

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="jobdatadimension",
name="infrastructure_error",
field=models.GeneratedField(
db_persist=True,
expression=models.Case(
models.When(
models.Q(
models.Q(
("status", "failed"),
models.Q(
(
"error_taxonomy__in",
[
"spack_error",
"build_error",
"concretization_error",
"module_not_found",
],
),
models.Q(
("error_taxonomy", "failed_to_get_specs"),
("job_type", "rebuild-index"),
),
_connector="OR",
),
)
),
then=models.Value(True),
),
default=models.Value(False),
output_field=models.BooleanField(),
),
help_text='Whether or not this job is an "infrastructure error", or a legitimate CI failure.',
output_field=models.BooleanField(),
),
),
]
34 changes: 34 additions & 0 deletions analytics/analytics/core/models/dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import Case, Q, Value, When
from django.db.models.functions import Length


Expand Down Expand Up @@ -173,6 +174,39 @@ class Meta:
db_comment="Whether this job has 'No need to rebuild' in its trace.",
) # type: ignore

infrastructure_error = models.GeneratedField(
output_field=models.BooleanField(),
db_persist=True,
expression=Case(
When(
Q(
Q(status="failed")
& Q(
Q(
error_taxonomy__in=[
"spack_error",
"build_error",
"concretization_error",
"module_not_found",
]
)
| Q(
# This is a special case for the rebuild-index job type.
# If a reindex job fails to get specs, it's not an infrastructure error,
# but only if both those conditions are met.
job_type=JobType.REBUILD_INDEX,
error_taxonomy="failed_to_get_specs",
),
),
),
then=Value(True),
),
default=Value(False),
output_field=models.BooleanField(),
),
help_text='Whether or not this job is an "infrastructure error", or a legitimate CI failure.',
)

pod_name = models.CharField(max_length=128, null=True, blank=True)
gitlab_runner_version = models.CharField(max_length=16)
job_type = models.CharField(
Expand Down

0 comments on commit 5e6004c

Please sign in to comment.