Skip to content

Commit 75bb1b5

Browse files
Fix corrupted splunk-operator-3.0.0.tgz and add validation
The splunk-operator-3.0.0.tgz file was corrupted - it contained the full splunk-enterprise chart (4.5MB) instead of just the operator chart (5.8KB). This caused Helm to load a stale splunk-enterprise as a subchart, leading to template rendering errors: Error: INSTALLATION FAILED: template: splunk-enterprise/charts/ splunk-enterprise/templates/enterprise_v4_ingestorcluster.yaml:1:14: executing "splunk-enterprise/charts/splunk-enterprise/templates/ enterprise_v4_ingestorcluster.yaml" at <.Values.ingestorCluster.enabled>: nil pointer evaluating interface {}.enabled Root cause: The file was replaced with a packaged splunk-enterprise chart in multiple "Restore helm chart version 3.0.0" commits (see b9766dd and related commits in git history). Fix: - Restored correct splunk-operator-3.0.0.tgz from commit a3737ba (5.8KB) - File now contains only splunk-operator chart content, not splunk-enterprise Validation: - helm lint passes on both splunk-operator and splunk-enterprise charts - helm template successfully renders c3 deployment without errors - Added tools/validate-helm-charts.sh script to detect future corruption - Added .github/workflows/validate-helm-charts.yml for automated CI validation The validation script checks: - tgz files start with "splunk-operator/" directory (not "splunk-enterprise/") - Files don't contain splunk-enterprise/Chart.yaml content - File sizes are reasonable (detects 4.5MB corruption vs expected 5-400KB) The CI workflow runs on PRs/pushes that touch helm-chart files and validates: - Tgz structure (via validation script) - Helm lint on both charts - Template rendering for common deployment patterns (default, c3, s1) This prevents the corruption from happening again in future PRs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6fad020 commit 75bb1b5

3 files changed

Lines changed: 181 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Validate Helm Charts
2+
permissions:
3+
contents: read
4+
pull-requests: write
5+
on:
6+
pull_request:
7+
paths:
8+
- 'helm-chart/**/*.tgz'
9+
- 'helm-chart/**/Chart.yaml'
10+
- 'helm-chart/**/values.yaml'
11+
- 'tools/validate-helm-charts.sh'
12+
push:
13+
branches:
14+
- main
15+
- develop
16+
paths:
17+
- 'helm-chart/**/*.tgz'
18+
- 'helm-chart/**/Chart.yaml'
19+
- 'helm-chart/**/values.yaml'
20+
- 'tools/validate-helm-charts.sh'
21+
workflow_dispatch:
22+
23+
jobs:
24+
validate-chart-tgz-files:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v2
29+
30+
- name: Validate Helm chart tgz files
31+
run: |
32+
chmod +x tools/validate-helm-charts.sh
33+
./tools/validate-helm-charts.sh
34+
35+
- name: Comment on PR with validation results
36+
if: failure() && github.event_name == 'pull_request'
37+
uses: actions/github-script@v6
38+
with:
39+
script: |
40+
github.rest.issues.createComment({
41+
issue_number: context.issue.number,
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
body: '❌ **Helm Chart Validation Failed**\n\nThe `tools/validate-helm-charts.sh` script detected issues with Helm chart tgz files.\n\nPlease check the workflow logs for details and ensure:\n- Operator chart tgz files contain only `splunk-operator/` content (not `splunk-enterprise/`)\n- File sizes are reasonable (3.x charts ~5-10KB, 2.x charts ~400-430KB)\n- No tgz files over 1MB\n\nSee workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
45+
})
46+
47+
lint-helm-charts:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v2
52+
53+
- name: Install Helm
54+
run: |
55+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
56+
chmod 700 get_helm.sh
57+
DESIRED_VERSION=v3.8.2 bash get_helm.sh
58+
59+
- name: Lint splunk-operator chart
60+
run: |
61+
helm lint helm-chart/splunk-operator
62+
63+
- name: Lint splunk-enterprise chart
64+
run: |
65+
helm lint helm-chart/splunk-enterprise
66+
67+
- name: Test template rendering for common deployments
68+
run: |
69+
# Test default values
70+
helm template test-default helm-chart/splunk-enterprise --dry-run > /dev/null
71+
72+
# Test c3 deployment
73+
helm template test-c3 helm-chart/splunk-enterprise \
74+
--set sva.c3.enabled=true \
75+
--set "sva.c3.indexerClusters[0].name=idx1" \
76+
--set "sva.c3.searchHeadClusters[0].name=shc1" \
77+
--set clusterManager.enabled=true \
78+
--dry-run > /dev/null
79+
80+
# Test s1 deployment
81+
helm template test-s1 helm-chart/splunk-enterprise \
82+
--set sva.s1.enabled=true \
83+
--dry-run > /dev/null
84+
85+
echo "✅ All template rendering tests passed"
-4.54 MB
Binary file not shown.

tools/validate-helm-charts.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
# Validation script for Helm chart tgz files
3+
# This script ensures that splunk-operator chart tgz files contain only the operator chart,
4+
# not the full splunk-enterprise chart (which would cause Helm to load a stale subchart).
5+
6+
set -e
7+
8+
RED='\033[0;31m'
9+
GREEN='\033[0;32m'
10+
YELLOW='\033[1;33m'
11+
NC='\033[0m' # No Color
12+
13+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14+
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
15+
CHARTS_DIR="${REPO_ROOT}/helm-chart/splunk-enterprise/charts"
16+
17+
echo "Validating Helm chart tgz files in ${CHARTS_DIR}"
18+
echo ""
19+
20+
EXIT_CODE=0
21+
22+
# Expected size ranges for operator charts (in KB)
23+
MIN_OPERATOR_SIZE_KB=5 # 3.x charts are ~6-7KB (no CRDs)
24+
MAX_OPERATOR_SIZE_2X_KB=450 # 2.x charts are ~400-430KB (with CRDs)
25+
MAX_OPERATOR_SIZE_3X_KB=10 # 3.x charts should be under 10KB
26+
27+
for TGZ_FILE in "${CHARTS_DIR}"/splunk-operator-*.tgz; do
28+
if [ ! -f "${TGZ_FILE}" ]; then
29+
continue
30+
fi
31+
32+
FILENAME=$(basename "${TGZ_FILE}")
33+
VERSION=$(echo "${FILENAME}" | sed 's/splunk-operator-\(.*\)\.tgz/\1/')
34+
35+
# Get file size in KB
36+
SIZE_BYTES=$(stat -f%z "${TGZ_FILE}" 2>/dev/null || stat -c%s "${TGZ_FILE}" 2>/dev/null)
37+
SIZE_KB=$((SIZE_BYTES / 1024))
38+
39+
echo "Checking ${FILENAME} (${SIZE_KB}KB)..."
40+
41+
# Check contents
42+
FIRST_DIR=$(tar -tzf "${TGZ_FILE}" | head -1 | cut -d'/' -f1)
43+
44+
if [ "${FIRST_DIR}" != "splunk-operator" ]; then
45+
echo -e "${RED}ERROR: ${FILENAME} does not start with 'splunk-operator/' directory${NC}"
46+
echo " Expected: splunk-operator/..."
47+
echo " Got: ${FIRST_DIR}/..."
48+
EXIT_CODE=1
49+
continue
50+
fi
51+
52+
# Check for splunk-enterprise content (should NOT be present)
53+
if tar -tzf "${TGZ_FILE}" | grep -q "splunk-enterprise/Chart.yaml"; then
54+
echo -e "${RED}ERROR: ${FILENAME} contains splunk-enterprise chart content${NC}"
55+
echo " This file appears to be a full splunk-enterprise chart package instead of just the operator chart."
56+
echo " Expected: Only splunk-operator chart files"
57+
echo " Found: splunk-enterprise/Chart.yaml (and likely other splunk-enterprise files)"
58+
EXIT_CODE=1
59+
continue
60+
fi
61+
62+
# Check size is reasonable based on version
63+
MAJOR_VERSION=$(echo "${VERSION}" | cut -d'.' -f1)
64+
65+
if [ "${MAJOR_VERSION}" = "3" ]; then
66+
# 3.x charts removed CRDs, should be small
67+
if [ ${SIZE_KB} -gt ${MAX_OPERATOR_SIZE_3X_KB} ]; then
68+
echo -e "${YELLOW}WARNING: ${FILENAME} is larger than expected for 3.x (${SIZE_KB}KB > ${MAX_OPERATOR_SIZE_3X_KB}KB)${NC}"
69+
echo " 3.x operator charts should not include CRDs and should be under 10KB"
70+
fi
71+
elif [ "${MAJOR_VERSION}" = "2" ]; then
72+
# 2.x charts included CRDs, larger but still not huge
73+
if [ ${SIZE_KB} -gt ${MAX_OPERATOR_SIZE_2X_KB} ]; then
74+
echo -e "${YELLOW}WARNING: ${FILENAME} is larger than expected for 2.x (${SIZE_KB}KB > ${MAX_OPERATOR_SIZE_2X_KB}KB)${NC}"
75+
fi
76+
fi
77+
78+
# Size sanity check - anything over 1MB is definitely wrong (4.5MB was the corrupted file)
79+
if [ ${SIZE_KB} -gt 1024 ]; then
80+
echo -e "${RED}ERROR: ${FILENAME} is suspiciously large (${SIZE_KB}KB)${NC}"
81+
echo " This likely contains the full splunk-enterprise chart instead of just the operator chart"
82+
EXIT_CODE=1
83+
continue
84+
fi
85+
86+
echo -e "${GREEN}${FILENAME} validated successfully${NC}"
87+
echo ""
88+
done
89+
90+
if [ ${EXIT_CODE} -eq 0 ]; then
91+
echo -e "${GREEN}All Helm chart tgz files validated successfully!${NC}"
92+
else
93+
echo -e "${RED}Validation failed! Please fix the issues above.${NC}"
94+
fi
95+
96+
exit ${EXIT_CODE}

0 commit comments

Comments
 (0)