mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-22 19:32:55 -05:00
## Description
Craft development required repeated image builds, copied cluster
settings, and editor-specific Telepresence commands. Startup could
report success before services were usable.
- Share configuration resolution and launch commands between Make and VS
Code. Read deployed ConfigMaps and Secrets in memory, with personal
`.env.k8s` overrides.
- Add separate infrastructure and application readiness checks,
`craft-doctor`, and shared Telepresence connection/intercept handling.
- Reuse images, detect source changes, and provide checkout-scoped
cleanup previews. Add pause/resume and migration commands with
database-target checks.
- Default Kubernetes sandbox callbacks to the internal API Service.
Preserve explicit `ONYX_SERVER_URL` overrides and bump the Helm chart to
0.9.20.
- Update the local Kubernetes guide, Craft development skill, and
feature map.
- Give Helm chart CI a 100 GB runner disk. The previous runner exhausted
disk while unpacking OpenSearch.
- Upgrade the Storybook package family to 10.6.2 to fix the critical
audit finding GHSA-f2ph-cmg5-wxc8.
Existing `.env.k8s` files remain untouched; old service entries continue
to override chart settings. Image refresh updates the PodTemplate for
future sandboxes; existing sandbox pods retain their images.
## Review guide
[Read or download the Markdown review
guide](https://github.com/onyx-dot-app/onyx/blob/d3cbc42d89bfb150d1cfc815638645043c34b69e/docs/craft/dev/kubernetes-review-guide.md).
## How Has This Been Tested?
- Live kind and Telepresence: startup, intercept reuse, doctor, API and
worker hot reload, readiness success/failure, and migration
status/upgrade.
- Three real Craft smoke tests: sandbox provisioning, file
upload/readback, and web app preview through the frontend. No real LLM
calls were exercised.
- 76 Craft Helm tests and 27 development-tool regression tests passed.
- Pre-commit checks, explicit development-tool type checking, frontend
type coverage, and skill validation passed.
- The local web audit passes its critical-severity gate without
suppressions. The Storybook production build passes.
- Removed the disposable test cluster, local processes, and temporary
files.
## Additional Options
- [ ] [Optional] Please cherry-pick this PR to the latest release
version.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Harden local Craft Kubernetes development by sharing configuration and
launch logic between Make and VS Code, and by checking service readiness
before startup reports success.
**What’s included**
- Resolve deployed ConfigMaps, Secrets, and container env in memory
through a shared launcher; personal `.env.k8s` values take precedence,
and resolved secrets never touch disk or terminal output.
- Add shared lifecycle commands (`craft-doctor`, staged
infrastructure/application readiness, Telepresence connect and
intercept, pause, resume, migration, cleanup previews) used by both Make
and VS Code.
- Reuse built images when source is unchanged, force a rebuild with
`--rebuild-sandbox-image`, and keep probe and command invocations
bounded while preserving actionable errors.
- Default sandbox callbacks to the internal API Service, preserving
explicit `ONYX_SERVER_URL` overrides; drop the now-unneeded validation
and bump the Helm chart to 0.9.20.
- Give the Helm CI runner a 100 GB disk, since Docker and kind each
store images and OpenSearch exhausted the default disk. Bump Storybook
tooling to 10.6.2 to patch a development server vulnerability.
- Update the local Kubernetes guide, Craft development skill, feature
map, and add a downloadable PR review guide.
**Validation**
- Passed 76 Craft Helm tests, 27 development-tool regression tests, and
new unit tests for the shared runtime and lifecycle CLI.
- Tested startup, readiness, Telepresence, hot reload, migrations, and
three Craft smoke tests against kind; no real LLM calls were exercised.
<sup>Written for commit d3cbc42d89.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/onyx-dot-app/onyx/pull/16376?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/onyx-dot-app/onyx/16376?returnTo=https%3A%2F%2Fgithub.com%2Fonyx-dot-app%2Fonyx%2Fpull%2F16376&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
- **New Features**
- Added a unified local Kubernetes workflow for Craft, including API and
worker launching, connectivity, readiness checks, migrations,
pause/resume, diagnostics, cleanup, and disk management.
- Added sandbox image reuse, rebuilding, loading, and configurable image
selection.
- Sandbox callbacks now default to the internal API service URL, with
support for explicit overrides.
- **Documentation**
- Added guidance for local Kubernetes setup, configuration, lifecycle
management, troubleshooting, and verification.
- **Bug Fixes**
- Improved readiness validation and stopped sensitive generated
credentials from being printed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
272 lines
12 KiB
YAML
272 lines
12 KiB
YAML
name: Helm - Lint and Test Charts
|
|
concurrency:
|
|
group: Helm-Lint-and-Test-Charts-${{ github.workflow }}-${{ github.head_ref || github.event.workflow_run.head_branch || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
workflow_dispatch: # Allows manual triggering
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
helm-chart-check:
|
|
# See https://runs-on.com/runners/linux/
|
|
runs-on:
|
|
[
|
|
runs-on,
|
|
runner=8cpu-linux-x64,
|
|
# Docker and kind each store images; OpenSearch exhausts the default disk.
|
|
"volume=100gb",
|
|
"run-id=${{ github.run_id }}-helm-chart-check",
|
|
]
|
|
timeout-minutes: 45
|
|
|
|
# fetch-depth 0 is required for helm/chart-testing-action
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # ratchet:actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Set up Helm
|
|
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # ratchet:azure/setup-helm@v5.0.1
|
|
with:
|
|
version: v3.19.0
|
|
|
|
- name: Set up chart-testing
|
|
uses: helm/chart-testing-action@d6db0ca01d3598ea552ccf97edb5de6fe6b54ce0
|
|
with:
|
|
uv_version: "0.11.25"
|
|
|
|
# even though we specify chart-dirs in ct.yaml, it isn't used by ct for the list-changed command...
|
|
# Diff against the PR's own base so a stacked PR only lists its own chart
|
|
# changes. `github.base_ref` is empty outside pull_request, so
|
|
# tag pushes and manual runs fall back to the default branch.
|
|
- name: Run chart-testing (list-changed)
|
|
id: list-changed
|
|
env:
|
|
TARGET_BRANCH: ${{ github.base_ref || github.event.repository.default_branch }}
|
|
run: |
|
|
echo "target_branch: ${TARGET_BRANCH}"
|
|
changed=$(ct list-changed --remote origin --target-branch "${TARGET_BRANCH}" --chart-dirs deployment/helm/charts)
|
|
echo "list-changed output: $changed"
|
|
if [[ -n "$changed" ]]; then
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
# uncomment to force run chart-testing
|
|
# - name: Force run chart-testing (list-changed)
|
|
# id: list-changed
|
|
# run: echo "changed=true" >> $GITHUB_OUTPUT
|
|
# lint all charts if any changes were detected
|
|
- name: Run chart-testing (lint)
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: ct lint --config ct.yaml --all
|
|
# the following would lint only changed charts, but linting isn't expensive
|
|
# run: ct lint --config ct.yaml --target-branch ${{ github.event.repository.default_branch }}
|
|
|
|
- name: Create kind cluster
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # ratchet:helm/kind-action@v1.14.0
|
|
|
|
- name: Pre-install cluster status check
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
echo "=== Pre-install Cluster Status ==="
|
|
kubectl get nodes -o wide
|
|
kubectl get pods --all-namespaces
|
|
kubectl get storageclass
|
|
|
|
- name: Add Helm repositories and update
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
echo "=== Adding Helm repositories ==="
|
|
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
|
|
helm repo add opensearch https://opensearch-project.github.io/helm-charts
|
|
helm repo add cloudnative-pg https://cloudnative-pg.github.io/charts
|
|
helm repo add ot-container-kit https://ot-container-kit.github.io/helm-charts
|
|
helm repo add minio https://charts.min.io/
|
|
helm repo add code-interpreter https://onyx-dot-app.github.io/python-sandbox/
|
|
helm repo update
|
|
|
|
- name: Verify CNPG CRDs are in sync
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
helm dependency build deployment/helm/charts/onyx
|
|
deployment/helm/charts/onyx/scripts/check-cnpg-crds.sh
|
|
|
|
- name: Pre-pull required images
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
echo "=== Pre-pulling required images to avoid timeout ==="
|
|
KIND_CLUSTER=$(kubectl config current-context | sed 's/kind-//')
|
|
echo "Kind cluster: $KIND_CLUSTER"
|
|
|
|
IMAGES=(
|
|
"ghcr.io/cloudnative-pg/cloudnative-pg:1.27.0"
|
|
"quay.io/opstree/redis:v7.0.15"
|
|
"docker.io/onyxdotapp/onyx-web-server:latest"
|
|
)
|
|
|
|
for image in "${IMAGES[@]}"; do
|
|
echo "Pre-pulling $image"
|
|
if docker pull "$image"; then
|
|
kind load docker-image "$image" --name "$KIND_CLUSTER" || echo "Failed to load $image into kind"
|
|
else
|
|
echo "Failed to pull $image"
|
|
fi
|
|
done
|
|
|
|
echo "=== Images loaded into Kind cluster ==="
|
|
docker exec "$KIND_CLUSTER"-control-plane crictl images | grep -E "(cloudnative-pg|redis|onyx)" || echo "Some images may still be loading..."
|
|
|
|
- name: Validate chart dependencies
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
echo "=== Validating chart dependencies ==="
|
|
cd deployment/helm/charts/onyx
|
|
helm dependency update
|
|
# objectstorage ships no defaults (fail closed), so lint must set placeholders.
|
|
helm lint . \
|
|
--set auth.userauth.values.user_auth_secret=placeholder \
|
|
--set auth.objectstorage.values.s3_aws_access_key_id=placeholder \
|
|
--set auth.objectstorage.values.s3_aws_secret_access_key=placeholder \
|
|
--set auth.objectstorage.values.rootUser=placeholder \
|
|
--set auth.objectstorage.values.rootPassword=placeholder
|
|
|
|
- name: Run chart-testing (install) with enhanced monitoring
|
|
timeout-minutes: 25
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
echo "=== Starting chart installation with monitoring ==="
|
|
|
|
# Function to monitor cluster state
|
|
monitor_cluster() {
|
|
while true; do
|
|
echo "=== Cluster Status Check at $(date) ==="
|
|
# Only show non-running pods to reduce noise
|
|
NON_RUNNING_PODS=$(kubectl get pods --all-namespaces --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers 2>/dev/null | wc -l)
|
|
if [ "$NON_RUNNING_PODS" -gt 0 ]; then
|
|
echo "Non-running pods:"
|
|
kubectl get pods --all-namespaces --field-selector=status.phase!=Running,status.phase!=Succeeded
|
|
else
|
|
echo "All pods running successfully"
|
|
fi
|
|
# Only show recent events if there are issues
|
|
RECENT_EVENTS=$(kubectl get events --sort-by=.lastTimestamp --all-namespaces --field-selector=type!=Normal 2>/dev/null | tail -5)
|
|
if [ -n "$RECENT_EVENTS" ]; then
|
|
echo "Recent warnings/errors:"
|
|
echo "$RECENT_EVENTS"
|
|
fi
|
|
sleep 60
|
|
done
|
|
}
|
|
|
|
# Start monitoring in background
|
|
monitor_cluster &
|
|
MONITOR_PID=$!
|
|
|
|
# Set up cleanup
|
|
cleanup() {
|
|
echo "=== Cleaning up monitoring process ==="
|
|
kill $MONITOR_PID 2>/dev/null || true
|
|
echo "=== Final cluster state ==="
|
|
kubectl get pods --all-namespaces
|
|
kubectl get events --all-namespaces --sort-by=.lastTimestamp | tail -20
|
|
}
|
|
|
|
# Trap cleanup on exit
|
|
trap cleanup EXIT
|
|
|
|
# Run the actual installation with detailed logging
|
|
# Note that opensearch.enabled is true whereas others in this install
|
|
# are false. There is some work that needs to be done to get this
|
|
# entire step working in CI, enabling opensearch here is a small step
|
|
# in that direction. If this is causing issues, disabling it in this
|
|
# step should be ok in the short term.
|
|
echo "=== Starting ct install ==="
|
|
set +e
|
|
ct install --all \
|
|
--helm-extra-set-args="\
|
|
--set=nginx.enabled=false \
|
|
--set=minio.enabled=false \
|
|
--set=opensearch.enabled=true \
|
|
--set=auth.opensearch.enabled=true \
|
|
--set=auth.userauth.values.user_auth_secret=test-secret \
|
|
--set=slackbot.enabled=false \
|
|
--set=postgresql.enabled=true \
|
|
--set=postgresql.cluster.storage.storageClass=standard \
|
|
--set=redis.enabled=true \
|
|
--set=redis.storageSpec.volumeClaimTemplate.spec.storageClassName=standard \
|
|
--set=webserver.replicaCount=1 \
|
|
--set=api.replicaCount=0 \
|
|
--set=inferenceCapability.replicaCount=0 \
|
|
--set=indexCapability.replicaCount=0 \
|
|
--set=celery_beat.replicaCount=0 \
|
|
--set=celery_worker_heavy.replicaCount=0 \
|
|
--set=celery_worker_docfetching.replicaCount=0 \
|
|
--set=celery_worker_docprocessing.replicaCount=0 \
|
|
--set=celery_worker_light.replicaCount=0 \
|
|
--set=celery_worker_monitoring.replicaCount=0 \
|
|
--set=celery_worker_primary.replicaCount=0 \
|
|
--set=celery_worker_scheduled_tasks.replicaCount=0 \
|
|
--set=celery_worker_user_file_processing.replicaCount=0 \
|
|
--set=celery_worker_user_files_indexing.replicaCount=0 \
|
|
--set=configMap.DISABLE_TELEMETRY=true" \
|
|
--helm-extra-args="--timeout 900s --debug" \
|
|
--debug --config ct.yaml
|
|
CT_EXIT=$?
|
|
set -e
|
|
|
|
if [[ $CT_EXIT -ne 0 ]]; then
|
|
echo "ct install failed with exit code $CT_EXIT"
|
|
exit $CT_EXIT
|
|
else
|
|
echo "=== Installation completed successfully ==="
|
|
fi
|
|
|
|
kubectl get pods --all-namespaces
|
|
|
|
- name: Post-install verification
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
echo "=== Post-install verification ==="
|
|
if ! kubectl cluster-info >/dev/null 2>&1; then
|
|
echo "ERROR: Kubernetes cluster is not reachable after install"
|
|
exit 1
|
|
fi
|
|
kubectl get pods --all-namespaces
|
|
kubectl get services --all-namespaces
|
|
# Only show issues if they exist
|
|
kubectl describe pods --all-namespaces | grep -A 5 -B 2 "Failed\|Error\|Warning" || echo "No pod issues found"
|
|
|
|
- name: Cleanup on failure
|
|
if: failure() && steps.list-changed.outputs.changed == 'true'
|
|
run: |
|
|
echo "=== Cleanup on failure ==="
|
|
if ! kubectl cluster-info >/dev/null 2>&1; then
|
|
echo "Skipping failure cleanup: Kubernetes cluster is not reachable"
|
|
exit 0
|
|
fi
|
|
echo "=== Final cluster state ==="
|
|
kubectl get pods --all-namespaces
|
|
kubectl get events --all-namespaces --sort-by=.lastTimestamp | tail -10
|
|
|
|
echo "=== Pod descriptions for debugging ==="
|
|
kubectl describe pods --all-namespaces | grep -A 10 -B 3 "Failed\|Error\|Warning\|Pending" || echo "No problematic pods found"
|
|
|
|
echo "=== Recent logs for debugging ==="
|
|
kubectl logs --all-namespaces --tail=50 | grep -i "error\|timeout\|failed\|pull" || echo "No error logs found"
|
|
|
|
echo "=== Helm releases ==="
|
|
helm list --all-namespaces
|
|
# the following would install only changed charts, but we only have one chart so
|
|
# don't worry about that for now
|
|
# run: ct install --target-branch ${{ github.event.repository.default_branch }}
|