From b0d5b8323dd66ca861a81d63ffeac14fd1bae2e9 Mon Sep 17 00:00:00 2001 From: UniDesk Codex Date: Mon, 6 Jul 2026 15:23:04 +0800 Subject: [PATCH] fix: gate prometheus operator resources for v03 --- deploy/deploy.schema.json | 3 +++ deploy/deploy.yaml | 1 + scripts/gitops-render.mjs | 13 ++++++++++--- scripts/src/runtime-lane.ts | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/deploy/deploy.schema.json b/deploy/deploy.schema.json index 5782e035..a37e6d35 100644 --- a/deploy/deploy.schema.json +++ b/deploy/deploy.schema.json @@ -401,6 +401,9 @@ "type": "string", "minLength": 1, "pattern": "\\{trace_id\\}" + }, + "prometheusOperatorResources": { + "type": "boolean" } }, "additionalProperties": false diff --git a/deploy/deploy.yaml b/deploy/deploy.yaml index 8bf1901a..bf18e620 100644 --- a/deploy/deploy.yaml +++ b/deploy/deploy.yaml @@ -339,6 +339,7 @@ lanes: autoCollapseTerminal: false observability: traceExplorerUrlTemplate: /v1/workbench/traces/{trace_id}/events + prometheusOperatorResources: false opencode: image: 127.0.0.1:5000/hwlab/opencode:1.17.7-git providerProfile: dsflash-go diff --git a/scripts/gitops-render.mjs b/scripts/gitops-render.mjs index 56347ac1..c7db3537 100644 --- a/scripts/gitops-render.mjs +++ b/scripts/gitops-render.mjs @@ -1142,6 +1142,12 @@ function runtimeTraceExplorerUrlTemplate(deploy, profile) { return typeof template === "string" && template.trim().length > 0 ? template.trim() : null; } +function runtimePrometheusOperatorResourcesEnabled(deploy, profile) { + if (!isRuntimeLane(profile)) return true; + const enabled = runtimeLaneConfig(deploy, profile)?.observability?.prometheusOperatorResources; + return enabled !== false; +} + function runtimeStoreEnvForProfile(deploy, profile, serviceId) { if (!isRuntimeLane(profile) || serviceId !== "hwlab-cloud-api") return {}; const postgres = runtimeLaneConfig(deploy, profile)?.runtimeStore?.postgres; @@ -1581,6 +1587,7 @@ function transformServices({ services, namespace, labels, annotations, profile = function observabilityManifest({ deploy, profile, namespace, labels, annotations, metricsSidecarScript }) { assert.ok(isRuntimeLane(profile), `observability profile must be a runtime lane, got ${profile}`); + const includePrometheusOperatorResources = runtimePrometheusOperatorResourcesEnabled(deploy, profile); const baseLabels = { ...labels, "app.kubernetes.io/part-of": "hwlab", @@ -1621,8 +1628,8 @@ function observabilityManifest({ deploy, profile, namespace, labels, annotations metadata: { name: `hwlab-${profile}-metrics-sidecar`, namespace, labels: baseLabels, annotations }, data: { "metrics-sidecar.mjs": metricsSidecarScript } }, - ...serviceMonitors, - { + ...(includePrometheusOperatorResources ? serviceMonitors : []), + ...(includePrometheusOperatorResources ? [{ apiVersion: "monitoring.coreos.com/v1", kind: "PrometheusRule", metadata: { name: `hwlab-${profile}-observability`, namespace, labels: baseLabels, annotations }, @@ -1647,7 +1654,7 @@ function observabilityManifest({ deploy, profile, namespace, labels, annotations ] }] } - } + }] : []) ] }; } diff --git a/scripts/src/runtime-lane.ts b/scripts/src/runtime-lane.ts index 6feb5555..dcd1800f 100644 --- a/scripts/src/runtime-lane.ts +++ b/scripts/src/runtime-lane.ts @@ -46,6 +46,7 @@ export type RuntimeLaneConfig = { }; observability?: { traceExplorerUrlTemplate?: string; + prometheusOperatorResources?: boolean; }; sourceRepo?: string; };