Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
328 lines (261 loc) · 15.7 KB
/
Copy pathMakefile
File metadata and controls
328 lines (261 loc) · 15.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# Root Makefile orchestrating build & test across the monorepo components:
# atlas-lib (shared library), csi-driver, operator, fleet-manager, support-tool, gateway
#
# Each target delegates to the relevant component's own Makefile.
ATLAS_DIR := atlas-lib
CSI_DIR := csi-driver
OPERATOR_DIR := operator
FLEET_DIR := fleet
SUPPORT_DIR := support-tool
GATEWAY_DIR := gateway
HELM_DIR := helm-charts
INTEGRATION_DIR := test/integration
# Local, untracked settings: the paths that are one machine's business rather
# than this repository's. SBCLI_DIR below is the one that needs it today.
-include local.mk
# The control-plane spec, and where it is exported from.
#
# SBCLI_DIR has no default, because a checkout of another repository is not
# something this one can know the location of. It is resolved, in order, from
# the command line or the environment, then from the repo.sbcli setting that
# scripts/local-config.sh records in local.mk, and then from .sbcli inside this
# repository, which is where CI checks sbcli out and which .gitignore covers.
# Failing all three, the openapi targets say what to set.
SBCLI_DIR ?= $(firstword $(strip $(REPO_SBCLI)) $(wildcard .sbcli))
OPENAPI_SPEC := shared/openapi.json
# The export imports the control plane's own app, so it runs against sbcli's
# requirement set rather than this machine's Python. The environment lives with
# the other pinned tools in .bin, which is ignored, and is built on first use:
# the alternative is a target that only ever works in CI.
# The interpreter the environment is built with, for a host whose python3 is too
# old for sbcli's requirements. Set it with
# `scripts/local-config.sh venv interpreter set python3.13`.
VENV_INTERPRETER ?= $(firstword $(strip $(VENV_INTERPRETER)) python3)
OPENAPI_VENV := .bin/openapi-venv
OPENAPI_PY := $(OPENAPI_VENV)/bin/python
OPENAPI_STAMP := $(OPENAPI_VENV)/.requirements-installed
# Through wildcard, so an absent sbcli checkout reaches the recipe's own message
# instead of make's "no rule to make target."
SBCLI_REQUIREMENTS := $(wildcard $(SBCLI_DIR)/requirements.txt)
# Run orchestrated targets serially; each component's Makefile manages its own
# internal parallelism.
.NOTPARALLEL:
.DEFAULT_GOAL := help
.PHONY: all build test lint fmt vet help \
atlas atlas-build atlas-test atlas-lint atlas-fmt atlas-vet \
csi csi-build csi-test csi-lint csi-fmt csi-vet \
operator operator-manifests operator-build-installer operator-build operator-test operator-lint operator-fmt operator-vet \
fleet fleet-manifests fleet-build fleet-test fleet-lint fleet-fmt fleet-vet \
support-tool support-tool-build support-tool-run support-tool-test support-tool-lint support-tool-fmt support-tool-vet \
gateway gateway-build gateway-test gateway-lint gateway-fmt gateway-vet \
helm-sync \
configure openapi-sync openapi-diff openapi-ref openapi-checkout
# ─── Aggregate ──────────────────────────────────────────────────────────────
all: build test ## Build and test every component.
build: atlas-build csi-build operator-build-installer operator-build fleet-build support-tool-build gateway-build helm-sync ## Build every component.
test: atlas-test csi-test operator-test fleet-test support-tool-test gateway-test ## Test every component.
lint: atlas-lint csi-lint operator-lint fleet-lint support-tool-lint gateway-lint ## Lint every component.
fmt: atlas-fmt csi-fmt operator-fmt fleet-fmt support-tool-fmt gateway-fmt ## Format every component.
vet: atlas-vet csi-vet operator-vet fleet-vet support-tool-vet gateway-vet ## Vet every component.
# ─── atlas ────────────────────────────────────────────────────────────────
atlas: atlas-build atlas-test ## Build and test atlas.
atlas-build: ## Build atlas.
$(MAKE) -C $(ATLAS_DIR) build
atlas-test: ## Test atlas.
$(MAKE) -C $(ATLAS_DIR) test
atlas-lint: ## Lint atlas.
$(MAKE) -C $(ATLAS_DIR) lint
atlas-fmt: ## Format atlas.
$(MAKE) -C $(ATLAS_DIR) fmt
atlas-vet: ## Vet atlas.
$(MAKE) -C $(ATLAS_DIR) vet
# ─── csi ──────────────────────────────────────────────────────────────────
csi: csi-build csi-test ## Build and test csi.
csi-build: ## Build csi (spdkcsi binary).
$(MAKE) -C $(CSI_DIR) spdkcsi
csi-test: ## Test csi.
$(MAKE) -C $(CSI_DIR) test
csi-lint: ## Lint csi.
$(MAKE) -C $(CSI_DIR) lint
csi-fmt: ## Format csi.
$(MAKE) -C $(CSI_DIR) fmt
csi-vet: ## Vet csi.
$(MAKE) -C $(CSI_DIR) vet
# ─── operator ───────────────────────────────────────────────────────────────
operator: operator-manifests operator-build-installer operator-build operator-test ## Manifests, installer, build and test operator.
operator-manifests: ## Generate operator manifests (CRDs, RBAC, webhooks).
$(MAKE) -C $(OPERATOR_DIR) manifests
operator-build-installer: ## Generate the operator dist/install.yaml.
$(MAKE) -C $(OPERATOR_DIR) build-installer
operator-build: ## Build the operator manager binary.
$(MAKE) -C $(OPERATOR_DIR) build
.PHONY: operator-build-upgrade
operator-build-upgrade: ## Build the API upgrade tool, which is not in the operator image.
$(MAKE) -C $(OPERATOR_DIR) build-upgrade
operator-test: ## Test operator.
$(MAKE) -C $(OPERATOR_DIR) test
operator-lint: ## Lint operator.
$(MAKE) -C $(OPERATOR_DIR) lint
operator-fmt: ## Format operator.
$(MAKE) -C $(OPERATOR_DIR) fmt
operator-vet: ## Vet operator.
$(MAKE) -C $(OPERATOR_DIR) vet
# ─── fleet-manager ──────────────────────────────────────────────────────────
# The hub half of a multi-cluster installation. It is built and tested with the
# rest, and it reaches no install path of its own: nothing a standalone
# deployment installs comes from here.
fleet: fleet-manifests fleet-build fleet-test ## Manifests, build and test the fleet manager.
fleet-manifests: ## Generate the fleet CRDs.
$(MAKE) -C $(FLEET_DIR) manifests
fleet-build: ## Build the fleet manager binary.
$(MAKE) -C $(FLEET_DIR) build
fleet-test: ## Test the fleet manager.
$(MAKE) -C $(FLEET_DIR) test
fleet-lint: ## Lint the fleet manager.
$(MAKE) -C $(FLEET_DIR) lint
fleet-fmt: ## Format the fleet manager.
$(MAKE) -C $(FLEET_DIR) fmt
fleet-vet: ## Vet the fleet manager.
$(MAKE) -C $(FLEET_DIR) vet
# ─── support-tool ───────────────────────────────────────────────────────────
# The local web application support agents read support bundles and build
# ClusterDeploymentConfigs with. It runs on the agent's machine only.
support-tool: support-tool-build support-tool-test ## Build and test the support tool.
support-tool-build: ## Build the support tool binary.
$(MAKE) -C $(SUPPORT_DIR) build
support-tool-run: ## Serve the support tool on 127.0.0.1:8099.
$(MAKE) -C $(SUPPORT_DIR) run
support-tool-test: ## Test the support tool.
$(MAKE) -C $(SUPPORT_DIR) test
support-tool-lint: ## Lint the support tool.
$(MAKE) -C $(SUPPORT_DIR) lint
support-tool-fmt: ## Format the support tool.
$(MAKE) -C $(SUPPORT_DIR) fmt
support-tool-vet: ## Vet the support tool.
$(MAKE) -C $(SUPPORT_DIR) vet
# ─── gateway ────────────────────────────────────────────────────────────────
# The S3 gateway: an embedded versitygw (github.com/versity/versitygw/embedgw)
# over its own posix backend. No manifests step: unlike fleet, this component
# carries no CRDs of its own.
gateway: gateway-build gateway-test ## Build and test the gateway.
gateway-build: ## Build the gateway binary.
$(MAKE) -C $(GATEWAY_DIR) build
gateway-test: ## Test the gateway.
$(MAKE) -C $(GATEWAY_DIR) test
gateway-lint: ## Lint the gateway.
$(MAKE) -C $(GATEWAY_DIR) lint
gateway-fmt: ## Format the gateway.
$(MAKE) -C $(GATEWAY_DIR) fmt
gateway-vet: ## Vet the gateway.
$(MAKE) -C $(GATEWAY_DIR) vet
# ─── helm ─────────────────────────────────────────────────────────────────
# Sync the operator's generated CRDs and RBAC roles into the Helm chart. Depends
# on operator-manifests so the copied sources are freshly generated (not stale).
helm-sync: operator-manifests ## Sync operator CRDs and RBAC into the Helm chart, and the chart's values into the support tool.
bash $(HELM_DIR)/scripts/sync-from-operator.sh $(OPERATOR_DIR)
$(MAKE) -C $(SUPPORT_DIR) chart
# ─── openapi ──────────────────────────────────────────────────────────────
# shared/openapi.json is the contract atlas-lib's generated client and the
# integration suite's control-plane simulator are built from, and it is exported
# from the control plane rather than written here. That makes it go stale
# silently: nothing in this repository fails when sbcli grows a field, and the
# generated client simply cannot see it.
#
# CI exports it nightly and proposes the drift as a pull request (see
# .github/workflows/repo_openapi_sync.yaml). These two targets are the same
# export by hand, for when the question is whether the export is behind today.
#
# Importing the control plane's app needs sbcli's own requirements installed
# (pip install -r $(SBCLI_DIR)/requirements.txt), and nothing connects to a
# database or to FoundationDB at import time.
# Which sbcli the spec is being read from, stated every time. A sibling checkout
# sits on whatever branch it was last left on, and an export from a release
# branch drops the endpoints that only exist on main: the committed spec is the
# contract, so the ref it came from is not a detail.
# ─── configuration ────────────────────────────────────────────────────────
# Where the checkouts this repository cannot contain actually are. Detecting
# them beats explaining local.mk to everybody once, and recording the answer
# beats detecting it on every invocation.
configure: ## Find the sbcli checkout the openapi targets need and record it.
@bash scripts/local-config.sh detect $(CONFIGURE_ARGS)
# Says what to do rather than failing on a path nobody set.
openapi-checkout:
@test -n "$(SBCLI_DIR)" && test -d "$(SBCLI_DIR)" || { \
echo "no sbcli checkout: SBCLI_DIR is unset and .sbcli does not exist. Either"; \
echo " let it be found: make configure"; \
echo " or have it cloned: make configure CONFIGURE_ARGS=--clone"; \
echo " or name it: scripts/local-config.sh repo sbcli set <dir>"; \
echo " or pass it once: make $(MAKECMDGOALS) SBCLI_DIR=<dir>"; \
exit 1; }
openapi-ref: openapi-checkout
@printf 'sbcli: %s at %s (%s)\n' \
"$$(git -C $(SBCLI_DIR) rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown branch')" \
"$$(git -C $(SBCLI_DIR) rev-parse --short HEAD 2>/dev/null || echo 'unknown commit')" \
"$(SBCLI_DIR)"
# Rebuilt when sbcli's requirements move, so an export never runs against a
# stale environment.
$(OPENAPI_STAMP): $(SBCLI_REQUIREMENTS)
@test -n "$(SBCLI_REQUIREMENTS)" || { \
echo "no sbcli checkout at $(SBCLI_DIR): clone it there, or pass SBCLI_DIR=<path>"; \
exit 1; }
$(VENV_INTERPRETER) -m venv $(OPENAPI_VENV)
$(OPENAPI_VENV)/bin/pip install --quiet --requirement $(SBCLI_REQUIREMENTS)
@touch $@
openapi-diff: openapi-checkout $(OPENAPI_STAMP) ## Show what re-exporting the spec would change, writing nothing.
@$(MAKE) --no-print-directory openapi-ref
@new=$$(mktemp); trap 'rm -f "$$new"' EXIT; \
$(OPENAPI_PY) shared/export-openapi.py export --sbcli $(SBCLI_DIR) --out $$new >/dev/null && \
$(OPENAPI_PY) shared/export-openapi.py summarize --old $(OPENAPI_SPEC) --new $$new
# Regenerating is part of the sync rather than a step to remember: a spec that
# moved and a client that did not is what the drift gates fail on.
openapi-sync: openapi-checkout $(OPENAPI_STAMP) ## Re-export the spec from SBCLI_DIR, then regenerate what reads it.
@$(MAKE) --no-print-directory openapi-ref
@old=$$(mktemp); cp $(OPENAPI_SPEC) $$old; trap 'rm -f "$$old"' EXIT; \
$(OPENAPI_PY) shared/export-openapi.py export --sbcli $(SBCLI_DIR) --out $(OPENAPI_SPEC) && \
$(OPENAPI_PY) shared/export-openapi.py summarize --old $$old --new $(OPENAPI_SPEC)
$(MAKE) -C $(ATLAS_DIR) generate
$(MAKE) -C $(INTEGRATION_DIR) generate
# ─── go workspace ─────────────────────────────────────────────────────────
# The modules go.work lists, read from the workspace itself so a module added to
# it is covered without touching this file. A module missing from go.work is
# skipped by both targets below.
#
# A shell fragment rather than $(shell ...), because make discards the exit
# status of $(shell ...): a workspace that cannot be loaded would list nothing,
# and the target would edit go.work alone and report success. Each recipe runs
# it before changing anything, and stops when the listing fails or is empty.
GO_WORK_MODULES_SH = mods=$$(go list -m -f '{{.Dir}}') && test -n "$$mods" || { \
echo "cannot list the modules in go.work; nothing was changed"; \
exit 1; }
.PHONY: go-sync go-version
go-sync: ## Align the workspace modules' dependency versions, then tidy each module.
@$(GO_WORK_MODULES_SH); \
go work sync || exit 1; \
for mod in $$mods; do \
echo "go mod tidy: $$mod"; \
(cd $$mod && go mod tidy) || exit 1; \
done
# The go line is set in each module and in go.work, the toolchain line only in
# go.work: the workspace picks the toolchain for every module it builds.
#
# The toolchain is fetched before anything is edited, so a version that does not
# exist is refused up front. The edits run with GOTOOLCHAIN=local: once go.work
# names the new version, any other go command would switch to that toolchain
# first, and a failed switch would leave the edit half done.
go-version: ## Set the Go version of go.work and every workspace module (GO_VERSION=X.Y.Z).
@echo "$(GO_VERSION)" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$$' || { \
echo "GO_VERSION must be X.Y.Z, got '$(GO_VERSION)': make go-version GO_VERSION=1.26.10"; \
exit 1; }
@GOTOOLCHAIN=go$(GO_VERSION) go version >/dev/null || { \
echo "toolchain go$(GO_VERSION) is not available; nothing was changed"; \
exit 1; }
@$(GO_WORK_MODULES_SH); \
echo "go work edit -go=$(GO_VERSION) -toolchain=go$(GO_VERSION)"; \
GOTOOLCHAIN=local go work edit -go=$(GO_VERSION) -toolchain=go$(GO_VERSION) || exit 1; \
for mod in $$mods; do \
echo "go mod edit -go=$(GO_VERSION): $$mod"; \
GOTOOLCHAIN=local go mod edit -go=$(GO_VERSION) $$mod/go.mod || exit 1; \
done
# ─── help ─────────────────────────────────────────────────────────────────
help: ## Show this help.
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make <target>\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-26s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)