Skip to content

Commit 19769ba

Browse files
Sync with upstream/main (excluding .github/workflows)
1 parent fc4c6ba commit 19769ba

23 files changed

+534
-60
lines changed

AGENTS.md

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
# AGENTS.md - Agent Guidelines for Cluster API Provider OpenStack
2+
3+
This document provides guidelines and useful commands for AI agents contributing to the Cluster API Provider OpenStack (CAPO) repository.
4+
5+
> **⚠️ IMPORTANT**: When making changes to Makefile targets, PR requirements, code generation workflows, verification steps, or any other information referenced in this document, **AGENTS.md must be updated accordingly** to keep it synchronized with the actual project state.
6+
7+
## Overview
8+
9+
Cluster API Provider OpenStack (CAPO) is a Kubernetes-native declarative infrastructure provider for managing Kubernetes clusters on OpenStack. It implements the Cluster API (CAPI) specification for self-managed Kubernetes clusters on OpenStack infrastructure.
10+
11+
**Key Concepts:**
12+
- **CAPI**: Cluster API - the upstream Kubernetes project defining cluster lifecycle APIs
13+
- **CAPO**: Cluster API Provider OpenStack - this repository
14+
- **Reconciler**: Controller-runtime pattern for managing Kubernetes custom resources
15+
- **Scope**: Context and configuration wrapper for controllers and services
16+
17+
## Key Requirements for Contributors
18+
19+
### Legal Requirements
20+
21+
- **CLA Required**: All contributors MUST sign the Kubernetes Contributor License Agreement (CLA)
22+
- See: https://git.k8s.io/community/CLA.md
23+
24+
### Pull Request Labels
25+
26+
All code PRs MUST be labeled with one of:
27+
- ⚠️ `:warning:` - major or breaking changes
28+
-`:sparkles:` - feature additions
29+
- 🐛 `:bug:` - patch and bugfixes
30+
- 📖 `:book:` - documentation or proposals
31+
- 🌱 `:seedling:` - minor or other
32+
33+
## Essential Make Targets
34+
35+
### Code Quality & Verification
36+
37+
```bash
38+
# Run all verification checks (should pass before submitting PR)
39+
make verify
40+
41+
# Verify boilerplate headers
42+
make verify-boilerplate
43+
44+
# Verify go modules are up to date
45+
make verify-modules
46+
47+
# Verify generated code is up to date
48+
make verify-gen
49+
50+
# Verify container images for vulnerabilities
51+
make verify-container-images
52+
53+
# Check code for security vulnerabilities
54+
make verify-govulncheck
55+
56+
# Run all security checks (images + code)
57+
make verify-security
58+
```
59+
60+
### Linting
61+
62+
```bash
63+
# Lint codebase
64+
make lint
65+
66+
# Lint and auto-fix issues
67+
make lint-update
68+
69+
# Run faster linters only
70+
make lint-fast
71+
```
72+
73+
### Testing
74+
75+
```bash
76+
# Run unit tests
77+
make test
78+
79+
# Run unit tests for CAPO specifically
80+
make test-capo
81+
82+
# Build e2e test binaries
83+
make build-e2e-tests
84+
85+
# Run e2e tests (requires OpenStack environment)
86+
make test-e2e
87+
88+
# Run conformance tests
89+
make test-conformance
90+
91+
# Compile e2e tests (verify they build)
92+
make compile-e2e
93+
```
94+
95+
### Code Generation
96+
97+
```bash
98+
# Generate ALL code (manifests, deepcopy, clients, mocks, docs)
99+
make generate
100+
101+
# Generate Go code (mocks, etc.)
102+
make generate-go
103+
104+
# Generate controller-gen code (deepcopy, etc.)
105+
make generate-controller-gen
106+
107+
# Generate client code (clientsets, listers, informers)
108+
make generate-codegen
109+
110+
# Generate CRD manifests
111+
make generate-manifests
112+
113+
# Generate API documentation
114+
make generate-api-docs
115+
116+
# Generate cluster templates
117+
make templates
118+
```
119+
120+
### Dependency Management
121+
122+
```bash
123+
# Update go modules
124+
make modules
125+
126+
# Check for API differences (useful before breaking changes)
127+
make apidiff
128+
```
129+
130+
### Building
131+
132+
```bash
133+
# Build manager binaries
134+
make managers
135+
136+
# Build all binaries
137+
make binaries
138+
139+
# Build Docker image
140+
make docker-build
141+
142+
# Build debug Docker image
143+
make docker-build-debug
144+
145+
# Build for all architectures
146+
make docker-build-all
147+
```
148+
149+
### Cleanup
150+
151+
```bash
152+
# Clean all build artifacts
153+
make clean
154+
155+
# Clean binaries only
156+
make clean-bin
157+
158+
# Clean temporary files
159+
make clean-temporary
160+
161+
# Clean release artifacts
162+
make clean-release
163+
```
164+
165+
## Important Development Patterns
166+
167+
### Adding New OpenStack Resources
168+
169+
1. Define API types in `/api/v1beta1` (or `/api/v1alpha1` for experimental features)
170+
2. Run `make generate` to create deepcopy methods and update CRDs
171+
3. Create controller in `/controllers`
172+
4. Create service implementation in `/pkg/cloud/services/<category>`
173+
5. Update or create scope in `/pkg/scope` if needed
174+
6. Add webhooks in `/pkg/webhooks` for validation/defaulting
175+
7. Add unit tests for controller and services
176+
8. Update documentation
177+
9. Generate cluster templates if applicable with `make templates`
178+
179+
### Testing Strategy
180+
181+
1. **Unit Tests**: Test individual functions/methods with mocks
182+
2. **Integration Tests**: Test controller behavior with envtest
183+
3. **E2E Tests**: Deploy real clusters on OpenStack, verify functionality
184+
4. **Conformance Tests**: Run upstream Kubernetes conformance suite
185+
186+
## Pre-Submit Checklist for Agents
187+
188+
Before submitting a PR, ensure:
189+
190+
1. **Code is generated and up to date**:
191+
```bash
192+
make generate
193+
```
194+
195+
2. **Modules are tidy**:
196+
```bash
197+
make modules
198+
```
199+
200+
3. **Code passes linting**:
201+
```bash
202+
make lint
203+
```
204+
205+
4. **Tests pass**:
206+
```bash
207+
make test
208+
```
209+
210+
5. **All verification checks pass**:
211+
```bash
212+
make verify
213+
```
214+
215+
## Common Workflows
216+
217+
### Making Code Changes
218+
219+
1. Make your code changes
220+
2. Run code generation: `make generate`
221+
3. Update modules if needed: `make modules`
222+
4. Run tests: `make test`
223+
5. Lint the code: `make lint`
224+
6. Verify everything: `make verify`
225+
7. Commit changes with descriptive message
226+
227+
### Updating Dependencies
228+
229+
1. Update `go.mod` or `hack/tools/go.mod` as needed
230+
2. Run: `make modules`
231+
3. Run: `make verify-modules`
232+
4. Test that everything still works: `make test`
233+
234+
## Common Issues
235+
236+
### Linting Errors
237+
238+
The project uses golangci-lint. If you get lint errors:
239+
1. Run `make lint-update` first to auto-fix
240+
2. Check `.golangci.yml` for enabled linters
241+
3. Some issues require manual fixes (cognitive complexity, error handling, etc.)
242+
4. Don't disable linters without good reason - fix the underlying issue
243+
244+
### Test Failures
245+
246+
- **envtest issues**: Ensure KUBEBUILDER_ASSETS is set correctly
247+
- **Flaky E2E tests**: Transient infrastructure issues, failure to deploy devstack
248+
249+
### Generated File Drift
250+
251+
If `make verify` fails with generated file drift:
252+
1. Run `make generate` to regenerate all files
253+
2. Review the changes to ensure they're expected
254+
3. Commit the generated files
255+
4. Never manually edit generated files
256+
257+
## Documentation
258+
259+
Primary documentation is in `/docs/book/src/` (mdBook format):
260+
- Getting started guides
261+
- Developer documentation
262+
- Troubleshooting guides
263+
- API reference
264+
- Cluster template documentation
265+
266+
Build and serve docs locally:
267+
```bash
268+
make -C docs/book serve
269+
```
270+
271+
## Quick Reference
272+
273+
| Task | Command |
274+
|------|---------|
275+
| Full verification before PR | `make verify && make test` |
276+
| Generate all code | `make generate` |
277+
| Update dependencies | `make modules` |
278+
| Lint and fix | `make lint-update` |
279+
| Run tests | `make test` |
280+
| Build binary | `make managers` |
281+
| Build Docker image | `make docker-build` |
282+
| Clean everything | `make clean` |
283+
| Check API compatibility | `make apidiff` |
284+
| Generate templates | `make templates` |
285+
| Build and serve docs | `make -C docs/book serve` |

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
188188
cluster-template-multi-network.yaml \
189189
cluster-template-without-lb.yaml \
190190
cluster-template.yaml \
191+
cluster-template-topology.yaml \
191192
cluster-template-flatcar.yaml \
192193
cluster-template-k8s-upgrade.yaml \
193194
cluster-template-flatcar-sysext.yaml \
@@ -448,14 +449,13 @@ staging-manifests:
448449
## --------------------------------------
449450
##@ Release
450451
## --------------------------------------
451-
452452
ifneq (,$(findstring -,$(RELEASE_TAG)))
453453
PRE_RELEASE=true
454454
endif
455455
PREVIOUS_TAG ?= $(shell git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | sort -V | grep -B1 $(RELEASE_TAG) | head -n 1 2>/dev/null)
456456
## set by Prow, ref name of the base branch, e.g., main
457457
RELEASE_DIR := out
458-
RELEASE_NOTES_DIR := _releasenotes
458+
RELEASE_NOTES_DIR := releasenotes
459459

460460
.PHONY: $(RELEASE_DIR)
461461
$(RELEASE_DIR):
@@ -478,14 +478,15 @@ list-image:
478478
gcloud container images list-tags $(STAGING_REGISTRY)/$(IMAGE) --filter="tags=('$(RELEASE_TAG)')" --format=json
479479

480480
.PHONY: release
481-
release: $(RELEASE_NOTES) clean-release $(RELEASE_DIR) ## Builds and push container images using the latest git tag for the commit.
481+
release: $(RELEASE_NOTES) $(RELEASE_DIR) ## Builds and push container images using the latest git tag for the commit.
482482
@if [ -z "${RELEASE_TAG}" ]; then echo "RELEASE_TAG is not set"; exit 1; fi
483483
@if ! [ -z "$$(git status --porcelain)" ]; then echo "Your local git repository contains uncommitted changes, use git clean before proceeding."; fi
484484
git checkout "${RELEASE_TAG}"
485485
# Set the manifest image to the production bucket.
486486
$(MAKE) manifest-modification REGISTRY=$(PROD_REGISTRY)
487487
$(MAKE) release-manifests
488488
$(MAKE) release-templates
489+
$(MAKE) generate-release-notes
489490

490491
.PHONY: manifest-modification
491492
manifest-modification: # Set the manifest images to the staging/production bucket.

OWNERS_ALIASES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ aliases:
2222
- emilienm
2323
- lentzi90
2424
cluster-api-openstack-reviewers:
25+
- bnallapeta
2526
- smoshiur1237

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/gophercloud/utils/v2 v2.0.0-20241220104409-2e0af06694a1
1313
github.com/hashicorp/go-version v1.7.0
1414
github.com/k-orc/openstack-resource-controller/v2 v2.2.0
15-
github.com/onsi/ginkgo/v2 v2.26.0
15+
github.com/onsi/ginkgo/v2 v2.27.1
1616
github.com/onsi/gomega v1.38.2
1717
github.com/prometheus/client_golang v1.23.2
1818
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BN
8484
github.com/gkampitakis/ciinfo v0.3.2/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo=
8585
github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M=
8686
github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk=
87-
github.com/gkampitakis/go-snaps v0.5.14 h1:3fAqdB6BCPKHDMHAKRwtPUwYexKtGrNuw8HX/T/4neo=
88-
github.com/gkampitakis/go-snaps v0.5.14/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc=
87+
github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE=
88+
github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc=
8989
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
9090
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
9191
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@@ -209,8 +209,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
209209
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
210210
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
211211
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
212-
github.com/onsi/ginkgo/v2 v2.26.0 h1:1J4Wut1IlYZNEAWIV3ALrT9NfiaGW2cDCJQSFQMs/gE=
213-
github.com/onsi/ginkgo/v2 v2.26.0/go.mod h1:qhEywmzWTBUY88kfO0BRvX4py7scov9yR+Az2oavUzw=
212+
github.com/onsi/ginkgo/v2 v2.27.1 h1:0LJC8MpUSQnfnp4n/3W3GdlmJP3ENGF0ZPzjQGLPP7s=
213+
github.com/onsi/ginkgo/v2 v2.27.1/go.mod h1:wmy3vCqiBjirARfVhAqFpYt8uvX0yaFe+GudAqqcCqA=
214214
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
215215
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
216216
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=

hack/ci/cloud-init/controller.yaml.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Enable Logging
1111
LOGFILE=/opt/stack/logs/stack.sh.log
1212
VERBOSE=True
13-
LOG_COLOR=True
13+
LOG_COLOR=False
1414

1515
# Host tuning
1616
ENABLE_SYSCTL_MEM_TUNING="True"
@@ -44,7 +44,7 @@
4444
PUBLIC_BRIDGE_MTU=${MTU}
4545
ENABLE_CHASSIS_AS_GW="True"
4646
OVN_DBS_LOG_LEVEL="dbg"
47-
Q_ML2_PLUGIN_MECHANISM_DRIVERS="ovn,logger"
47+
Q_ML2_PLUGIN_MECHANISM_DRIVERS="ovn"
4848
OVN_L3_CREATE_PUBLIC_NETWORK="True"
4949
Q_AGENT="ovn"
5050

hack/ci/cloud-init/worker.yaml.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Enable Logging
1010
LOGFILE=/opt/stack/logs/stack.sh.log
1111
VERBOSE=True
12-
LOG_COLOR=True
12+
LOG_COLOR=False
1313

1414
# Host tuning
1515
ENABLE_SYSCTL_MEM_TUNING="True"
@@ -41,7 +41,7 @@
4141
PUBLIC_BRIDGE_MTU=${MTU}
4242
ENABLE_CHASSIS_AS_GW="False"
4343
OVN_DBS_LOG_LEVEL="dbg"
44-
Q_ML2_PLUGIN_MECHANISM_DRIVERS="ovn,logger"
44+
Q_ML2_PLUGIN_MECHANISM_DRIVERS="ovn"
4545
Q_AGENT="ovn"
4646

4747
# WORKAROUND:

0 commit comments

Comments
 (0)