Skip to content

Commit 38c14a5

Browse files
chore: Address all 86 review items from Go operator rewrite PR (#275)
* chore: add agentic workflow directories to gitignore Add .windsurf/, .planning/, .specify/, specs/, CLAUDE.md, and GEMINI.md to gitignore to exclude AI-assisted development workflow files and specifications from version control. * docs: initialize project Comprehensive fix pass on Go operator rewrite (PR #274) — addressing all 9 critical, ~25 major, and 50+ minor issues from 8 expert reviewers, plus repo restructuring. * chore: remove tracked planning docs (now gitignored) * test(01-01): add failing tests for extraArgs wiring and conflict detection - Add tests for BuildMasterCommand with extraArgs - Add tests for BuildWorkerCommand with extraArgs - Add tests for detectFlagConflicts function - Add tests for conflict warning logging - Update existing tests to pass new logger parameter - Tests currently fail (RED phase) - functions not yet implemented * feat(01-01): implement extraArgs wiring with conflict detection - Add operatorManagedFlags registry containing all operator-controlled flags - Implement detectFlagConflicts function to identify conflicting extraArgs - Wire extraArgs into BuildMasterCommand with conflict warning logging - Wire extraArgs into BuildWorkerCommand with conflict warning logging - Update BuildMasterJob and BuildWorkerJob to accept logger parameter - Update controller to pass logger to job builders - Update all test calls to pass logger parameter - ExtraArgs are appended after operator-managed flags (POSIX last-wins) - All tests now pass (GREEN phase complete) * test(01-02): add failing tests for safe resource parsing RED Phase - Add tests for: - LoadConfig() returns error for invalid resource quantities - Multiple invalid values are collected and reported - Valid resource quantities pass validation - Empty resource strings are treated as optional All existing LoadConfig() call sites updated to handle error return. * feat(01-02): implement safe resource parsing and CR precedence GREEN Phase - Implementation: 1. Config validation (config.go): - LoadConfig() now returns (*OperatorConfig, error) - validateResourceQuantities() checks all resource env vars - Invalid values produce clear error messages - Multiple invalid values collected and reported together - Empty strings treated as optional (not validated) 2. Safe parsing (job.go): - Replace resource.MustParse() with resource.ParseQuantity() - Safe because values pre-validated at startup - buildResourceList() now uses ParseQuantity with error ignored 3. Resource precedence (job.go): - buildResourceRequirementsWithPrecedence() implements CR → defaults - hasResourcesSpecified() helper distinguishes nil vs empty - CR resources are complete override (not partial merge) - buildLocustContainer() uses new precedence function 4. Main error handling (main.go): - Handles LoadConfig error, logs and exits with code 1 - Clear error messages on startup failure 5. Test updates (suite_test.go): - Controller test suite handles new LoadConfig error return All tests pass. No MustParse in production code. * feat(01-03): add Helm masterResources and workerResources fields - Add masterResources and workerResources to values.yaml (default empty) - Add 12 helper templates in _helpers.tpl for role-specific resources - Add conditional env vars in deployment.yaml (via envVars helper) - Empty resources means 'use unified resources' (backward compatible) - Helm lint passes, default rendering excludes role-specific env vars * test(01-03): add integration tests for extraArgs and resource precedence - Add 7 integration tests for BuildMasterJob/BuildWorkerJob - Test extraArgs appear in generated Job command - Test CR resources override operator defaults - Test empty CR resources fall back to defaults - Test master/worker resources are independent - All tests pass, verify full Phase 1 wiring works end-to-end * test(01-04): add failing tests for role-specific resource precedence Add tests for 3-level resource precedence (CR > role-specific > unified): - TestLoadConfig_RoleSpecificResourceDefaults: Verify 12 fields default to empty - TestLoadConfig_RoleSpecificResourceOverrides: Verify env vars are loaded - TestLoadConfig_InvalidRoleSpecificResource: Verify validation errors - TestBuildMasterJob_WithHelmMasterResources: Verify master-specific overrides unified - TestBuildWorkerJob_WithHelmWorkerResources: Verify worker-specific overrides unified - TestBuildMasterJob_CROverridesHelmRoleSpecific: Verify CR wins over role-specific - TestBuildMasterJob_HelmRoleSpecific_PrecedenceOverUnified: Verify field-level fallback Tests fail to compile (RED phase) - fields don't exist yet. * feat(01-04): implement role-specific config and 3-level resource precedence Complete the three-level resource precedence chain: - Level 1: CR-level resources (complete override, highest precedence) - Level 2: Role-specific operator config (from Helm masterResources/workerResources) - Level 3: Unified operator defaults (from Helm resources) Config changes: - Add 12 role-specific fields to OperatorConfig (6 master, 6 worker) - LoadConfig reads MASTER_POD_* and WORKER_POD_* env vars with empty defaults - validateResourceQuantities validates non-empty role-specific values Job changes: - buildResourceRequirementsWithPrecedence implements 3-level precedence - Field-level fallback: empty role-specific → unified (backward compatible) - CR resources remain complete override (not partial merge) All tests pass (GREEN phase complete). * fix(02-01): remove MutatingWebhookConfiguration for CRD conversion - Remove MutatingWebhookConfiguration block (lines 60-90) - CRD conversion uses spec.conversion.webhook on CRD, not admission webhook - Keep ValidatingWebhookConfiguration for CR validation (correct) - Keep webhook Service for routing API server traffic - Update comments to clarify conversion is handled by CRD spec - controller-runtime serves /convert endpoint automatically * fix(02-01): add emptyDir /tmp volume and fix replicaCount default - Add tmp emptyDir volume at /tmp for controller-runtime temp files - Webhook certs mount overlays at subdirectory /tmp/k8s-webhook-server/serving-certs - readOnlyRootFilesystem: true now works with webhook server - Change replicaCount default from 2 to 1 (backward compatible with Java operator) - Update comment to recommend 2+ replicas with leader election for HA - No volumes/mounts when webhooks disabled (clean default install) * feat(02-02): tighten RBAC to least privilege with conditional Leases - ConfigMaps/Secrets reduced to read-only (get, list, watch) - Jobs reduced to immutable pattern (get, list, watch, create, delete) - Services reduced to create/delete lifecycle (no update/patch) - Leases conditional on leaderElection.enabled flag - Leases verbs reduced (removed delete, kept get/list/watch/create/update/patch) - Updated header comments to reflect read-only and immutable patterns * feat(02-02): fix backward compatibility helpers to check leaf values - Changed all helpers from checking parent keys to checking full path with leaf values - Pod resources: Check .Values.locustPods.resources.requests.cpu exists (not just .Values.locustPods) - Boolean helpers (affinity, tolerations): Use hasKey to handle false values correctly - TTL helper: Check actual ttlSecondsAfterFinished value exists - Metrics exporter: Check full nested path for image, port, pullPolicy, and resources - Kafka: Check bootstrapServers and security.enabled with full paths - Updated header comment to explain leaf-value checking precedence - Enables true backward compat: old config paths work when new paths are absent * feat(02-03): add optional PodDisruptionBudget and remove no-op crd.install - Add PDB template (disabled by default per user decision) - Add podDisruptionBudget config section to values.yaml - Remove crd.install no-op value (Helm crds/ always installs unconditionally) - PDB supports HA deployments with replicaCount >= 2 * fix(02-03): replace CRD symlink with actual file for helm package compatibility - Remove symlink to ../../locust-k8s-operator-go/config/crd/bases - Copy locust.io_locusttests.yaml directly into charts/crds/ - Fixes helm package in CI environments where symlink target may not resolve * refactor(03-01): unify volume name constant and fix mount path trailing slash - Changed libVolumeName from "locust-lib" to "lib" in webhook to match resources package - Removed trailing slash from DefaultMountPath ("/lotest/src/" → "/lotest/src") - Updated test to validate "lib" instead of "locust-lib" - Both packages now use "lib" as the canonical lib volume name * feat(03-02): remove generation guard and implement phase-based reconciliation - Remove Generation > 1 NO-OP guard from reconciler - Phase-based state machine now drives all reconciliation - Pending phase creates resources regardless of generation number - Add V(1) info message for generation > 1 (informational only) - Rewrite tests to verify phase-based behavior - Fixes operator-restart edge case where modified-but-unprocessed CRs would never get resources created * feat(03-02): suppress Prometheus annotations when OTel is enabled - Add IsOTelEnabled check to BuildAnnotations for master pods - When OTel is enabled, Locust exports metrics natively via OTLP - No sidecar container or Prometheus scrape annotations needed with OTel - Pattern matches existing OTel suppression in service.go and job.go - Add test TestBuildAnnotations_Master_NoPrometheusWhenOTelEnabled - Rename existing test for clarity * feat(03-03): detect externally deleted resources and self-heal - Check for missing Service, master Job, and worker Job during reconcileStatus - Reset Phase to Pending when resources are externally deleted - Emit Warning event with descriptive message - Pending phase triggers createResources on next reconcile (self-healing loop) - Standard controller-runtime requeue handles exponential backoff * test(03-03): add external deletion detection and recovery tests - TestReconcile_ExternalDeletion_MasterService: verify Service deletion triggers recovery - TestReconcile_ExternalDeletion_MasterJob: verify master Job deletion triggers recovery - TestReconcile_ExternalDeletion_WorkerJob: verify worker Job deletion triggers recovery - All tests verify Warning event emission, Phase reset to Pending, and self-healing recreation - Full test suite passes (21/21 controller integration tests) * fix(04-01): correct publish-image job — ko path, version, permissions, timeout - Fix ko build path from ./cmd/main.go to ./cmd (CICD-01) - Align ko version to @v0.7 matching ci.yaml (CICD-02) - Remove unnecessary packages: write permission (CICD-12) - Add timeout-minutes: 30 for job reliability (CICD-03) * feat(04-01): enforce release ordering and replace chart-releaser fork - Replace askcloudarchitech fork with upstream helm/chart-releaser-action@v1 (CICD-05) - Add needs: [publish-image] to helm-chart-release for proper ordering - Add timeout-minutes: 15 to helm-chart-release (CICD-03) - Add timeout-minutes: 15 to docs-release (CICD-03) - Remove stale comments about upstream PR - Keep docs-release independent for parallel execution * feat(04-02): parallelize CI jobs, add timeouts, fix ct.yaml timeout - Remove needs: dependencies from lint-test-helm and docs-test jobs - Jobs now run in parallel (build-go, lint-test-helm, docs-test) - Add timeout-minutes: 30 to build-go and lint-test-helm jobs - Add timeout-minutes: 15 to docs-test job - Increase ct.yaml helm timeout from 120s to 300s for operator deployments * feat(04-02): add artifact uploads on CI job failures - Upload Go test artifacts (cover.out) on build-go failure - Upload kind cluster logs on lint-test-helm failure - Upload docs build output (site/) on docs-test failure - All artifacts retained for 7 days * feat(04-03): overhaul E2E workflow with security and reliability fixes - Add permissions: read-all for least privilege (CICD-06) - Replace manual Kind download with helm/kind-action@v1.12.0 (CICD-07) - Add go mod tidy verification check on go.mod and go.sum (CICD-08) - Add timeout-minutes: 30 to prevent runaway jobs (CICD-03) - Add artifact upload on failure for debugging (CICD-11) * chore(04-03): remove dead nested workflow files - Remove locust-k8s-operator-go/.github/workflows/lint.yml - Remove locust-k8s-operator-go/.github/workflows/test.yml - Remove locust-k8s-operator-go/.github/workflows/test-e2e.yml These workflows are dead code - GitHub Actions only reads from repo root .github/workflows/. The nested workflows were leftover from when the Go operator was a standalone repository. All functionality is covered by root-level ci.yaml, go-test-e2e.yml, and release.yaml. * fix(05-01): fix imagePullSecrets format and reframe Kafka docs - Fix imagePullSecrets to use LocalObjectReference format (- name: gcr-secret) - Reframe Kafka section to explain two-level config model - Document operator-level centralized configuration approach - Document per-test override capability - Remove deprecated framing from Kafka documentation * fix(05-01): fix metrics.secure comment and replace jaeger with otlphttp - Correct metrics.secure comment to state default is false - Replace deprecated jaeger exporter with otlphttp in OTel collector config - Update exporter endpoint to http://jaeger-collector:4318 (OTLP HTTP) * docs(05-02): fix status example and update copyright/roadmap - Replace non-existent masterJob/workerJob fields with actual status fields - Add expectedWorkers, connectedWorkers, startTime, conditions - Update copyright year from 2025 to 2026 - Delete stale roadmap.md file - Remove roadmap from mkdocs.yml navigation * docs(05-02): fix README framework reference - Change "Operator SDK" to "controller-runtime" in comparison table - Removes ambiguity (Operator SDK could mean CLI tool or framework) - controller-runtime is the actual framework used (verified in go.mod) * docs(05-03): standardize namespaces, add missing image field, fix CPU limit - helm_deploy.md: add --namespace locust-system --create-namespace to all install examples - getting_started.md: add missing image field to v2 lib configmap example - migration.md: fix operator CPU limit from 100m to 500m (matches values.yaml) Fixes: DOCS-02, DOCS-04, DOCS-06 * docs(05-03): remove subdirectory references and fix working dir instructions - Remove all locust-k8s-operator-go/ subdirectory references across docs - Update local-development.md with note about dev vs production namespaces - Update integration-testing.md directory tree to show repo root structure - Update pull-request-process.md to remove subdirectory path reference - Simplify Kind cluster name in integration-testing.md Fixes: DOCS-05, DOCS-12 * fix(06-02): remove os.Chdir side effect and fix E2E label selectors - Remove os.Chdir from test/utils/utils.go (global side effect causing test interference) - Fix E2E conversion script to use correct label selectors (performance-test-pod-name) - Replace app=locust-master/worker with performance-test-pod-name=<name>-master/worker * feat(06-01): add typed Phase enum, ObservedGeneration, and phase transition events - Define Phase as typed enum (type Phase string) for compile-time safety - Add ObservedGeneration field to LocustTestStatus for controller progress tracking - Update derivePhaseFromJob to return typed Phase - Add phase transition event recording (TestStarted, TestCompleted, TestFailed) - Update ObservedGeneration on all status updates in controller - Document ConnectedWorkers as approximation from Job.Status.Active - Remove unused RestartPolicyNever constant (code uses corev1.RestartPolicyNever) - Remove unused LocustContainerName constant * feat(06-04): add Helm chart metadata, schema validation, and NOTES.txt - Add Chart.yaml metadata: kubeVersion, home, sources, maintainers - Add fullnameOverride and nameOverride support in values and _helpers.tpl - Add extraEnv support for custom operator environment variables - Add terminationGracePeriodSeconds configuration - Add configurable podSecurityContext and containerSecurityContext - Add health_check extension to OTel Collector config - Create values.schema.json for Helm value validation - Create NOTES.txt with post-install instructions and examples * feat(06-04): add health probes, Kafka gating, and deployment configurability - Add terminationGracePeriodSeconds to deployment from values - Use configurable podSecurityContext and containerSecurityContext - Add extraEnv support to deployment env section - Gate Kafka environment variables behind kafka.enabled condition - Add ConfigMap checksum annotation to OTel Collector for auto-rollout - Add liveness and readiness HTTP probes on port 13133 to OTel Collector - Add health port (13133) to OTel Collector container ports * test(06-02): add webhook update tests, boundary tests, and v2 fixtures - Add TestValidateUpdate_Invalid for webhook update validation (secret mounts, volumes, OTel) - Add TestValidateCreate_LongCRName boundary test for CR name length validation - Add validateCRName function to enforce 63-char limit on generated resource names - Create locusttest-with-scheduling.yaml E2E fixture with affinity and tolerations - Add LoadV2Fixture/MustLoadV2Fixture functions for v2 test fixtures - Create locusttest_v2_full.json comprehensive v2 fixture * test(06-01): add comprehensive status transition tests and fix Phase type in tests - Add TestUpdateStatusFromJobs_FullStateMachine covering all phase transitions - Add TestUpdateStatusFromJobs_PhaseTransitionEvents verifying event emission - Add TestUpdateStatusFromJobs_NoEventOnSamePhase for idempotency verification - Add TestUpdateStatusFromJobs_ObservedGeneration verifying generation tracking - Add TestDerivePhaseFromJob_TypeSafety verifying typed Phase return - Add TestUpdateStatusFromJobs_WorkersConnectedCondition for worker tracking - Fix existing tests to use typed Phase (string conversion for comparisons) - Update CRD manifests for ObservedGeneration field * test(06-06): remove v1 webhook unused logger and add OTel integration tests - Remove unused logf import and blank identifier assignment in api/v1/locusttest_webhook.go - Add comprehensive OTel integration tests in internal/resources/env_test.go - TestBuildEnvVars_WithOTel_Enabled: verifies OTel env vars correctly merged with Kafka and user vars - TestBuildEnvVars_WithOTel_Disabled: verifies no OTel vars when disabled - TestBuildEnvVars_WithOTel_NoObservabilityConfig: verifies no OTel vars when config absent - TestBuildEnvVars_OTel_HTTPProtocol: verifies HTTP protocol support - TestBuildEnvVars_OTel_EnvVarOrder: verifies correct precedence (Kafka, OTel, user) Note: PDB template was already implemented in a previous phase * feat(06-03): add gosec, errorlint, exhaustive linters and wrap reconciler errors - Add gosec, errorlint, exhaustive linters to .golangci.yml - Configure errorlint with all checks enabled - Configure exhaustive with strict mode (default-signifies-exhaustive: false) - Add error wrapping with %w to all reconciler error returns - Add PhasePending case to switch statement (exhaustive requirement) - Fix gofmt formatting in config.go - Add justified nolint:gosec directives for test code with known safe inputs * refactor(06-03): move BuildKafkaEnvVars to env.go and replace custom string helpers - Move BuildKafkaEnvVars function from job.go to env.go for logical grouping - Move strconv import from job.go to env.go (only used by BuildKafkaEnvVars) - Replace custom contains()/containsHelper() with stdlib strings.Contains() - Add strings import to controller unit test * refactor(06-05): extract main.go helpers and update leader election ID - Extract parseFlags helper for command-line flag parsing - Extract configureTLS helper for TLS options - Extract setupWebhookServer helper for webhook configuration - Extract setupMetricsServer helper for metrics configuration - Extract setupControllers helper for controller registration - Extract setupHealthChecks helper for health probes - Remove nolint:gocyclo directive (no longer needed) - Change leader election ID to locust-k8s-operator.locust.io (CORE-27) * chore(06-05): update project metadata, dockerfile, build files, and RBAC - Update PROJECT file to track v2 API (CORE-21) - Pin Dockerfile golang version to 1.24.0 (CORE-23) - Add comprehensive .dockerignore for build optimization (CORE-18) - Add cover.out, coverage.out, venv/ to .gitignore (CORE-20) - Remove create/delete verbs from locusttests RBAC (CORE-28) - Remove finalizers permission from RBAC (CORE-29) - Update kubebuilder RBAC markers in controller - Add map ordering comment to buildNodeSelector (CORE-15) * chore(07-01): remove legacy Java operator code and build files - Remove all Java source code (src/) - Remove Gradle build system (build.gradle, gradle/, gradlew, settings.gradle) - Remove Java tooling config (lombok.config, micronaut-cli.yml) - Remove legacy Kubernetes manifests (kube/) - Remove old integration scripts (scripts/) - Remove legacy planning directories (issue-analysis/, v2/) - Remove build artifacts (build/, .gradle/) Archive branch archive/java-operator-v1 preserves Java code from master. Go operator in locust-k8s-operator-go/ remains intact. * refactor(07-02): move Go operator code from subdirectory to repository root Move all Go operator files from locust-k8s-operator-go/ to repository root using git mv to preserve file history. The Go operator is now the primary codebase and belongs at the root level. Files moved: - Go module (go.mod, go.sum) - Source code (cmd/, api/, internal/, test/) - Build system (Makefile, Dockerfile, PROJECT) - Config (config/, hack/, .golangci.yml, .dockerignore) - DevContainer (.devcontainer/) Files removed: - locust-k8s-operator-go/README.md (root README is canonical) - locust-k8s-operator-go/.gitignore (will merge in Plan 03) - Build artifacts (bin/, venv/, *.out) * chore(07-03): update CI/CD workflows, Makefile, PROJECT, and gitignore for root-level structure - Remove working-directory from build-go job in ci.yaml - Update go-version-file paths from locust-k8s-operator-go/go.mod to go.mod - Remove working-directory from golangci-lint and ko build steps - Update artifact paths to reference root-level cover.out - Update E2E workflow path filters to trigger on root-level Go directories - Change Makefile IMAGE_TAG_BASE to io/locust-k8s-operator (remove -go) - Change Makefile KIND_CLUSTER to locust-k8s-operator-test-e2e - Update buildx builder name to locust-k8s-operator-builder - Change PROJECT projectName to locust-k8s-operator - Replace root .gitignore with merged Go and project entries * chore(07-03): update all config manifests and E2E tests to use locust-k8s-operator - Change namespace from locust-k8s-operator-go-system to locust-k8s-operator-system - Update namePrefix in config/default/kustomization.yaml - Update all resource names, labels, and references across config/ manifests - Update E2E test constants: namespace, serviceAccountName, metricsServiceName - Update projectImage reference in e2e_suite_test.go - Update clusterrole name in metrics test - Change CSV filename reference in config/manifests/kustomization.yaml - All config and test files now use standard locust-k8s-operator naming * docs(07-04): add MIGRATION.md, SECURITY.md, .editorconfig, update README - Create MIGRATION.md documenting Java-to-Go transition with archive branch reference - Create SECURITY.md with vulnerability reporting policy - Create .editorconfig with Go and YAML formatting standards - Update README.md to reflect Go operator (remove Java usage instructions) - Update .pre-commit-config.yaml to remove Java-specific hooks (gradle-check, gradle-spotless) - Update .cz.yaml to remove build.gradle reference and set version to 2.0.0 * chore: fix struct alignment and update test CRD with observedGeneration * chore(07-04): remove DevContainer configuration files - Remove .devcontainer/devcontainer.json - Remove .devcontainer/post-install.sh * chore(06-05): optimize requeue timing, preallocate slice, and improve code clarity - Change Requeue: true to RequeueAfter: time.Second for resource deletion detection - Update unit tests to assert RequeueAfter > 0 instead of Requeue == true - Preallocate formatErrors slice with capacity for better performance - Replace if-else chain with switch statement in buildResourceRequirementsWithPrecedence - Move github.com/go-logr/logr from indirect to direct dependency * chore(06-05): fix line length formatting in main.go flag parsing and metrics setup - Wrap metrics-cert-name flag description to comply with line length limits - Add nolint:lll directive to setupMetricsServer function signature * test(06-05): add nolint directive for intentional type assertion in status test * chore: exclude goconst linter from test files in golangci-lint config * chore: standardize lib volume name and improve status/flag handling - Rename lib volume from "lib" to "locust-lib" for clarity - Add cluster_name to E2E workflow Kind cluster creation - Fix StartTime to only set on first creation (preserve across reconciles) - Add Ready=false status when test fails - Add WorkersConnected=false condition when workers missing - Fix flag conflict detection to match exact flags (not just prefixes) - Update all tests to reflect locust-lib volume name * test(e2e): fix testdata directory path to use relative path - Change testdata path from "test/e2e/testdata" to "testdata" in all E2E tests - Update locusttest_e2e_test.go, otel_e2e_test.go, v1_compatibility_test.go, and validation_e2e_test.go
1 parent 2a65954 commit 38c14a5

File tree

295 files changed

+8148
-36816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+8148
-36816
lines changed

.cz.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
---
22
commitizen:
33
annotated_tag: true
4-
bump_message: "bump(release): v$current_version \u2192 v$new_version"
4+
bump_message: "bump(release): v$current_version v$new_version"
55
name: cz_conventional_commits
66
tag_format: $major.$minor.$patch$prerelease
77
update_changelog_on_bump: true
8-
version: 1.1.1
8+
version: 2.0.0
99
version_files:
10-
- build.gradle:version
1110
- charts/locust-k8s-operator/Chart.yaml:appVersion
1211
- charts/locust-k8s-operator/Chart.yaml:version

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
3+
# Test files
4+
test/
5+
*_test.go
6+
7+
# Documentation
8+
docs/
9+
*.md
10+
LICENSE
11+
12+
# Git
13+
.git/
14+
.gitignore
15+
16+
# IDE
17+
.idea/
18+
.vscode/
19+
20+
# CI
21+
.github/
22+
.golangci.yml
23+
24+
# Build artifacts
25+
bin/
26+
cover.out
27+
coverage.out
28+
29+
# Planning
30+
.planning/
31+
32+
# Python
33+
venv/
34+
__pycache__/

.editorconfig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
9+
[*.go]
10+
indent_style = tab
11+
indent_size = 4
12+
13+
[*.{yaml,yml}]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[*.{md,markdown}]
18+
trim_trailing_whitespace = false
19+
20+
[Makefile]
21+
indent_style = tab
22+
23+
[Dockerfile]
24+
indent_style = space
25+
indent_size = 4
26+
27+
[*.sh]
28+
indent_style = space
29+
indent_size = 2

.github/ct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
debug: true
22
validate-maintainers: false
3-
helm-extra-args: --timeout 120s
3+
helm-extra-args: --timeout 300s

.github/workflows/ci.yaml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ jobs:
2020
build-go:
2121
name: 🏗️ Build Go Operator
2222
runs-on: ubuntu-latest
23-
defaults:
24-
run:
25-
working-directory: locust-k8s-operator-go
23+
timeout-minutes: 30
2624
steps:
2725
- name: 📂 Checkout repo
2826
uses: actions/checkout@v4
@@ -33,7 +31,7 @@ jobs:
3331
- name: 🔧 Setup Go
3432
uses: actions/setup-go@v5
3533
with:
36-
go-version-file: locust-k8s-operator-go/go.mod
34+
go-version-file: go.mod
3735

3836
- name: 📥 Download dependencies
3937
run: go mod download
@@ -42,7 +40,6 @@ jobs:
4240
uses: golangci/golangci-lint-action@v8
4341
with:
4442
version: v2.1.0
45-
working-directory: locust-k8s-operator-go
4643

4744
- name: 🛠️ Build
4845
run: make build
@@ -54,19 +51,27 @@ jobs:
5451
if: always()
5552
uses: codecov/codecov-action@v5
5653
with:
57-
files: locust-k8s-operator-go/cover.out
54+
files: cover.out
5855
flags: go-unit-tests
5956
name: go-coverage
6057
fail_ci_if_error: false
6158

59+
- name: 📦 Upload Go test artifacts on failure
60+
if: failure()
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: go-test-artifacts
64+
path: |
65+
cover.out
66+
retention-days: 7
67+
6268
# ============================================
6369
# Helm Chart Lint & Test
6470
# ============================================
6571
lint-test-helm:
6672
name: 🌊 Lint & Test chart
6773
runs-on: ubuntu-latest
68-
needs:
69-
- build-go
74+
timeout-minutes: 30
7075
steps:
7176
- name: 📂 Checkout
7277
uses: actions/checkout@v4
@@ -108,19 +113,18 @@ jobs:
108113
if: steps.list-changed.outputs.changed == 'true'
109114
uses: actions/setup-go@v5
110115
with:
111-
go-version-file: locust-k8s-operator-go/go.mod
116+
go-version-file: go.mod
112117

113118
- name: 🛠️ Install ko
114119
if: steps.list-changed.outputs.changed == 'true'
115120
uses: ko-build/setup-ko@v0.7
116121

117122
- name: 🐳 Build operator image with ko
118123
if: steps.list-changed.outputs.changed == 'true'
119-
working-directory: locust-k8s-operator-go
120124
env:
121125
KO_DOCKER_REPO: lotest/locust-k8s-operator
122126
run: |
123-
CHART_VERSION=$(grep '^appVersion:' ../charts/locust-k8s-operator/Chart.yaml | awk '{print $2}' | tr -d '"')
127+
CHART_VERSION=$(grep '^appVersion:' charts/locust-k8s-operator/Chart.yaml | awk '{print $2}' | tr -d '"')
124128
ko build ./cmd --local --bare --tags=${CHART_VERSION}
125129
126130
- name: 📦 Load image into kind cluster
@@ -132,11 +136,23 @@ jobs:
132136
- name: 🚀 Run chart-testing (install)
133137
run: ct install --target-branch ${{ github.event.repository.default_branch }} --config .github/ct.yaml --helm-extra-set-args "--set=image.pullPolicy=Never"
134138

139+
- name: 📦 Collect kind cluster logs on failure
140+
if: failure() && steps.list-changed.outputs.changed == 'true'
141+
run: kind export logs kind-logs --name chart-testing
142+
143+
- name: 📦 Upload Helm test artifacts on failure
144+
if: failure() && steps.list-changed.outputs.changed == 'true'
145+
uses: actions/upload-artifact@v4
146+
with:
147+
name: helm-test-artifacts
148+
path: |
149+
kind-logs/
150+
retention-days: 7
151+
135152
docs-test:
136153
name: 📚 Test documentation
137154
runs-on: ubuntu-latest
138-
needs:
139-
- lint-test-helm
155+
timeout-minutes: 15
140156
steps:
141157
- name: 📂 Checkout
142158
uses: actions/checkout@v4
@@ -161,3 +177,12 @@ jobs:
161177
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162178
run: |
163179
python -m mkdocs build
180+
181+
- name: 📦 Upload docs build artifacts on failure
182+
if: failure()
183+
uses: actions/upload-artifact@v4
184+
with:
185+
name: docs-build-artifacts
186+
path: |
187+
site/
188+
retention-days: 7

.github/workflows/go-test-e2e.yml

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,58 @@ on:
44
push:
55
branches: [main, master]
66
paths:
7-
- 'locust-k8s-operator-go/**'
7+
- 'cmd/**'
8+
- 'api/**'
9+
- 'internal/**'
10+
- 'test/**'
11+
- 'go.mod'
12+
- 'go.sum'
13+
- 'Makefile'
814
pull_request:
915
paths:
10-
- 'locust-k8s-operator-go/**'
16+
- 'cmd/**'
17+
- 'api/**'
18+
- 'internal/**'
19+
- 'test/**'
20+
- 'go.mod'
21+
- 'go.sum'
22+
- 'Makefile'
1123

12-
defaults:
13-
run:
14-
working-directory: locust-k8s-operator-go
24+
permissions: read-all
1525

1626
jobs:
1727
test-e2e:
1828
name: 🎯 Run E2E Tests
1929
runs-on: ubuntu-latest
30+
timeout-minutes: 30
2031
steps:
2132
- name: 📥 Clone the code
2233
uses: actions/checkout@v4
2334

2435
- name: 🔧 Setup Go
2536
uses: actions/setup-go@v5
2637
with:
27-
go-version-file: locust-k8s-operator-go/go.mod
38+
go-version-file: go.mod
2839

29-
- name: ☸️ Install the latest version of kind
30-
run: |
31-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
32-
chmod +x ./kind
33-
sudo mv ./kind /usr/local/bin/kind
34-
35-
- name: ✔️ Verify kind installation
36-
run: kind version
40+
- name: ☸️ Create Kind cluster
41+
uses: helm/kind-action@v1.12.0
42+
with:
43+
cluster_name: locust-k8s-operator-test-e2e
44+
wait: 120s
3745

38-
- name: 🎯 Running Test e2e
46+
- name: 🔍 Verify go mod tidy
3947
run: |
4048
go mod tidy
41-
make test-e2e
49+
git diff --exit-code -- go.mod go.sum
50+
51+
- name: 🎯 Run E2E tests
52+
run: make test-e2e
53+
54+
- name: 📦 Upload E2E test artifacts on failure
55+
if: failure()
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: e2e-test-artifacts
59+
path: |
60+
cover.out
61+
retention-days: 7

.github/workflows/release.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
publish-image:
1515
name: 🐳 Publish image
1616
runs-on: ubuntu-latest
17+
timeout-minutes: 30
1718
permissions:
1819
contents: read
19-
packages: write
2020
env:
2121
DOCKER_IMAGE: lotest/locust-k8s-operator
2222
steps:
@@ -26,10 +26,10 @@ jobs:
2626
- name: 🔧 Setup Go
2727
uses: actions/setup-go@v5
2828
with:
29-
go-version-file: locust-k8s-operator-go/go.mod
29+
go-version-file: go.mod
3030

3131
- name: 🔧 Setup ko
32-
uses: ko-build/setup-ko@v0.6
32+
uses: ko-build/setup-ko@v0.7
3333

3434
- name: 🔐 Login to Docker Hub
3535
uses: docker/login-action@v3
@@ -38,18 +38,19 @@ jobs:
3838
password: ${{ secrets.DOCKERHUB_TOKEN }}
3939

4040
- name: 📦 Build and push with ko
41-
working-directory: locust-k8s-operator-go
4241
env:
4342
KO_DOCKER_REPO: ${{ env.DOCKER_IMAGE }}
4443
run: |
45-
ko build ./cmd/main.go \
44+
ko build ./cmd \
4645
--platform=linux/amd64,linux/arm64 \
4746
--bare \
4847
--tags=${{ github.ref_name }},latest,${{ github.sha }}
4948
5049
helm-chart-release:
5150
name: 🌊 Publish Helm chart
5251
runs-on: ubuntu-latest
52+
timeout-minutes: 15
53+
needs: [publish-image]
5354
permissions:
5455
contents: write
5556
steps:
@@ -76,9 +77,7 @@ jobs:
7677
helm package charts/locust-k8s-operator --app-version=${VERSION} --version=${VERSION} --destination=.cr-release-packages
7778
7879
- name: 🎉 Run chart-releaser
79-
# switch back to helm/chart-releaser-action when https://github.com/helm/chart-releaser-action/pull/109 is merged
80-
# Waiting for a new release to include changes coming from https://github.com/helm/chart-releaser-action/commit/38cfeacdbbd62d13ec773fcdee1435ff5846c554
81-
uses: askcloudarchitech/chart-releaser-action@skip-packaging-option
80+
uses: helm/chart-releaser-action@v1
8281
with:
8382
skip_packaging: true
8483
env:
@@ -87,6 +86,7 @@ jobs:
8786
docs-release:
8887
name: 📚 Publish documentation
8988
runs-on: ubuntu-latest
89+
timeout-minutes: 15
9090
permissions:
9191
contents: write
9292
steps:

0 commit comments

Comments
 (0)