Skip to content

Commit d4e338b

Browse files
authored
Merge pull request #1216 from spack/commit_id-to-pipeline_id
Rename `commit_id` to `pipeline_id`
2 parents 6d229b9 + 49eca97 commit d4e338b

File tree

7 files changed

+41
-14
lines changed

7 files changed

+41
-14
lines changed

.github/workflows/custom_docker_builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- docker-image: ./images/cache-indexer
4646
image-tags: ghcr.io/spack/cache-indexer:0.0.6
4747
- docker-image: ./analytics
48-
image-tags: ghcr.io/spack/django:0.5.9
48+
image-tags: ghcr.io/spack/django:0.5.10
4949
- docker-image: ./images/ci-prune-buildcache
5050
image-tags: ghcr.io/spack/ci-prune-buildcache:0.0.4
5151
- docker-image: ./images/protected-publish

analytics/analytics/core/job_log_uploader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def store_job_data(job_input_data_json: str) -> None:
6060
retry_info = get_job_retry_data(
6161
job_id=job_input_data["build_id"],
6262
job_name=job_input_data["build_name"],
63-
job_commit_id=job_input_data["commit"]["id"],
63+
job_pipeline_id=job_input_data["pipeline_id"],
6464
job_failure_reason=job_input_data["build_failure_reason"],
6565
)
6666
job_input_data.update(asdict(retry_info))
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 5.2.6 on 2025-10-02 20:46
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('core', '0012_jobfact_core_jobfact_started_at_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveConstraint(
14+
model_name='gitlabjobdatadimension',
15+
name='unique-gitlab-job-data',
16+
),
17+
migrations.RenameField(
18+
model_name='gitlabjobdatadimension',
19+
old_name='commit_id',
20+
new_name='pipeline_id',
21+
),
22+
migrations.AddConstraint(
23+
model_name='gitlabjobdatadimension',
24+
constraint=models.UniqueConstraint(fields=('gitlab_runner_version', 'ref', 'tags', 'pipeline_id'), name='unique-gitlab-job-data'),
25+
),
26+
]

analytics/analytics/core/models/dimensions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class GitlabJobDataDimension(models.Model):
171171
gitlab_runner_version = models.CharField(max_length=16)
172172
ref = models.CharField(max_length=256)
173173
tags = ArrayField(base_field=models.CharField(max_length=32), default=list)
174-
commit_id = models.PositiveBigIntegerField(null=True)
174+
pipeline_id = models.PositiveBigIntegerField(null=True)
175175

176176
class Meta:
177177
constraints = [
@@ -181,7 +181,7 @@ class Meta:
181181
"gitlab_runner_version",
182182
"ref",
183183
"tags",
184-
"commit_id",
184+
"pipeline_id",
185185
],
186186
),
187187
]

analytics/analytics/job_processor/dimensions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def create_gitlab_job_data_dimension(
134134
gitlab_runner_version=runner_version,
135135
ref=gljob.ref,
136136
tags=gljob.tag_list,
137-
commit_id=job_input_data["commit"]["id"],
137+
pipeline_id=job_input_data["pipeline_id"],
138138
)
139139

140140
return res
@@ -165,12 +165,12 @@ def create_job_result_dimension(job_input_data: dict, job_trace: str):
165165
def create_job_retry_dimension(job_input_data: dict):
166166
job_id = job_input_data["build_id"]
167167
job_name = job_input_data["build_name"]
168-
job_commit_id = job_input_data["commit"]["id"]
168+
job_pipeline_id = job_input_data["pipeline_id"]
169169
job_failure_reason: str = job_input_data["build_failure_reason"]
170170
retry_info = get_job_retry_data(
171171
job_id=job_id,
172172
job_name=job_name,
173-
job_commit_id=job_commit_id,
173+
job_pipeline_id=job_pipeline_id,
174174
job_failure_reason=job_failure_reason,
175175
)
176176

analytics/analytics/job_processor/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ class RetryInfo:
2424

2525

2626
def get_job_retry_data(
27-
job_id: int, job_name: str, job_commit_id: int, job_failure_reason: str
27+
job_id: int, job_name: str, job_pipeline_id: int, job_failure_reason: str
2828
) -> RetryInfo:
2929
with connections["gitlab"].cursor() as cursor:
30-
# the prior attempts for a given job are all jobs with a lower id, the same commit_id, and
31-
# the same name. the commit_id is the foreign key for the pipeline.
32-
# it's important to filter for a lower job id in the event that the webhook is delayed or
30+
# In gitlab, the pipeline ID is stored as `commit_id`.
31+
# The prior attempts for a given job are all jobs with a lower id, the same commit_id, and
32+
# the same name.
33+
# It's important to filter for a lower job id in the event that the webhook is delayed or
3334
# received out of order.
3435
cursor.execute(
3536
"""
@@ -39,7 +40,7 @@ def get_job_retry_data(
3940
AND commit_id = %(commit_id)s
4041
AND name = %(job_name)s
4142
""",
42-
{"job_id": job_id, "job_name": job_name, "commit_id": job_commit_id},
43+
{"job_id": job_id, "job_name": job_name, "commit_id": job_pipeline_id},
4344
)
4445
attempt_number = cursor.fetchone()[0] + 1
4546

k8s/production/custom/webhook-handler/deployments.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
serviceAccountName: webhook-handler
2424
containers:
2525
- name: webhook-handler
26-
image: ghcr.io/spack/django:0.5.9
26+
image: ghcr.io/spack/django:0.5.10
2727
imagePullPolicy: Always
2828
resources:
2929
requests:
@@ -146,7 +146,7 @@ spec:
146146
serviceAccountName: webhook-handler
147147
containers:
148148
- name: webhook-handler-worker
149-
image: ghcr.io/spack/django:0.5.9
149+
image: ghcr.io/spack/django:0.5.10
150150
command:
151151
[
152152
"celery",

0 commit comments

Comments
 (0)