Skip to content

[quality] test: pin storeLiteLLMAPIKey PVC-failure fallback semantics (src/pkg/dashboard/litellm_key_store.go) - #6359

Merged
clubanderson merged 1 commit into
v4from
quality/test-litellm-key-fallback
Sep 9, 2026
Merged

[quality] test: pin storeLiteLLMAPIKey PVC-failure fallback semantics (src/pkg/dashboard/litellm_key_store.go)#6359
clubanderson merged 1 commit into
v4from
quality/test-litellm-key-fallback

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds src/pkg/dashboard/litellm_key_store_fallback_test.go, pinning the previously-untested failure branches of storeLiteLLMAPIKey / patchKeyIntoHiveSecrets (existing coverage only exercises the PVC-write happy path and not-in-cluster short-circuits):

  • PVC write fails, Secret patch succeeds → save succeeds and api_key_file records the Secret mount path (config.DefaultLiteLLMAPIKeyFile), not the PVC path. Also pins the wire contract: PATCH to /api/v1/namespaces/<ns>/secrets/hive-secrets with the SA bearer token and base64 key.
  • PVC write fails, not in cluster → save fails with the PVC error; empty path returned.
  • Both stores fail → the PVC (primary store) error surfaces.
  • Secrecy invariant: returned errors never contain the key value; a rejected patch yields a status-only error (API bodies can echo patch contents).

Tests are hermetic: fake in-cluster API via httptest.NewTLSServer + temp serviceaccount dir (token/namespace/ca.crt), PVC failure induced by a not-a-directory parent so it works at any uid.

Claimed ground

Files: src/pkg/dashboard/litellm_key_store.go (test-only PR; adds src/pkg/dashboard/litellm_key_store_fallback_test.go). Functions: storeLiteLLMAPIKey, patchKeyIntoHiveSecrets. Disjoint from open PRs #6348/#6343/#6292 (other dashboard files) and #6355 (pkg/hub).

Validation

go test -run 'TestStoreLiteLLMAPIKey|TestPatchKeyIntoHiveSecrets' ./pkg/dashboard/ — 4/4 pass.


Filed by quality agent (hold-gated mode). Human review required. Do not merge without removing hold (humans only).

— hive: agent=quality backend=copilot model=claude-fable-5

… (src/pkg/dashboard/litellm_key_store.go)

Pins the previously-untested failure branches of storeLiteLLMAPIKey:
- PVC write fails, hive-secrets Secret patch succeeds -> api_key_file
  records config.DefaultLiteLLMAPIKeyFile (Secret mount), save succeeds
- PVC write fails, not in cluster -> save fails with the PVC error
- both stores fail -> PVC (primary) error surfaces
- patchKeyIntoHiveSecrets rejection is status-only and never echoes the
  key value; the PATCH carries the base64 key, SA token, and targets
  /api/v1/namespaces/<ns>/secrets/hive-secrets

Uses a fake in-cluster API (httptest TLS server + temp serviceaccount
dir) so the tests are hermetic.

Signed-off-by: hive-quality <sec-check@hive.kubestellar.io>
@kubestellar-hive kubestellar-hive Bot added the hold label Sep 9, 2026
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but carries no changelog entry
(no changelog.d/ fragment and no CHANGELOG.md edit).

If it is user-visible — a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking —
please add a fragment file changelog.d/<category>-<pr-or-slug>.md
containing exactly your entry (see changelog.d/README.md; the
category is one of added/changed/deprecated/fixed/security). Please
do not append to CHANGELOG.md's ## Unreleased directly — that
shared section is the merge-conflict generator fragments replaced
(#5675). If it is a refactor, a test-only change, or dependency
churn, no entry is needed and you can ignore this.

This is a reminder, not a gate; it never blocks a merge.

@clubanderson

Copy link
Copy Markdown
Member

/approve

@clubanderson
clubanderson merged commit 8e41e7f into v4 Sep 9, 2026
54 of 60 checks passed
@clubanderson
clubanderson deleted the quality/test-litellm-key-fallback branch September 9, 2026 16:20
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clubanderson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Approved by a Hive merger/owner for auto-merge on green CI approved Indicates a PR has been approved by an approver from all required OWNERS files. copilot dco-signoff: yes Indicates the PR's author has signed the DCO. hive/hosted-available-oke-11-placeholder-r05x Approved by a Hive merger/owner for auto-merge on green CI no-changelog No changelog fragment required quality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant