|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file is for AI coding agents. It describes the repository, how to build and test it, and the conventions to follow when contributing. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +scylla-operator is a Kubernetes operator for managing ScyllaDB clusters. It is written in Go and follows controller-runtime/kubebuilder patterns. The operator manages these primary CRDs: |
| 8 | + |
| 9 | +- **ScyllaCluster** - legacy single-datacenter ScyllaDB cluster |
| 10 | +- **ScyllaDBCluster** - multi-datacenter ScyllaDB cluster |
| 11 | +- **ScyllaDBDatacenter** - per-datacenter ScyllaDB resources |
| 12 | +- **ScyllaDBMonitoring** - monitoring stack for ScyllaDB |
| 13 | +- **NodeConfig** - node-level tuning and configuration |
| 14 | +- **ScyllaOperatorConfig** - operator-wide settings |
| 15 | + |
| 16 | +## Repository Layout |
| 17 | + |
| 18 | +``` |
| 19 | +cmd/ Entrypoints |
| 20 | + scylla-operator/ Operator binary |
| 21 | + scylla-operator-tests/ E2E test binary |
| 22 | + gen-api-reference/ API reference doc generator |
| 23 | +pkg/ |
| 24 | + api/scylla/ CRD types, defaulting, validation |
| 25 | + controller/ One reconciliation controller per CRD |
| 26 | + scyllacluster/ ScyllaCluster controller |
| 27 | + scylladbcluster/ ScyllaDBCluster controller |
| 28 | + scylladbdatacenter/ ScyllaDBDatacenter controller |
| 29 | + scylladbmonitoring/ ScyllaDBMonitoring controller |
| 30 | + nodeconfig/ NodeConfig controller |
| 31 | + scyllaoperatorconfig/ ScyllaOperatorConfig controller |
| 32 | + sidecar/ Sidecar injection controller |
| 33 | + ... Other supporting controllers |
| 34 | + naming/ Deterministic resource naming and label helpers |
| 35 | + scyllaclient/ HTTP client for ScyllaDB node REST API |
| 36 | + helpers/ Shared utility functions |
| 37 | + client/ Generated and extended Kubernetes clients |
| 38 | + test/ Test framework helpers |
| 39 | +test/ E2E test suites |
| 40 | +hack/ Build and CI scripts |
| 41 | +helm/ Helm charts |
| 42 | +deploy/ Static deployment manifests |
| 43 | +docs/ Generated API reference |
| 44 | +enhancements/ Design proposals |
| 45 | +examples/ Example CRD manifests |
| 46 | +assets/ Embedded assets (certs, configs) |
| 47 | +``` |
| 48 | + |
| 49 | +## Building and Testing |
| 50 | + |
| 51 | +### Build |
| 52 | + |
| 53 | +```sh |
| 54 | +make build |
| 55 | +``` |
| 56 | + |
| 57 | +### Unit Tests |
| 58 | + |
| 59 | +```sh |
| 60 | +make test-unit |
| 61 | +``` |
| 62 | + |
| 63 | +### Generated Files |
| 64 | + |
| 65 | +After modifying API types, CRDs, or any code that affects generated output, always run: |
| 66 | + |
| 67 | +```sh |
| 68 | +make update |
| 69 | +``` |
| 70 | + |
| 71 | +Then verify nothing is out of date: |
| 72 | + |
| 73 | +```sh |
| 74 | +make verify |
| 75 | +``` |
| 76 | + |
| 77 | +`make verify` will fail if generated files are stale. Always run `make update` before `make verify`. |
| 78 | + |
| 79 | +### E2E Tests (Kind) |
| 80 | + |
| 81 | +```sh |
| 82 | +make kind-setup # Create Kind cluster |
| 83 | +make test-e2e-kind # Run all e2e tests |
| 84 | +SO_FOCUS='test name' make test-e2e-kind # Run specific e2e test |
| 85 | +make kind-teardown # Destroy Kind cluster |
| 86 | +``` |
| 87 | + |
| 88 | +### Required Tools |
| 89 | + |
| 90 | +yq, jq, helm, golangci-lint, operator-sdk, ginkgo, podman, kind. |
| 91 | + |
| 92 | +## Architecture |
| 93 | + |
| 94 | +Each CRD has a dedicated controller in `pkg/controller/<name>/`. Controllers follow the standard reconciliation loop pattern: watch the primary resource and owned/related resources, compare desired state with actual state, and apply changes. |
| 95 | + |
| 96 | +- `pkg/naming/` provides deterministic resource name generation and label/selector helpers. Use it instead of constructing names manually. |
| 97 | +- `pkg/scyllaclient/` wraps the ScyllaDB node REST API for operations like health checks, repair, and configuration. |
| 98 | +- `pkg/api/scylla/` contains versioned API types (`v1`, `v1alpha1`), defaulting functions, and validation logic. |
| 99 | +- API types use a tagged/discriminated union pattern for polymorphic fields. See `API_CONVENTIONS.md` for details. |
| 100 | + |
| 101 | +## Conventions for Contributions |
| 102 | + |
| 103 | +### Commit Messages and PR Titles |
| 104 | + |
| 105 | +Use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format: |
| 106 | + |
| 107 | +``` |
| 108 | +<type>(<scope>): <subject> |
| 109 | +``` |
| 110 | + |
| 111 | +- Subject must be imperative, lowercase, 72 characters or fewer, no trailing period. |
| 112 | +- Never include `@mentions`, issue-closing keywords, or `#` references in commit messages. |
| 113 | +- If the PR fixes an issue, add `Resolves #<number>` only in the PR description body. |
| 114 | + |
| 115 | +### Code Style |
| 116 | + |
| 117 | +- Follow [Effective Go](https://go.dev/doc/effective_go) and [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments). |
| 118 | +- Follow [Kubernetes API Conventions](https://github.com/kubernetes/community/blob/master/contributors/dml-conventions/api-conventions.md) and `API_CONVENTIONS.md` for CRD types. |
| 119 | + |
| 120 | +### Before Submitting |
| 121 | + |
| 122 | +1. `make build` succeeds. |
| 123 | +2. `make test-unit` passes. |
| 124 | +3. `make update` followed by `make verify` passes (no stale generated files). |
| 125 | +4. New functionality has unit tests. Integration or e2e tests where applicable. |
| 126 | +5. Commit history is clean (squash fixups, logical commits). |
0 commit comments