HYPERFLEET-1108 - feat: Add e2e.hyperfleet.io/run-id label for e2e-gcp environment, label resources created by adapters#57
Conversation
…p environment, label resources created by adapters
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughA new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@helmfile/configs/e2e/adapters/cl-deployment/adapter-task-config.yaml`:
- Around line 9-12: The e2eRunId input is only checked for non-empty, but it is
later used as a Kubernetes label value, so invalid characters can still reach
templating. Update the boundary handling for the e2eRunId mapping sourced from
env.E2E_RUN_ID to enforce a strict label-safe regex before it is rendered or
stamped into manifests. Keep the validation close to the adapter-task-config
input definition so invalid values are rejected early and cannot flow into label
generation.
In
`@helmfile/configs/e2e/adapters/cl-maestro/adapter-task-resource-manifestwork.yaml`:
- Around line 31-50: The YAML template in the manifestwork adapter has an
indentation regression that breaks the parent mappings and produces invalid
YAML. Re-indent the `hyperfleet.io/platform-type` conditional, the `annotations`
block, the ConfigMap `data` conditionals, and the ConfigMap `metadata` block so
they remain nested under the correct `metadata`/resource sections in this
template. Use the surrounding manifest structure in
`adapter-task-resource-manifestwork.yaml` to keep the `annotations`, `data`, and
`metadata` keys aligned with their parent objects.
In `@helmfile/helmfile.yaml.gotmpl`:
- Around line 30-32: The run-id label value is being emitted unquoted in the
helmfile template, which can let a numeric E2E_RUN_ID be serialized as a
non-string scalar and break Kubernetes label rendering. Update the
helmfile.yaml.gotmpl entry for labels.e2e.hyperfleet.io/run-id so the value is
always quoted as a string, while keeping e2eRunId consistent with the downstream
string handling.
In `@Makefile`:
- Around line 320-327: The E2E_RUN_ID check in the Makefile only blocks empty
values, but it should also reject strings that are not valid Kubernetes label
values before they reach metadata.labels. Update the install-hyperfleet
validation block to verify E2E_RUN_ID against Kubernetes label-value rules
(allowed characters, length, and format) in addition to the existing non-empty
check, and fail fast with a clear error message when invalid. Keep the logic in
the same HELMFILE_ENV=e2e-gcp guard so the validation happens at the system
boundary before any Helm/Kubernetes apply step.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: dec1e2d2-0e70-4017-9915-192667816ec1
📒 Files selected for processing (12)
Makefilehelmfile/configs/e2e/adapters/cl-deployment/adapter-task-config.yamlhelmfile/configs/e2e/adapters/cl-deployment/adapter-task-resource-deployment.yamlhelmfile/configs/e2e/adapters/cl-job/adapter-task-config.yamlhelmfile/configs/e2e/adapters/cl-job/adapter-task-resource-job.yamlhelmfile/configs/e2e/adapters/cl-maestro/adapter-task-config.yamlhelmfile/configs/e2e/adapters/cl-maestro/adapter-task-resource-manifestwork.yamlhelmfile/configs/e2e/adapters/cl-namespace/adapter-task-config.yamlhelmfile/helmfile.yaml.gotmplhelmfile/values/base-adapter.yaml.gotmplhelmfile/values/base-api.yaml.gotmplhelmfile/values/base-sentinel.yaml.gotmpl
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
openshift-hyperfleet/architecture(manual)openshift-hyperfleet/hyperfleet-api(manual)openshift-hyperfleet/hyperfleet-sentinel(manual)openshift-hyperfleet/hyperfleet-adapter(manual)openshift-hyperfleet/hyperfleet-broker(manual)
| - name: "e2eRunId" | ||
| source: "env.E2E_RUN_ID" | ||
| type: "string" | ||
| required: false |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Enforce label-safe validation for E2E_RUN_ID before templating.
e2eRunId is sourced from env and later stamped into Kubernetes labels. Current gating only checks non-empty, so invalid characters can break manifests or inject malformed YAML/labels (CWE-20, CWE-74). Add strict label-value regex validation at the boundary.
As per path instructions, “Validate input at system boundaries (HTTP handlers, CLI parsers, webhook receivers).”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@helmfile/configs/e2e/adapters/cl-deployment/adapter-task-config.yaml` around
lines 9 - 12, The e2eRunId input is only checked for non-empty, but it is later
used as a Kubernetes label value, so invalid characters can still reach
templating. Update the boundary handling for the e2eRunId mapping sourced from
env.E2E_RUN_ID to enforce a strict label-safe regex before it is rendered or
stamped into manifests. Keep the validation close to the adapter-task-config
input definition so invalid values are rejected early and cannot flow into label
generation.
Source: Path instructions
| {{ if .platformType }} | ||
| hyperfleet.io/platform-type: "{{ .platformType }}" | ||
| {{ end }} | ||
|
|
||
| # Annotations for metadata and operational information | ||
| annotations: | ||
| # Tracking and lifecycle | ||
| hyperfleet.io/created-by: "cl-maestro-framework" | ||
| hyperfleet.io/managed-by: "{{ .adapter.name }}" | ||
| hyperfleet.io/generation: "{{ .generation }}" | ||
| hyperfleet.io/cluster-id: "{{ .clusterId }}" | ||
| hyperfleet.io/cluster-name: "{{ .clusterName }}" | ||
| hyperfleet.io/deployment-time: "{{ .timestamp }}" | ||
| # Annotations for metadata and operational information | ||
| annotations: | ||
| # Tracking and lifecycle | ||
| hyperfleet.io/created-by: "cl-maestro-framework" | ||
| hyperfleet.io/managed-by: "{{ .adapter.name }}" | ||
| hyperfleet.io/generation: "{{ .generation }}" | ||
| hyperfleet.io/cluster-id: "{{ .clusterId }}" | ||
| hyperfleet.io/cluster-name: "{{ .clusterName }}" | ||
| hyperfleet.io/deployment-time: "{{ .timestamp }}" | ||
|
|
||
| # Maestro-specific annotations | ||
| maestro.io/applied-time: "{{ .timestamp }}" | ||
| maestro.io/source-adapter: "{{ .adapter.name }}" | ||
| # Maestro-specific annotations | ||
| maestro.io/applied-time: "{{ .timestamp }}" | ||
| maestro.io/source-adapter: "{{ .adapter.name }}" | ||
|
|
||
| # Documentation | ||
| description: "Complete cluster setup including namespace, configuration, and RBAC" | ||
| # Documentation | ||
| description: "Complete cluster setup including namespace, configuration, and RBAC" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file='helmfile/configs/e2e/adapters/cl-maestro/adapter-task-resource-manifestwork.yaml'
echo "== outline =="
ast-grep outline "$file" --view expanded || true
echo
echo "== numbered excerpt (1-220) =="
cat -n "$file" | sed -n '1,220p'Repository: openshift-hyperfleet/hyperfleet-infra
Length of output: 7552
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file='helmfile/configs/e2e/adapters/cl-maestro/adapter-task-resource-manifestwork.yaml'
echo "== outline =="
ast-grep outline "$file" --view expanded || true
echo
echo "== numbered excerpt (1-220) =="
cat -n "$file" | sed -n '1,220p'Repository: openshift-hyperfleet/hyperfleet-infra
Length of output: 7552
Fix the YAML indentation regression
hyperfleet.io/platform-type, annotations, the ConfigMap data conditionals, and the ConfigMap metadata block are dedented out of their parent mappings, so the template now renders invalid YAML and the manifest can’t be parsed (CWE-20). Also applies to 77-99.
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 32-32: syntax error: could not find expected ':'
(syntax)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@helmfile/configs/e2e/adapters/cl-maestro/adapter-task-resource-manifestwork.yaml`
around lines 31 - 50, The YAML template in the manifestwork adapter has an
indentation regression that breaks the parent mappings and produces invalid
YAML. Re-indent the `hyperfleet.io/platform-type` conditional, the `annotations`
block, the ConfigMap `data` conditionals, and the ConfigMap `metadata` block so
they remain nested under the correct `metadata`/resource sections in this
template. Use the surrounding manifest structure in
`adapter-task-resource-manifestwork.yaml` to keep the `annotations`, `data`, and
`metadata` keys aligned with their parent objects.
Source: Linters/SAST tools
| e2eRunId: {{ env "E2E_RUN_ID" }} | ||
| labels: | ||
| e2e.hyperfleet.io/run-id: {{ env "E2E_RUN_ID" }} |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== helmfile references =="
rg -n 'E2E_RUN_ID|e2e\.hyperfleet\.io/run-id|e2eRunId|requiredEnv "E2E_RUN_ID"|env "E2E_RUN_ID"' helmfile . || true
echo
echo "== nearby context in helmfile/helmfile.yaml.gotmpl =="
nl -ba helmfile/helmfile.yaml.gotmpl | sed -n '1,80p'Repository: openshift-hyperfleet/hyperfleet-infra
Length of output: 5082
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== adapter references =="
rg -n 'testRunId|run-id|E2E_RUN_ID|TEST_RUN_ID|e2e\.hyperfleet\.io/(run-id|test-run-id)' . || trueRepository: openshift-hyperfleet/hyperfleet-adapter
Length of output: 437
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== architecture docs references =="
rg -n 'test-run-id|run-id|E2E_RUN_ID|TEST_RUN_ID|e2e\.hyperfleet\.io/(run-id|test-run-id)' hyperfleet/docs/e2e-testing || trueRepository: openshift-hyperfleet/architecture
Length of output: 2602
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '20,38p' helmfile/helmfile.yaml.gotmpl
echo
sed -n '1,90p' helmfile/values/base-adapter.yaml.gotmpl
echo
sed -n '312,328p' MakefileRepository: openshift-hyperfleet/hyperfleet-infra
Length of output: 2577
🏁 Script executed (no clone):
python3 - <<'PY'
import yaml, json, textwrap
doc = yaml.safe_load(textwrap.dedent("""
labels:
e2e.hyperfleet.io/run-id: 123
"""))
print(type(doc["labels"]["e2e.hyperfleet.io/run-id"]).__name__, doc["labels"]["e2e.hyperfleet.io/run-id"])
PY
Length of output: 133
Quote the run-id label value (CWE-20).
e2eRunId is re-quoted downstream, but labels.e2e.hyperfleet.io/run-id is later serialized via toYaml and can become a non-string YAML scalar if E2E_RUN_ID is numeric, which breaks Kubernetes label rendering.
Suggested fix
- e2e.hyperfleet.io/run-id: {{ env "E2E_RUN_ID" }}
+ e2e.hyperfleet.io/run-id: {{ env "E2E_RUN_ID" | quote }}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| e2eRunId: {{ env "E2E_RUN_ID" }} | |
| labels: | |
| e2e.hyperfleet.io/run-id: {{ env "E2E_RUN_ID" }} | |
| e2eRunId: {{ env "E2E_RUN_ID" }} | |
| labels: | |
| e2e.hyperfleet.io/run-id: {{ env "E2E_RUN_ID" | quote }} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@helmfile/helmfile.yaml.gotmpl` around lines 30 - 32, The run-id label value
is being emitted unquoted in the helmfile template, which can let a numeric
E2E_RUN_ID be serialized as a non-string scalar and break Kubernetes label
rendering. Update the helmfile.yaml.gotmpl entry for
labels.e2e.hyperfleet.io/run-id so the value is always quoted as a string, while
keeping e2eRunId consistent with the downstream string handling.
Source: Path instructions
| @if [ "$(HELMFILE_ENV)" = "e2e-gcp" ]; then \ | ||
| if [ -z "$(E2E_RUN_ID)" ]; then \ | ||
| echo "ERROR: E2E_RUN_ID must be set when HELMFILE_ENV=e2e-gcp"; \ | ||
| echo " Usage: E2E_RUN_ID=<run-id> make install-hyperfleet"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "OK: E2E_RUN_ID=$(E2E_RUN_ID)"; \ | ||
| fi; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Enforce Kubernetes label-value validation for E2E_RUN_ID (CWE-20).
Current check only rejects empty values. Invalid label values (illegal chars/length) still pass here and fail later when applied as metadata.labels.
Suggested fix
check-e2e-run-id: ## Verify E2E_RUN_ID is set for e2e-gcp environment
`@if` [ "$(HELMFILE_ENV)" = "e2e-gcp" ]; then \
if [ -z "$(E2E_RUN_ID)" ]; then \
echo "ERROR: E2E_RUN_ID must be set when HELMFILE_ENV=e2e-gcp"; \
echo " Usage: E2E_RUN_ID=<run-id> make install-hyperfleet"; \
exit 1; \
fi; \
+ if ! printf '%s' "$(E2E_RUN_ID)" | grep -Eq '^[A-Za-z0-9]([A-Za-z0-9._-]{0,61}[A-Za-z0-9])?$$'; then \
+ echo "ERROR: E2E_RUN_ID must be a valid Kubernetes label value (1-63 chars, alnum boundaries, [A-Za-z0-9._-] allowed)"; \
+ exit 1; \
+ fi; \
echo "OK: E2E_RUN_ID=$(E2E_RUN_ID)"; \
fi;As per path instructions, "Validate input at system boundaries (HTTP handlers, CLI parsers, webhook receivers)."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @if [ "$(HELMFILE_ENV)" = "e2e-gcp" ]; then \ | |
| if [ -z "$(E2E_RUN_ID)" ]; then \ | |
| echo "ERROR: E2E_RUN_ID must be set when HELMFILE_ENV=e2e-gcp"; \ | |
| echo " Usage: E2E_RUN_ID=<run-id> make install-hyperfleet"; \ | |
| exit 1; \ | |
| fi; \ | |
| echo "OK: E2E_RUN_ID=$(E2E_RUN_ID)"; \ | |
| fi; | |
| `@if` [ "$(HELMFILE_ENV)" = "e2e-gcp" ]; then \ | |
| if [ -z "$(E2E_RUN_ID)" ]; then \ | |
| echo "ERROR: E2E_RUN_ID must be set when HELMFILE_ENV=e2e-gcp"; \ | |
| echo " Usage: E2E_RUN_ID=<run-id> make install-hyperfleet"; \ | |
| exit 1; \ | |
| fi; \ | |
| if ! printf '%s' "$(E2E_RUN_ID)" | grep -Eq '^[A-Za-z0-9]([A-Za-z0-9._-]{0,61}[A-Za-z0-9])?$$'; then \ | |
| echo "ERROR: E2E_RUN_ID must be a valid Kubernetes label value (1-63 chars, alnum boundaries, [A-Za-z0-9._-] allowed)"; \ | |
| exit 1; \ | |
| fi; \ | |
| echo "OK: E2E_RUN_ID=$(E2E_RUN_ID)"; \ | |
| fi; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Makefile` around lines 320 - 327, The E2E_RUN_ID check in the Makefile only
blocks empty values, but it should also reject strings that are not valid
Kubernetes label values before they reach metadata.labels. Update the
install-hyperfleet validation block to verify E2E_RUN_ID against Kubernetes
label-value rules (allowed characters, length, and format) in addition to the
existing non-empty check, and fail fast with a clear error message when invalid.
Keep the logic in the same HELMFILE_ENV=e2e-gcp guard so the validation happens
at the system boundary before any Helm/Kubernetes apply step.
Source: Path instructions
Summary
This PR adds support for labeling all resources in the
e2e-gcpenvironment with a uniquee2e.hyperfleet.io/run-idlabel, enabling better tracking and cleanup of resources created during E2E test runs.Caution
TODO: Prepare change for openshift/release repo CI for hyperfleet-e2e
What changed:
E2E_RUN_IDenvironment variable fore2e-gcpdeploymentse2e-gcpare automatically labeled withe2e.hyperfleet.io/run-id: <run-id>E2E_RUN_IDas an environment variablee2eRunIdparameter to resources they create (Namespaces, Jobs, Deployments, ConfigMaps, ManifestWorks)E2E_RUN_IDis set when deploying toe2e-gcpWhy this is needed:
Impact on users:
E2E_RUN_IDto be set when deploying (enforced by validation)E2E_RUN_IDwhen runningmake install-hyperfleetUsage:
Test Plan
make test-allpasses - N/A (no test suite for helmfile templates)make lintpasses - Validated withmake ci-validatemake test-helm(if applicable) - N/A (changes are in helmfile values, not charts)make template-helmfileManual Testing Performed:
e2e-gcpdeployment fails withoutE2E_RUN_IDe2e-gcpdeployment succeeds withE2E_RUN_IDe2e-gcpare labeled withe2e.hyperfleet.io/run-idE2E_RUN_IDenvironment variablegcp,kind, ande2e-kindenvironments build without changese2e.hyperfleet.io/run-idlabelBreaking Changes
For e2e-gcp environment only:
E2E_RUN_IDenvironment variable is now required when deploying toe2e-gcpE2E_RUN_IDis not setHELMFILE_ENV=e2e-gcpmust be updated to passE2E_RUN_ID