Skip to content

fix konflux package issues - #2377

Merged
radofuchs merged 17 commits into
lightspeed-core:mainfrom
radofuchs:fix_konflux_tests
Aug 11, 2026
Merged

fix konflux package issues#2377
radofuchs merged 17 commits into
lightspeed-core:mainfrom
radofuchs:fix_konflux_tests

Conversation

@radofuchs

@radofuchs radofuchs commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library [pyproject.toml + uv.lock]
  • Bump-up dependent library [requirements.*.txt for Konflux]
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: (e.g., Claude, CodeRabbit, Ollama, etc., N/A if not used)
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Bug Fixes

    • Improved RAG storage isolation to prevent conflicts with default application data.
    • Standardized startup configuration and handling of RAG fixtures across deployment environments.
    • Improved Kubernetes test setup by supporting updates to existing secrets and large RAG fixtures.
  • Chores

    • Updated dependency pinning and package installation for more reliable, reproducible builds.
    • Updated pipeline profiles and container configuration for the latest build manifests.
    • Upgraded the bundled pyarrow package.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change updates Konflux dependency inputs and pipeline references, adds PyPI wheel installation, relocates OGX and RAG storage in E2E manifests, centralizes startup through a shared entrypoint, and changes secret and ConfigMap provisioning.

Changes

Dependency and E2E runtime updates

Layer / File(s) Summary
Dependency pinning and prefetch wiring
.konflux/..., .tekton/lightspeed-stack-0-8-*.yaml, deploy/lightspeed-stack/Containerfile
The lockfiles, Tekton prefetch configuration, CPU profile, and cachi2 installation use updated wheel requirements and package references.
OGX and RAG startup flow
docker-compose.yaml, tests/e2e-prow/rhoai/configs/run.yaml, tests/e2e-prow/rhoai/manifests/lightspeed/*
The E2E configuration separates RAG storage, preserves OGX paths, restores RAG fixtures, and starts through the shared enrichment entrypoint.
E2E resource provisioning and validation
tests/e2e-prow/rhoai/pipeline-konflux.sh, tests/e2e/features/unified-mode-validation.feature
Secret creation now supports updates, RAG ConfigMaps are recreated directly, and validation scenarios have revised spacing.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InitContainer
  participant RAGFixture
  participant enrich-entrypoint.sh
  participant OGX
  InitContainer->>RAGFixture: restore seed data into RAG working directory
  InitContainer->>enrich-entrypoint.sh: install shared startup wrapper
  enrich-entrypoint.sh->>OGX: use OGX_CONFIG_DIR and configured storage paths
  OGX->>enrich-entrypoint.sh: start Llama Stack with restored RAG data
Loading

Possibly related PRs

Suggested labels: ok-to-test

Suggested reviewers: asimurka, tisnik


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Security And Secret Handling ❌ Error tests/e2e-prow/rhoai/pipeline-konflux.sh:73 and 104-108 create or apply Kubernetes Secrets without OwnerReferences, which can leave credential Secrets orphaned. Attach an appropriate controller or test-resource OwnerReference to every created Secret, including the Quay pull Secret, or document and enforce an approved cleanup owner.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Performance And Algorithmic Complexity ❓ Inconclusive Investigation is still in progress; no verdict submitted yet. Continue code inspection before deciding.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main Konflux package and dependency fixes covered by the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@radofuchs

Copy link
Copy Markdown
Contributor Author

/retest

@radofuchs radofuchs changed the title fix konflux tests fix konflux package issues Aug 11, 2026
@radofuchs
radofuchs marked this pull request as ready for review August 11, 2026 08:52

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 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 `@tests/e2e-prow/rhoai/pipeline-konflux.sh`:
- Around line 223-225: Replace the predictable /tmp/kv_store.db.gz archive path
in the pipeline script with a unique file created via mktemp, update the archive
creation and configmap upload commands to use that path, and register an EXIT
trap to remove it after completion or failure.
- Around line 68-73: Update create_secret to use server-side apply with the
e2e-provisioner field manager when applying the generated Secret manifest,
replacing the current client-side oc apply invocation while preserving the
existing secret generation and namespace behavior.
- Around line 68-73: Update create_secret so every generated Secret receives a
run-scoped same-namespace owner reference using the owner resource’s UID, or add
teardown that explicitly deletes all generated Secrets. Ensure optional Secrets
are also removed or owned when their inputs are absent, preventing stale
resources across runs.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a7bb9639-ac6c-46c6-bab9-5b1b14efc9bf

📥 Commits

Reviewing files that changed from the base of the PR and between 3ff8997 and 5a97e84.

📒 Files selected for processing (14)
  • .konflux/profiles.toml
  • .konflux/requirements.hashes.source.txt
  • .konflux/requirements.hashes.wheel.pypi.txt
  • .konflux/requirements.hashes.wheel.txt
  • .tekton/lightspeed-stack-0-8-pull-request.yaml
  • .tekton/lightspeed-stack-0-8-push.yaml
  • deploy/lightspeed-stack/Containerfile
  • docker-compose.yaml
  • tests/e2e-prow/rhoai/configs/run.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-openai.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-prow.yaml
  • tests/e2e-prow/rhoai/pipeline-konflux.sh
  • tests/e2e/features/unified-mode-validation.feature
💤 Files with no reviewable changes (1)
  • .konflux/requirements.hashes.source.txt
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-8-on-pull-request
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 3
⚠️ CI failures not shown inline (5)

GitHub Actions: PR Title Checker / 0_check.txt: fix konflux package issues

Conclusion: failure

View job details

##[group]Run thehanimo/pr-title-checker@v1.4.3
 with:
   GITHUB_***REDACTED_SECRET_ASSIGNMENT***
   pass_on_octokit_error: false
   configuration_path: .github/pr-title-checker-config.json
 ##[endgroup]
 (node:2143) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
 Using config file .github/pr-title-checker-config.json from repo lightspeed-core/lightspeed-stack [ref: d301b6346f16f36921092e6c3e0ec5b08f51cd10]
 (Use `node --trace-deprecation ...` to show where the warning was created)
 (node:2143) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
 Creating label (title needs formatting)...
 Label (title needs formatting) already created.
 Adding label (title needs formatting) to PR...
 HttpError: Resource not accessible by integration
 ##[error]Failed to add label (title needs formatting) to PR

GitHub Actions: PR Title Checker / check: fix konflux package issues

Conclusion: failure

View job details

##[group]Run thehanimo/pr-title-checker@v1.4.3
 with:
   GITHUB_***REDACTED_SECRET_ASSIGNMENT***
   pass_on_octokit_error: false
   configuration_path: .github/pr-title-checker-config.json
 ##[endgroup]
 (node:2143) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
 Using config file .github/pr-title-checker-config.json from repo lightspeed-core/lightspeed-stack [ref: d301b6346f16f36921092e6c3e0ec5b08f51cd10]
 (Use `node --trace-deprecation ...` to show where the warning was created)
 (node:2143) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
 Creating label (title needs formatting)...
 Label (title needs formatting) already created.
 Adding label (title needs formatting) to PR...
 HttpError: Resource not accessible by integration
 ##[error]Failed to add label (title needs formatting) to PR

GitHub Actions: E2E Tests for Lightspeed Evaluation / E2E Tests for Lightspeed Evaluation job: fix konflux package issues

Conclusion: failure

View job details

##[group]Run echo "=== Test failure logs ==="
 �[36;1mecho "=== Test failure logs ==="�[0m
 �[36;1mecho "=== lightspeed-stack (library mode) logs ==="�[0m
 �[36;1mdocker compose -f docker-compose-library.yaml logs lightspeed-stack�[0m
 shell: /usr/bin/bash -e {0}
 env:
   OPENAI_***REDACTED_SECRET_ASSIGNMENT***
   E2E_OPENAI_MODEL: gpt-4o-mini
   FAISS_VECTOR_STORE_ID: vs_8c94967b-81cc-4028-a294-9cfac6fd9ae2
 ##[endgroup]
 === Test failure logs ===
 === lightspeed-stack (library mode) logs ===
 lightspeed-stack  | .743 INFO:     Lightspeed Core Stack startup  [lightspeed_stack.__main__:160]
 lightspeed-stack  | .746 INFO:     Configuration: name='Lightspeed Core Service (LCS)' service=ServiceConfiguration(host='0.0.0.0', port=8080, base_url=None, auth_enabled=False, workers=1, color_log=True, access_log=True, tls_config=TLSConfiguration(tls_certificate_path=None, tls_key_path=None, tls_key_***REDACTED_SECRET_ASSIGNMENT*** root_path='', cors=CORSConfiguration(allow_origins=['*'], allow_credentials=False, allow_methods=['*'], allow_headers=['*'])) llama_stack=LlamaStackConfiguration(url=AnyHttpUrl('http://localhost:8321/'), ***REDACTED_SECRET_ASSIGNMENT*** use_as_library_client=True, library_client_config_path='/app-root/run.yaml', timeout=180, max_retries=5, retry_delay=2, allow_degraded_mode=False, config=None) user_data_collection=UserDataCollection(feedback_enabled=True, feedback_storage='/tmp/data/feedback', transcripts_enabled=True, transcripts_storage='/tmp/data/transcripts') database=DatabaseConfiguration(sqlite=SQLiteDatabaseConfiguration(db_path='/tmp/lightspeed-stack.db'), postgres=None) mcp_servers=[] authentication=AuthenticationConfiguration(module='noop', skip_tls_verification=False, skip_for_health_probes=False, skip_for_metrics=False, k8s_cluster_api=None, k8s_ca_cert_path=None, jwk_config=None, api_key_config=None, rh_identity_config=None, trusted_proxy_config=None) authorization=None customization=None inference=InferenceConfiguration(default_mod...

GitHub Actions: E2E Tests for Lightspeed Evaluation / E2E Tests for Lightspeed Evaluation job: fix konflux package issues

Conclusion: failure

View job details

 lightspeed-stack  | ERROR      Application startup failed. Exiting.  category=server
 Still waiting...
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 curl: (7) Failed to connect to localhost port 8080 after 0 ms: Couldn't connect to server
 lightspeed-stack  |            File "/app-root/.venv/lib64/python3.12/site-packages/fastapi/routing.py", line 240, in merged_lifespan
 lightspeed-stack  |              async with original_context(app) as maybe_original_state:
 lightspeed-stack  |                         ^^^^^^^^^^^^^^^^^^^^^
 lightspeed-stack  |            File "/usr/lib64/python3.12/contextlib.py", line 210, in __aenter__
 lightspeed-stack  |              return await anext(self.gen)
 lightspeed-stack  |                     ^^^^^^^^^^^^^^^^^^^^^
 lightspeed-stack  |            File "/app-root/src/app/main.py", line 87, in lifespan
 lightspeed-stack  |              await AsyncOgxClientHolder().load(llama_stack_config)
 lightspeed-stack  |            File "/app-root/src/client.py", line 49, in load
 lightspeed-stack  |              await self._load_library_client(llama_stack_config)
 lightspeed-stack  |            File "/app-root/src/client.py", line 82, in _load_library_client
 lightspeed-stack  |              await client.initialize()
 lightspeed-stack  |            File "/app-root/.venv/lib64/python3.12/site-packages/ogx/core/library_client.py", line 413, in initialize
 lightspeed-stack  |              await self.stack.initialize()  # type: ignore
 lightspeed-stack  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 lightspeed-stack  |            File "/app-root/.venv/lib64/python3.12/site-packages/ogx/core/stack.py", line 753, in initialize
 lightspeed-stack  |              impls = await reso...

GitHub Actions: E2E Tests for Lightspeed Evaluation / 0_E2E Tests for Lightspeed Evaluation job.txt: fix konflux package issues

Conclusion: failure

View job details

 lightspeed-stack  | ERROR      Application startup failed. Exiting.  category=server
 Still waiting...
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 curl: (7) Failed to connect to localhost port 8080 after 0 ms: Couldn't connect to server
 lightspeed-stack  |            File "/app-root/.venv/lib64/python3.12/site-packages/fastapi/routing.py", line 240, in merged_lifespan
 lightspeed-stack  |              async with original_context(app) as maybe_original_state:
 lightspeed-stack  |                         ^^^^^^^^^^^^^^^^^^^^^
 lightspeed-stack  |            File "/usr/lib64/python3.12/contextlib.py", line 210, in __aenter__
 lightspeed-stack  |              return await anext(self.gen)
 lightspeed-stack  |                     ^^^^^^^^^^^^^^^^^^^^^
 lightspeed-stack  |            File "/app-root/src/app/main.py", line 87, in lifespan
 lightspeed-stack  |              await AsyncOgxClientHolder().load(llama_stack_config)
 lightspeed-stack  |            File "/app-root/src/client.py", line 49, in load
 lightspeed-stack  |              await self._load_library_client(llama_stack_config)
 lightspeed-stack  |            File "/app-root/src/client.py", line 82, in _load_library_client
 lightspeed-stack  |              await client.initialize()
 lightspeed-stack  |            File "/app-root/.venv/lib64/python3.12/site-packages/ogx/core/library_client.py", line 413, in initialize
 lightspeed-stack  |              await self.stack.initialize()  # type: ignore
 lightspeed-stack  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 lightspeed-stack  |            File "/app-root/.venv/lib64/python3.12/site-packages/ogx/core/stack.py", line 753, in initialize
 lightspeed-stack  |              impls = await reso...
🧰 Additional context used
📓 Path-based instructions (2)
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Files:

  • tests/e2e/features/unified-mode-validation.feature
  • deploy/lightspeed-stack/Containerfile
  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
  • docker-compose.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-prow.yaml
  • tests/e2e-prow/rhoai/configs/run.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-openai.yaml
  • tests/e2e-prow/rhoai/pipeline-konflux.sh
tests/e2e/**/*.feature

📄 CodeRabbit inference engine (AGENTS.md)

Use Behave with Gherkin feature files for end-to-end tests.

Files:

  • tests/e2e/features/unified-mode-validation.feature
🧠 Learnings (2)
📚 Learning: 2026-02-19T10:06:50.647Z
Learnt from: radofuchs
Repo: lightspeed-core/lightspeed-stack PR: 1181
File: tests/e2e-prow/rhoai/manifests/lightspeed/mock-jwks.yaml:32-34
Timestamp: 2026-02-19T10:06:50.647Z
Learning: In the rhoai tests under tests/e2e-prow/rhoai/manifests, avoid static ConfigMap definitions for mock-jwks-script and mcp-mock-server-script since these ConfigMaps are created dynamically by the pipeline.sh deployment script using 'oc create configmap'. Ensure there are no static ConfigMap resources for these names in the manifests. If such ConfigMaps are added in the future, coordinate with the pipeline to reflect dynamic creation or adjust tests to rely on the dynamic provisioning.

Applied to files:

  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-prow.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-openai.yaml
📚 Learning: 2026-05-20T08:09:30.641Z
Learnt from: max-svistunov
Repo: lightspeed-core/lightspeed-stack PR: 1580
File: docs/design/llama-stack-config-merge/poc-results/library-mode/synthesized-run.yaml:107-110
Timestamp: 2026-05-20T08:09:30.641Z
Learning: In Llama-stack config YAMLs, when defining a Llama Guard safety shield entry, set `provider_shield_id` to the *guard model identifier* (e.g., `meta-llama/Llama-Guard-3-8B`). Do not use a chat/generative model id (e.g., `openai/gpt-4o-mini`): a chat-model id (or `native_override`) indicates only an override landed and does **not** mean the safety shield is actually gating queries. Ensure any E2E coverage for the related implementation (JIRA/E2E tests) exercises a real Llama Guard model to verify that the shield is effective.

Applied to files:

  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
  • docker-compose.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-prow.yaml
  • tests/e2e-prow/rhoai/configs/run.yaml
  • tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-openai.yaml
🪛 ast-grep (0.45.1)
tests/e2e-prow/rhoai/pipeline-konflux.sh

[warning] 225-225: Writing to or reading from a hardcoded, predictable path under /tmp is vulnerable to symlink and TOCTOU attacks: a local attacker can pre-create the file (or a symlink pointing elsewhere) and hijack or corrupt the contents. Generate a unique, unpredictable temporary file with mktemp instead, e.g. tmpfile="$(mktemp)" (or mktemp -d for directories) and reference "$tmpfile".
Context: /tmp/kv_store.db.gz
Note: [CWE-377] Insecure Temporary File.

(predictable-tmp-file-bash)

🔇 Additional comments (15)
.konflux/profiles.toml (1)

10-11: LGTM!

.konflux/requirements.hashes.wheel.pypi.txt (1)

2-21: LGTM!

.konflux/requirements.hashes.wheel.txt (1)

105-105: LGTM!

Also applies to: 141-144, 218-218, 286-290, 299-301

.tekton/lightspeed-stack-0-8-pull-request.yaml (1)

51-57: LGTM!

.tekton/lightspeed-stack-0-8-push.yaml (1)

52-58: LGTM!

tests/e2e-prow/rhoai/pipeline-konflux.sh (3)

220-222: LGTM!


223-225: 🩺 Stability & Availability

Avoid an unprotected delete/create window for rag-data.

If pipeline-konflux.sh runs while Llama Stack is active, oc delete removes the ConfigMap before oc create restores it. A restart or concurrent run can fail while rag-data is absent. Use a no-gap replacement strategy, or verify that provisioning always completes before consumers start and that runs cannot overlap. The same ConfigMap name is used by tests/e2e-prow/rhoai/pipeline.sh:261-295.


418-418: LGTM!

tests/e2e/features/unified-mode-validation.feature (1)

22-22: LGTM!

deploy/lightspeed-stack/Containerfile (1)

73-73: LGTM!

docker-compose.yaml (1)

60-61: LGTM!

tests/e2e-prow/rhoai/configs/run.yaml (1)

66-72: LGTM!

tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml (1)

57-59: LGTM!

tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-openai.yaml (1)

1-7: LGTM!

Also applies to: 50-62, 82-82, 94-97, 142-152, 196-221

tests/e2e-prow/rhoai/manifests/lightspeed/llama-stack-prow.yaml (1)

33-41: LGTM!

Also applies to: 90-92, 142-143

Comment on lines 68 to +73
create_secret() {
local name=$1; shift
log "Creating secret $name..."
oc create secret generic "$name" "$@" -n "$NAMESPACE" 2>/dev/null || log "Secret $name exists"
log "Creating/updating secret $name..."
# Upsert: a stale FAISS_VECTOR_STORE_ID from a prior run in this namespace
# would otherwise leave registration/search pointing at the wrong store.
oc create secret generic "$name" "$@" -n "$NAMESPACE" --dry-run=client -o yaml | oc apply -f -

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
sed -n '55,82p' tests/e2e-prow/rhoai/pipeline-konflux.sh
printf '%s\n' '--- oc apply usage in repository ---'
rg -n --glob '*.sh' --glob '*.yaml' --glob '*.yml' 'oc apply|kubectl apply|server-side|field-manager' . | head -200
printf '%s\n' '--- secret ownership patterns ---'
rg -n --glob '*.sh' --glob '*.yaml' --glob '*.yml' 'ownerReferences|create_secret|secret generic' tests/e2e-prow/rhoai . | head -200
printf '%s\n' '--- local oc availability ---'
if command -v oc >/dev/null 2>&1; then
  oc version --client 2>&1 || true
  oc apply --help 2>&1 | grep -E -- '--server-side|--field-manager|--dry-run' || true
else
  echo 'oc is not installed'
fi

Repository: lightspeed-core/lightspeed-stack

Length of output: 13220


🌐 Web query:

Kubernetes client-side apply last-applied-configuration Secret data server-side apply annotation official documentation

💡 Result:

The kubectl.kubernetes.io/last-applied-configuration annotation is a mechanism used exclusively by client-side apply (CSA) to track the state of an object as it was last applied by the client [1][2][3]. This annotation allows the client to perform three-way merges by comparing the live object, the new configuration, and the last-applied state to determine which fields to add, update, or remove [2][3]. When you use server-side apply (SSA) via kubectl apply --server-side, the Kubernetes API server takes over field management [1]. SSA does not use the last-applied-configuration annotation to track changes; instead, it uses the .metadata.managedFields field to track ownership of individual fields by different field managers [1][4][3]. Regarding the specific interaction between these strategies: 1. Transitioning to Server-Side Apply: When you run kubectl apply --server-side on an object previously managed by CSA, the client-side field ownership is transparently migrated to the specified --fieldmanager [5]. During this process, the last-applied-configuration annotation may be updated or eventually removed as ownership is transferred to the server's managed fields system [1][4][5]. 2. Secret Data and SSA: Official Kubernetes documentation notes that the stringData field for a Secret does not work well with server-side apply [6][7]. It is recommended to use the data field instead when working with SSA to avoid potential issues [8]. 3. Downgrading: If you are using SSA and wish to return to CSA, you can generally do so directly with kubectl apply. Because kubectl maintains the last-applied-configuration annotation during SSA operations, the transition back to client-side management remains possible [1]. In summary, SSA represents a shift from client-side state tracking (the annotation) to server-side field ownership (managed fields) [1][4]. When managing Secrets, favor the data field over stringData when utilizing SSA [6][8].

Citations:


🌐 Web query:

site:docs.redhat.com OpenShift oc apply --server-side --field-manager

💡 Result:

The command oc apply --server-side --field-manager is used to perform Server-Side Apply (SSA) in OpenShift, a process that enables collaborative management of Kubernetes resources [1]. Server-Side Apply (SSA) shifts the responsibility of merging resource changes from the client to the API server [1]. Unlike traditional client-side apply, which relies on a last-applied-configuration annotation to calculate diffs, SSA tracks field ownership directly on the server [2][1]. Here is a breakdown of the components: --server-side: This flag instructs the API server to perform the apply operation [1]. It enables the server to track which controller or user manages specific fields within an object [1]. When multiple actors attempt to modify the same resource, the server uses this information to detect and resolve conflicts [1]. --field-manager: This flag allows you to specify a custom name (the "manager") associated with the entity making the changes [3][4]. This name is recorded in the resource's.metadata.managedFields property [2][1]. If you do not provide a name, a default one is typically assigned. Key benefits of this approach include: Conflict Detection: The server prevents unintentional overwrites by identifying when different managers attempt to modify the same field [1]. Ownership Tracking: Because field ownership is stored in managedFields, the system provides a clear audit trail of which actor is responsible for which part of the object configuration [2][1]. Declarative Management: It allows multiple tools or users to manage different parts of the same resource without interfering with each other, as long as they are not modifying the same fields [1]. If a conflict occurs, you may need to use the --force-conflicts flag to override existing field ownership [1].

Citations:


Use server-side apply for Secret data.

Client-side oc apply stores the generated Secret, including Secret.data, in kubectl.kubernetes.io/last-applied-configuration. Use oc apply --server-side --field-manager=e2e-provisioner -f -, or use a patch/replace operation.

🤖 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 `@tests/e2e-prow/rhoai/pipeline-konflux.sh` around lines 68 - 73, Update
create_secret to use server-side apply with the e2e-provisioner field manager
when applying the generated Secret manifest, replacing the current client-side
oc apply invocation while preserving the existing secret generation and
namespace behavior.

Source: MCP tools


🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

file='tests/e2e-prow/rhoai/pipeline-konflux.sh'
printf '%s\n' '--- target file outline ---'
if command -v ast-grep >/dev/null 2>&1; then
  ast-grep outline "$file" || true
fi

printf '%s\n' '--- create_secret and cleanup references ---'
rg -n -C 8 'create_secret|faiss-vector-store-secret|rag-data|NAMESPACE|ownerReferences|owner-reference|delete' "$file"

printf '%s\n' '--- related files and references ---'
rg -n -C 3 'pipeline-konflux|faiss-vector-store-secret|create_secret|rag-data' tests README.md .github 2>/dev/null || true

Repository: lightspeed-core/lightspeed-stack

Length of output: 40086


🏁 Script executed:

#!/bin/bash
set -eu

file='tests/e2e-prow/rhoai/pipeline-konflux.sh'

printf '%s\n' '--- create_secret and lifecycle references ---'
rg -n -C 8 'create_secret|faiss-vector-store-secret|rag-data|NAMESPACE|ownerReferences|owner-reference|delete' "$file"

printf '%s\n' '--- related repository references ---'
rg -n -C 3 'pipeline-konflux|faiss-vector-store-secret|create_secret|rag-data' tests README.md .github 2>/dev/null || true

Repository: lightspeed-core/lightspeed-stack

Length of output: 40006


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- target pipeline and service script ---'
sed -n '1,125p' tests/e2e-prow/rhoai/pipeline-konflux.sh
sed -n '1,90p' tests/e2e-prow/rhoai/pipeline-services-konflux.sh

printf '%s\n' '--- CI/job/owner candidates ---'
rg -n -C 5 'kind: (Job|Deployment|Pod|CronJob)|ownerReferences|generateName:|pipeline-konflux.sh|NAMESPACE=.*e2e-rhoai|e2e-rhoai-dsc' \
  .github tests config 2>/dev/null || true

printf '%s\n' '--- cleanup candidates ---'
rg -n -C 4 'oc (delete|apply).*secret|delete.*namespace|trap|cleanup|teardown|ownerReferences' \
  tests/e2e-prow .github 2>/dev/null || true

printf '%s\n' '--- all Secret creation commands in the target pipeline ---'
rg -n -C 2 'oc create secret|create_secret ' tests/e2e-prow/rhoai/pipeline-konflux.sh

Repository: lightspeed-core/lightspeed-stack

Length of output: 49407


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import re

path = Path("tests/e2e-prow/rhoai/pipeline-konflux.sh")
text = path.read_text()

secret_commands = []
for match in re.finditer(r'(?ms)^\s*(?:create_secret\b.*|oc create secret\b.*?(?:\n\s+.*?\\\n)*\s*--dry-run=client -o yaml \| oc apply -f -|oc create secret\b.*?(?:\n\s+.*?\\\n)*$)', text):
    command = " ".join(line.strip().rstrip("\\") for line in match.group(0).splitlines())
    secret_commands.append(command)

print("secret-command-count:", len(secret_commands))
for i, command in enumerate(secret_commands, 1):
    print(f"{i}: {command}")

print("ownerReferences-present-in-target:", "ownerReferences" in text)
print("namespace-created-only-if-missing:",
      'oc get ns "$NAMESPACE"' in text and '|| oc create namespace "$NAMESPACE"' in text)
print("namespace-deletion-present:", bool(re.search(r'oc\s+delete\s+namespace', text)))
print("secret-deletion-present:", bool(re.search(r'oc\s+delete\s+secret', text)))

# This verifier only inspects the command construction. It does not contact a cluster
# or execute repository code.
for i, command in enumerate(secret_commands, 1):
    print(f"command-{i}-contains-ownerReferences:", "ownerReferences" in command)
PY

Repository: lightspeed-core/lightspeed-stack

Length of output: 16775


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- target pipeline and service script ---'
sed -n '1,125p' tests/e2e-prow/rhoai/pipeline-konflux.sh
sed -n '1,90p' tests/e2e-prow/rhoai/pipeline-services-konflux.sh

printf '%s\n' '--- CI/job/owner candidates ---'
rg -n -C 5 'kind: (Job|Deployment|Pod|CronJob)|ownerReferences|generateName:|pipeline-konflux.sh|NAMESPACE=.*e2e-rhoai|e2e-rhoai-dsc' \
  .github tests config 2>/dev/null || true

printf '%s\n' '--- cleanup candidates ---'
rg -n -C 4 'oc (delete|apply).*secret|delete.*namespace|trap|cleanup|teardown|ownerReferences' \
  tests/e2e-prow .github 2>/dev/null || true

printf '%s\n' '--- all Secret creation commands ---'
rg -n -C 2 'oc create secret|create_secret ' tests/e2e-prow/rhoai/pipeline-konflux.sh

Repository: lightspeed-core/lightspeed-stack

Length of output: 49384


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import re

path = Path("tests/e2e-prow/rhoai/pipeline-konflux.sh")
text = path.read_text()

print("ownerReferences-present-in-target:", "ownerReferences" in text)
print("namespace-created-only-if-missing:",
      'oc get ns "$NAMESPACE"' in text and '|| oc create namespace "$NAMESPACE"' in text)
print("namespace-deletion-present:", bool(re.search(r'oc\s+delete\s+namespace', text)))
print("secret-deletion-present:", bool(re.search(r'oc\s+delete\s+secret', text)))

for line_no, line in enumerate(text.splitlines(), 1):
    if "create_secret " in line or "oc create secret " in line:
        print(f"{line_no}: {line.strip()}")
PY

Repository: lightspeed-core/lightspeed-stack

Length of output: 1037


Assign a run-scoped owner to every Secret, or delete them during teardown.

The default $NAMESPACE persists, and this script does not delete the namespace or its Secrets. Create a same-namespace owner resource and set its UID in metadata.ownerReferences for all generated Secrets. Otherwise, enforce explicit cleanup. Optional Secrets can remain after later runs when their inputs are absent.

🤖 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 `@tests/e2e-prow/rhoai/pipeline-konflux.sh` around lines 68 - 73, Update
create_secret so every generated Secret receives a run-scoped same-namespace
owner reference using the owner resource’s UID, or add teardown that explicitly
deletes all generated Secrets. Ensure optional Secrets are also removed or owned
when their inputs are absent, preventing stale resources across runs.

Sources: Coding guidelines, MCP tools

Comment on lines +223 to +225
oc delete configmap rag-data -n "$NAMESPACE" --ignore-not-found
oc create configmap rag-data -n "$NAMESPACE" \
--from-file=kv_store.db.gz=/tmp/kv_store.db.gz

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Use a unique temporary path for the RAG archive.

If another process can write /tmp, the predictable /tmp/kv_store.db.gz path allows a symlink or TOCTOU attack. The shell redirection can overwrite an attacker-selected path. Create the archive with mktemp and remove it with an EXIT trap.

Proposed fix
+tmp_dir="$(mktemp -d)"
+trap 'rm -rf "$tmp_dir"' EXIT
-gzip -c "$RAG_DB_PATH" > /tmp/kv_store.db.gz
+gzip -c "$RAG_DB_PATH" > "$tmp_dir/kv_store.db.gz"
-      --from-file=kv_store.db.gz=/tmp/kv_store.db.gz
+      --from-file=kv_store.db.gz="$tmp_dir/kv_store.db.gz"
🧰 Tools
🪛 ast-grep (0.45.1)

[warning] 225-225: Writing to or reading from a hardcoded, predictable path under /tmp is vulnerable to symlink and TOCTOU attacks: a local attacker can pre-create the file (or a symlink pointing elsewhere) and hijack or corrupt the contents. Generate a unique, unpredictable temporary file with mktemp instead, e.g. tmpfile="$(mktemp)" (or mktemp -d for directories) and reference "$tmpfile".
Context: /tmp/kv_store.db.gz
Note: [CWE-377] Insecure Temporary File.

(predictable-tmp-file-bash)

🤖 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 `@tests/e2e-prow/rhoai/pipeline-konflux.sh` around lines 223 - 225, Replace the
predictable /tmp/kv_store.db.gz archive path in the pipeline script with a
unique file created via mktemp, update the archive creation and configmap upload
commands to use that path, and register an EXIT trap to remove it after
completion or failure.

Source: Linters/SAST tools

@tisnik tisnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@radofuchs
radofuchs merged commit d625a6a into lightspeed-core:main Aug 11, 2026
27 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants