Skip to content

Commit 28522eb

Browse files
authored
chore(dashboard): Drop redundant CI dashboard columns (#484)
## Summary - Stop reading and writing the redundant `ci_l1_builds.url` column, using `normalized_build_url` as the canonical Jenkins build URL. - Stop persisting unused `ci_l1_pod_lifecycle.jenkins_label_digest` and `jenkins_controller` metadata. - Add follow-up schema migrations to drop the redundant build URL column, one redundant build index, and the unused pod lifecycle metadata columns. ## Rollout notes This PR intentionally keeps code and schema compatible for a two-step rollout: 1. Deploy the new dashboard image first so workers no longer reference the dropped columns. 2. After confirming old `sync_pods`, `sync_builds`, and Jenkins worker jobs are no longer running, execute the schema migrations: - `025_drop_ci_l1_builds_url.sql` - `026_drop_redundant_ci_l1_build_indexes.sql` - `027_drop_unused_pod_lifecycle_metadata_columns.sql` Do not run the drop-column migrations before all old workers are drained, because old workers still reference these columns. ## Validation - `git diff --check` - `.venv/bin/python -m ruff check src tests` - `PYTHONPATH=src .venv/bin/python -m pytest -q tests/jobs/test_sync_pods.py tests/api/test_runtime_insights.py tests/jobs/test_archive_error_logs.py tests/jobs/test_jenkins_worker.py tests/test_models.py`
1 parent 4e0ddfa commit 28522eb

18 files changed

Lines changed: 67 additions & 53 deletions

ci-dashboard/sql/006_create_ci_l1_pod_lifecycle.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ CREATE TABLE IF NOT EXISTS ci_l1_pod_lifecycle (
1717
pod_org VARCHAR(255) NULL,
1818
pod_repo VARCHAR(255) NULL,
1919
jenkins_label VARCHAR(255) NULL,
20-
jenkins_label_digest VARCHAR(255) NULL,
21-
jenkins_controller VARCHAR(255) NULL,
2220
ci_job VARCHAR(255) NULL,
2321
source_prow_job_id VARCHAR(128) NULL,
2422
normalized_build_url VARCHAR(1024) NULL,

ci-dashboard/sql/012_alter_ci_l1_pod_lifecycle_add_pod_metadata_fields.sql

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,4 @@ ALTER TABLE ci_l1_pod_lifecycle
2020
ADD COLUMN IF NOT EXISTS jenkins_label VARCHAR(255) NULL AFTER pod_repo;
2121

2222
ALTER TABLE ci_l1_pod_lifecycle
23-
ADD COLUMN IF NOT EXISTS jenkins_label_digest VARCHAR(255) NULL AFTER jenkins_label;
24-
25-
ALTER TABLE ci_l1_pod_lifecycle
26-
ADD COLUMN IF NOT EXISTS jenkins_controller VARCHAR(255) NULL AFTER jenkins_label_digest;
27-
28-
ALTER TABLE ci_l1_pod_lifecycle
29-
ADD COLUMN IF NOT EXISTS ci_job VARCHAR(255) NULL AFTER jenkins_controller;
23+
ADD COLUMN IF NOT EXISTS ci_job VARCHAR(255) NULL AFTER jenkins_label;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE ci_l1_builds
2+
DROP COLUMN IF EXISTS url;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE ci_l1_builds
2+
DROP INDEX IF EXISTS idx_ci_l1_builds_build_system_state_start_id;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE ci_l1_pod_lifecycle
2+
DROP COLUMN IF EXISTS jenkins_label_digest;
3+
4+
ALTER TABLE ci_l1_pod_lifecycle
5+
DROP COLUMN IF EXISTS jenkins_controller;

ci-dashboard/src/ci_dashboard/api/queries/runtime.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,6 @@ def get_error_builds(
15561556
SELECT
15571557
b.id AS build_row_id,
15581558
b.build_id,
1559-
b.url,
15601559
b.normalized_build_url,
15611560
b.completion_time,
15621561
b.start_time
@@ -2148,7 +2147,7 @@ def _job_ranking_item(row: Any, *, value_key: str, extra_keys: tuple[str, ...] =
21482147

21492148

21502149
def _error_build_item(row: Any, *, include_completion_time: bool = False) -> dict[str, Any]:
2151-
build_url = normalize_build_url(row.get("normalized_build_url")) or normalize_build_url(row.get("url"))
2150+
build_url = normalize_build_url(row.get("normalized_build_url"))
21522151
build_number_from_url = _build_number_from_url(build_url)
21532152
raw_build_number = str(row.get("build_id") or "").strip()
21542153
if build_number_from_url:

ci-dashboard/src/ci_dashboard/common/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class NormalizedBuildRow:
2222
pr_number: int | None
2323
is_pr_build: bool
2424
context: str | None
25-
url: str
2625
normalized_build_url: str | None
2726
author: str | None
2827
retest: bool | None

ci-dashboard/src/ci_dashboard/jobs/analyze_errors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
FETCH_CANDIDATE_BUILDS_BY_IDS = text(
106106
"""
107107
SELECT b.id, b.source_prow_job_id, b.job_name, b.job_type, b.repo_full_name,
108-
b.pr_number, b.head_sha, b.url, b.normalized_build_url, b.pod_name, b.log_gcs_uri,
108+
b.pr_number, b.head_sha, b.normalized_build_url,
109+
b.pod_name, b.log_gcs_uri,
109110
b.error_l1_category, b.error_l2_subcategory,
110111
b.revise_error_l1_category, b.revise_error_l2_subcategory,
111112
pj.state AS prow_state, pj.status AS prow_status,
@@ -142,7 +143,8 @@
142143
FETCH_CANDIDATE_BUILD_BY_ID = text(
143144
"""
144145
SELECT b.id, b.source_prow_job_id, b.job_name, b.job_type, b.repo_full_name,
145-
b.pr_number, b.head_sha, b.url, b.normalized_build_url, b.pod_name, b.log_gcs_uri,
146+
b.pr_number, b.head_sha, b.normalized_build_url,
147+
b.pod_name, b.log_gcs_uri,
146148
b.error_l1_category, b.error_l2_subcategory,
147149
b.revise_error_l1_category, b.revise_error_l2_subcategory,
148150
pj.state AS prow_state, pj.status AS prow_status,
@@ -677,7 +679,7 @@ def _append_live_signal_excerpts(
677679
if not callable(fetch_console_signal_excerpts):
678680
return log_text
679681

680-
build_url = str(build.get("url") or "").strip()
682+
build_url = str(build.get("normalized_build_url") or "").strip()
681683
if not build_url:
682684
return log_text
683685

ci-dashboard/src/ci_dashboard/jobs/archive_error_logs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
FETCH_CANDIDATE_BUILD_BY_ID = text(
2121
"""
22-
SELECT id, url, normalized_build_url, log_gcs_uri, state, build_system,
22+
SELECT id, normalized_build_url, log_gcs_uri, state, build_system,
2323
start_time, completion_time
2424
FROM ci_l1_builds
2525
WHERE id = :build_id
@@ -31,7 +31,7 @@
3131

3232
FETCH_CANDIDATE_BUILD_BY_ID_FORCE = text(
3333
"""
34-
SELECT id, url, normalized_build_url, log_gcs_uri, state, build_system,
34+
SELECT id, normalized_build_url, log_gcs_uri, state, build_system,
3535
start_time, completion_time
3636
FROM ci_l1_builds
3737
WHERE id = :build_id
@@ -42,7 +42,7 @@
4242

4343
FETCH_CANDIDATE_BUILDS_SCAN = text(
4444
"""
45-
SELECT id, url, normalized_build_url, log_gcs_uri, state, build_system,
45+
SELECT id, normalized_build_url, log_gcs_uri, state, build_system,
4646
start_time, completion_time
4747
FROM ci_l1_builds
4848
WHERE build_system = 'JENKINS'
@@ -55,7 +55,7 @@
5555

5656
FETCH_CANDIDATE_BUILDS_SCAN_FORCE = text(
5757
"""
58-
SELECT id, url, normalized_build_url, log_gcs_uri, state, build_system,
58+
SELECT id, normalized_build_url, log_gcs_uri, state, build_system,
5959
start_time, completion_time
6060
FROM ci_l1_builds
6161
WHERE build_system = 'JENKINS'
@@ -236,7 +236,7 @@ def _archive_single_build(
236236
if not force and build.get("log_gcs_uri"):
237237
return False
238238

239-
build_url = str(build.get("url") or "").strip()
239+
build_url = str(build.get("normalized_build_url") or "").strip()
240240
if not build_url:
241241
raise ValueError(f"build {build['id']} is missing Jenkins build URL")
242242

ci-dashboard/src/ci_dashboard/jobs/jenkins_timings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,11 @@ def run_backfill_jenkins_timings(
261261
limit_clause = "LIMIT :limit_value" if limit is not None else ""
262262
query = text(
263263
f"""
264-
SELECT id, COALESCE(normalized_build_url, url) AS build_url
264+
SELECT id, normalized_build_url AS build_url
265265
FROM ci_l1_builds
266266
WHERE build_system = 'JENKINS'
267+
AND normalized_build_url IS NOT NULL
268+
AND normalized_build_url <> ''
267269
AND completion_time IS NOT NULL
268270
AND completion_time >= :cutoff
269271
AND jenkins_queue_total_subtasks_sum IS NULL

0 commit comments

Comments
 (0)