forked from pachyderm/pachyderm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
480 lines (393 loc) · 16.9 KB
/
Makefile
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
#### VARIABLES
# TESTFLAGS: flags for test
# KUBECTLFLAGS: flags for kubectl
# DOCKER_BUILD_FLAGS: flags for 'docker build'
####
include etc/govars.mk
SHELL=/bin/bash -o pipefail
RUN= # used by go tests to decide which tests to run (i.e. passed to -run)
export VERSION_ADDITIONAL = -$(shell git log --pretty=format:%H | head -n 1)
export GC_FLAGS = "all=-trimpath=${PWD}"
export CLIENT_ADDITIONAL_VERSION=github.com/pachyderm/pachyderm/v2/src/version.AdditionalVersion=$(VERSION_ADDITIONAL)
export LD_FLAGS=-X $(CLIENT_ADDITIONAL_VERSION)
export DOCKER_BUILD_FLAGS
CLUSTER_NAME ?= pachyderm
CLUSTER_MACHINE_TYPE ?= n1-standard-4
CLUSTER_SIZE ?= 4
MINIKUBE_MEM = 8192 # MB of memory allocated to minikube
MINIKUBE_CPU = 4 # Number of CPUs allocated to minikube
CHLOGFILE = ${PWD}/../changelog.diff
export GOVERSION = $(shell cat etc/compile/GO_VERSION)
GORELSNAP = #--snapshot # uncomment --snapshot if you want to do a dry run.
SKIP = #\# # To skip push to docker and github remove # in front of #
GORELDEBUG = #--debug # uncomment --debug for verbose goreleaser output
# Default upper bound for test timeouts
# You can specify your own, but this is what CI uses
TIMEOUT ?= 3600s
install:
# GOBIN (default: GOPATH/bin) must be on your PATH to access these binaries:
go install -ldflags "$(LD_FLAGS)" -gcflags "$(GC_FLAGS)" ./src/server/cmd/pachctl
install-clean:
@# Need to blow away pachctl binary if its already there
@rm -f $(PACHCTL)
@make install
install-doc:
go install -gcflags "$(GC_FLAGS)" ./src/server/cmd/pachctl-doc
doc-custom: install-doc install-clean
./etc/build/doc.sh
doc-reference-refresh: install-doc install-clean
./etc/build/reference_refresh.sh
doc:
@make VERSION_ADDITIONAL= doc-custom
point-release:
@./etc/build/make_changelog.sh $(CHLOGFILE)
@VERSION_ADDITIONAL= ./etc/build/make_release.sh
@echo "Release completed"
# Run via 'make VERSION_ADDITIONAL=-rc2 release-candidate' to specify a version string
release-candidate:
@make custom-release
custom-release:
echo "" > $(CHLOGFILE)
@VERSION_ADDITIONAL=$(VERSION_ADDITIONAL) ./etc/build/make_release.sh "Custom"
# Need to check for homebrew updates from release-pachctl-custom
# This is getting called from etc/build/make_release.sh
# Git tag is force pushed. We are assuming if the same build is done again, it is done with intent
release:
@git tag -f -am "Release tag v$(VERSION)" v$(VERSION)
$(SKIP) @git push -f origin v$(VERSION)
@make release-helper
@make release-pachctl
@echo "Release $(VERSION) completed"
release-helper: release-docker-images docker-push-release
release-docker-images:
DOCKER_BUILDKIT=1 goreleaser release -p 1 $(GORELSNAP) $(GORELDEBUG) --skip-publish --rm-dist -f goreleaser/docker.yml
release-pachctl:
@goreleaser release -p 1 $(GORELSNAP) $(GORELDEBUG) --release-notes=$(CHLOGFILE) --rm-dist -f goreleaser/pachctl.yml
docker-build:
docker build -f etc/test-images/Dockerfile.testuser -t pachyderm/testuser:local .
docker build -f etc/test-images/Dockerfile.netcat -t pachyderm/ubuntuplusnetcat:local .
DOCKER_BUILDKIT=1 goreleaser release -p 1 --snapshot $(GORELDEBUG) --skip-publish --rm-dist -f goreleaser/docker.yml
docker-build-proto:
docker build $(DOCKER_BUILD_FLAGS) -t pachyderm_proto etc/proto
docker-build-gpu:
docker build $(DOCKER_BUILD_FLAGS) -t pachyderm_nvidia_driver_install etc/deploy/gpu
docker tag pachyderm_nvidia_driver_install pachyderm/nvidia_driver_install
docker-build-kafka:
docker build -t kafka-demo etc/testing/kafka
docker-build-spout-test:
docker build -t spout-test etc/testing/spout
docker-push-gpu:
$(SKIP) docker push pachyderm/nvidia_driver_install
docker-push-gpu-dev:
docker tag pachyderm/nvidia_driver_install pachyderm/nvidia_driver_install:`git rev-list HEAD --max-count=1`
$(SKIP) docker push pachyderm/nvidia_driver_install:`git rev-list HEAD --max-count=1`
echo pushed pachyderm/nvidia_driver_install:`git rev-list HEAD --max-count=1`
docker-gpu: docker-build-gpu docker-push-gpu
docker-gpu-dev: docker-build-gpu docker-push-gpu-dev
docker-tag:
docker tag pachyderm/pachd pachyderm/pachd:$(VERSION)
docker tag pachyderm/worker pachyderm/worker:$(VERSION)
docker tag pachyderm/pachctl pachyderm/pachctl:$(VERSION)
docker-push: docker-tag
$(SKIP) docker push pachyderm/pachd:$(VERSION)
$(SKIP) docker push pachyderm/worker:$(VERSION)
$(SKIP) docker push pachyderm/pachctl:$(VERSION)
docker-push-release: docker-push
$(SKIP) docker push pachyderm/etcd:v3.3.5
check-kubectl:
@# check that kubectl is installed
@which kubectl >/dev/null || { \
echo "error: kubectl not found"; \
exit 1; \
}
@if expr match $(shell kubectl config current-context) gke_pachub > /dev/null; then \
echo "ERROR: The active kubectl context is pointing to a pachub GKE cluster"; \
exit 1; \
fi
check-kubectl-connection:
kubectl $(KUBECTLFLAGS) get all > /dev/null
launch-kube: check-kubectl
etc/kube/start-minikube.sh
launch-dev-vm: check-kubectl
# Making sure minikube isn't still up from a previous run...
@if minikube ip 2>/dev/null || sudo minikube ip 2>/dev/null; \
then \
echo "minikube is still up. Run 'make clean-launch-kube'"; \
exit 1; \
fi
etc/kube/start-minikube-vm.sh --cpus=$(MINIKUBE_CPU) --memory=$(MINIKUBE_MEM)
# launch-release-vm is like launch-dev-vm but it doesn't build pachctl locally, and uses the same
# version of pachd associated with the current pachctl (useful if you want to start a VM with a
# point-release version of pachd, instead of whatever's in the current branch)
launch-release-vm:
# Making sure minikube isn't still up from a previous run...
@if minikube ip 2>/dev/null || sudo minikube ip 2>/dev/null; \
then \
echo "minikube is still up. Run 'make clean-launch-kube'"; \
exit 1; \
fi
etc/kube/start-minikube-vm.sh --cpus=$(MINIKUBE_CPU) --memory=$(MINIKUBE_MEM) --tag=v$$($(PACHCTL) version --client-only)
clean-launch-kube:
@# clean up both of the following cases:
@# make launch-dev-vm - minikube config is owned by $USER
@# make launch-kube - minikube config is owned by root
minikube ip 2>/dev/null && minikube delete || true
sudo minikube ip 2>/dev/null && sudo minikube delete || true
killall kubectl || true
launch: install check-kubectl
$(eval STARTTIME := $(shell date +%s))
helm install pachyderm etc/helm/pachyderm --set deployTarget=LOCAL
# wait for the pachyderm to come up
kubectl wait --for=condition=ready pod -l app=pachd --timeout=5m
@echo "pachd launch took $$(($$(date +%s) - $(STARTTIME))) seconds"
launch-dev: check-kubectl check-kubectl-connection
$(eval STARTTIME := $(shell date +%s))
kubectl apply -f etc/testing/minio.yaml --namespace=default
helm install pachyderm etc/helm/pachyderm -f etc/helm/examples/local-dev-values.yaml
# wait for the pachyderm to come up
kubectl wait --for=condition=ready pod -l app=pachd --timeout=5m
@echo "pachd launch took $$(($$(date +%s) - $(STARTTIME))) seconds"
launch-enterprise: check-kubectl check-kubectl-connection
$(eval STARTTIME := $(shell date +%s))
kubectl create namespace enterprise --dry-run=true -o yaml | kubectl apply -f -
helm install enterprise etc/helm/pachyderm --namespace enterprise -f etc/helm/examples/enterprise-dev.yaml
# wait for the pachyderm to come up
kubectl wait --for=condition=ready pod -l app=pach-enterprise --namespace enterprise --timeout=5m
@echo "pachd launch took $$(($$(date +%s) - $(STARTTIME))) seconds"
launch-enterprise-member: check-kubectl check-kubectl-connection
$(eval STARTTIME := $(shell date +%s))
helm install pachyderm etc/helm/pachyderm -f etc/helm/examples/enterprise-member-dev.yaml
# wait for the pachyderm to come up
kubectl wait --for=condition=ready pod -l app=pachd --timeout=5m
@echo "pachd launch took $$(($$(date +%s) - $(STARTTIME))) seconds"
clean-launch: check-kubectl
helm delete pachyderm || true
helm delete enterprise || true
# These resources were not cleaned up by the old pachctl undeploy
kubectl delete roles.rbac.authorization.k8s.io,rolebindings.rbac.authorization.k8s.io -l suite=pachyderm
kubectl delete clusterroles.rbac.authorization.k8s.io,clusterrolebindings.rbac.authorization.k8s.io -l suite=pachyderm
# Helm won't clean statefulset PVCs by design
kubectl delete pvc -l suite=pachyderm
kubectl delete pvc -l suite=pachyderm -n enterprise
# cleanup minio
kubectl delete statefulset -l app=minio -n default
kubectl delete service -l app=minio -n default
kubectl delete pvc -l app=minio -n default
test-proto-static:
./etc/proto/test_no_changes.sh || echo "Protos need to be recompiled; run 'DOCKER_BUILD_FLAGS=--no-cache make proto'."
proto: docker-build-proto
./etc/proto/build.sh
# Run all the tests. Note! This is no longer the test entrypoint for travis
test: clean-launch launch-dev lint enterprise-code-checkin-test docker-build test-pfs-server test-cmds test-libs test-auth test-identity test-license test-enterprise test-worker test-admin test-pps
enterprise-code-checkin-test:
@which ag || { printf "'ag' not found. Run:\n sudo apt-get install -y silversearcher-ag\n brew install the_silver_searcher\nto install it\n\n"; exit 1; }
# Check if our test activation code is anywhere in the repo
@echo "Files containing test Pachyderm Enterprise activation token:"; \
if ag --ignore=Makefile -p .gitignore 'RM2o1Qit6YlZhS1RGdXVac'; \
then \
$$( which echo ) -e "\n*** It looks like Pachyderm Engineering's test activation code may be in this repo. Please remove it before committing! ***\n"; \
false; \
fi
test-pfs-server:
./etc/testing/pfs_server.sh $(TIMEOUT) $(TESTFLAGS)
test-pps: launch-stats docker-build-spout-test
@# Use the count flag to disable test caching for this test suite.
PROM_PORT=$$(kubectl --namespace=monitoring get svc/prometheus -o json | jq -r .spec.ports[0].nodePort) \
go test -v -count=1 ./src/server -parallel 1 -timeout $(TIMEOUT) $(RUN) $(TESTFLAGS)
test-cmds:
go install -v ./src/testing/match
CGOENABLED=0 go test -v -count=1 ./src/server/cmd/pachctl/cmd
go test -v -count=1 ./src/server/pfs/cmds -timeout $(TIMEOUT) $(TESTFLAGS)
go test -v -count=1 ./src/server/pps/cmds -timeout $(TIMEOUT) $(TESTFLAGS)
go test -v -count=1 ./src/server/config -timeout $(TIMEOUT) $(TESTFLAGS)
@# TODO(msteffen) does this test leave auth active? If so it must run last
go test -v -count=1 ./src/server/auth/cmds -timeout $(TIMEOUT) $(TESTFLAGS)
go test -v -count=1 ./src/server/enterprise/cmds -timeout $(TIMEOUT) $(TESTFLAGS)
go test -v -count=1 ./src/server/identity/cmds -timeout $(TIMEOUT) $(TESTFLAGS)
test-transaction:
go test -count=1 ./src/server/transaction/server/testing -timeout $(TIMEOUT) $(TESTFLAGS)
test-client:
go test -count=1 -cover $$(go list ./src/client/...) $(TESTFLAGS)
test-s3gateway-conformance:
@if [ -z $$CONFORMANCE_SCRIPT_PATH ]; then \
echo "Missing environment variable 'CONFORMANCE_SCRIPT_PATH'"; \
exit 1; \
fi
$(CONFORMANCE_SCRIPT_PATH) --s3tests-config=etc/testing/s3gateway/s3tests.conf --ignore-config=etc/testing/s3gateway/ignore.conf --runs-dir=etc/testing/s3gateway/runs
test-s3gateway-integration:
@if [ -z $$INTEGRATION_SCRIPT_PATH ]; then \
echo "Missing environment variable 'INTEGRATION_SCRIPT_PATH'"; \
exit 1; \
fi
$(INTEGRATION_SCRIPT_PATH) http://localhost:30600 --access-key=none --secret-key=none
test-s3gateway-unit:
go test -v -count=1 ./src/server/pfs/s3 -timeout $(TIMEOUT) $(TESTFLAGS)
test-fuse:
CGOENABLED=0 go test -count=1 -cover $$(go list ./src/server/... | grep '/src/server/pfs/fuse') $(TESTFLAGS)
test-local:
CGOENABLED=0 go test -count=1 -cover -short $$(go list ./src/server/... | grep -v '/src/server/pfs/fuse') -timeout $(TIMEOUT) $(TESTFLAGS)
test-auth:
go test -v -count=1 ./src/server/auth/server/testing -timeout $(TIMEOUT) $(RUN) $(TESTFLAGS)
test-identity:
etc/testing/forward-postgres.sh
go test -v -count=1 ./src/server/identity/server -timeout $(TIMEOUT) $(RUN) $(TESTFLAGS)
test-license:
go test -v -count=1 ./src/server/license/server -timeout $(TIMEOUT) $(RUN) $(TESTFLAGS)
test-admin:
go test -v -count=1 ./src/server/admin/server -timeout $(TIMEOUT) $(RUN) $(TESTFLAGS)
test-enterprise:
go test -v -count=1 ./src/server/enterprise/server -timeout $(TIMEOUT) $(TESTFLAGS)
test-enterprise-integration:
go install ./src/testing/match
go test -v -count=1 ./src/server/enterprise/testing -timeout $(TIMEOUT) $(TESTFLAGS)
test-tls:
./etc/testing/test_tls.sh
test-worker: launch-stats test-worker-helper
test-worker-helper:
PROM_PORT=$$(kubectl --namespace=monitoring get svc/prometheus -o json | jq -r .spec.ports[0].nodePort) \
go test -v -count=1 ./src/server/worker/ -timeout $(TIMEOUT) $(TESTFLAGS)
clean: clean-launch clean-launch-kube
clean-launch-kafka:
kubectl delete -f etc/kubernetes-kafka -R
launch-kafka:
kubectl apply -f etc/kubernetes-kafka -R
kubectl wait --for=condition=ready pod -l app=kafka --timeout=5m
clean-launch-stats:
kubectl delete --filename etc/kubernetes-prometheus -R
launch-stats:
kubectl apply --filename etc/kubernetes-prometheus -R
launch-loki:
helm repo remove loki || true
helm repo add loki https://grafana.github.io/loki/charts
helm repo update
helm upgrade --install loki loki/loki-stack
kubectl wait --for=condition=ready pod -l release=loki --timeout=5m
clean-launch-loki:
helm uninstall loki
logs: check-kubectl
kubectl $(KUBECTLFLAGS) get pod -l app=pachd | sed '1d' | cut -f1 -d ' ' | xargs -n 1 -I pod sh -c 'echo pod && kubectl $(KUBECTLFLAGS) logs pod'
follow-logs: check-kubectl
kubectl $(KUBECTLFLAGS) get pod -l app=pachd | sed '1d' | cut -f1 -d ' ' | xargs -n 1 -I pod sh -c 'echo pod && kubectl $(KUBECTLFLAGS) logs -f pod'
google-cluster:
gcloud container clusters create $(CLUSTER_NAME) --scopes storage-rw --machine-type $(CLUSTER_MACHINE_TYPE) --num-nodes $(CLUSTER_SIZE)
gcloud config set container/cluster $(CLUSTER_NAME)
gcloud container clusters get-credentials $(CLUSTER_NAME)
gcloud components install kubectl
-gcloud compute firewall-rules create pachd --allow=tcp:30650
gsutil mb gs://$(BUCKET_NAME) # for PFS
gcloud compute disks create --size=$(STORAGE_SIZE)GB $(STORAGE_NAME) # for PPS
clean-google-cluster:
gcloud container clusters delete $(CLUSTER_NAME)
gcloud compute firewall-rules delete pachd
gsutil -m rm -r gs://$(BUCKET_NAME)
gcloud compute disks delete $(STORAGE_NAME)
amazon-cluster:
aws s3api create-bucket --bucket $(BUCKET_NAME) --region $(AWS_REGION)
aws ec2 create-volume --size $(STORAGE_SIZE) --region $(AWS_REGION) --availability-zone $(AWS_AVAILABILITY_ZONE) --volume-type gp2
amazon-clean-cluster:
aws s3api delete-bucket --bucket $(BUCKET_NAME) --region $(AWS_REGION)
aws ec2 detach-volume --force --volume-id $(STORAGE_NAME)
sleep 20
aws ec2 delete-volume --volume-id $(STORAGE_NAME)
amazon-clean-launch: clean-launch
kubectl $(KUBECTLFLAGS) delete --ignore-not-found secrets amazon-secret
amazon-clean:
@while :; \
do if echo "The following script will delete your AWS bucket and volume. The action cannot be undone. Do you want to proceed? (Y/n)";read REPLY; then \
case $$REPLY in Y|y) make amazon-clean-launch;make amazon-clean-cluster;break;; \
N|n) echo "The amazon clean process has been cancelled by user!";break;; \
*) echo "input parameter error, please input again ";continue;;esac; \
fi;done;
microsoft-cluster:
azure group create --name $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION)
azure storage account create $(AZURE_STORAGE_NAME) --location $(AZURE_LOCATION) --resource-group $(AZURE_RESOURCE_GROUP) --sku-name LRS --kind Storage
clean-microsoft-cluster:
azure group delete $(AZURE_RESOURCE_GROUP) -q
lint:
etc/testing/lint.sh
spellcheck:
@mdspell doc/*.md doc/**/*.md *.md --en-us --ignore-numbers --ignore-acronyms --report --no-suggestions
check-buckets:
./etc/testing/circle/check_buckets.sh
.PHONY: \
install \
install-clean \
install-doc \
doc-custom \
doc \
point-release \
release-candidate \
custom-release \
release \
release-helper \
release-docker-images \
release-pachctl \
docker-build \
docker-build-proto \
docker-build-gpu \
docker-build-kafka \
docker-build-spout-test \
docker-push-gpu \
docker-push-gpu-dev \
docker-gpu \
docker-gpu-dev \
docker-build-test-entrypoint \
docker-tag \
docker-push \
docker-push-release \
check-buckets \
check-kubectl \
check-kubectl-connection \
launch-kube \
launch-dev-vm \
launch-release-vm \
clean-launch-kube \
launch \
launch-dev \
clean-launch \
test-proto-static \
proto \
test \
enterprise-code-checkin-test \
test-pfs-server \
test-pfs-storage \
test-pps \
test-cmds \
test-transaction \
test-client \
test-libs \
test-s3gateway-conformance \
test-s3gateway-integration \
test-s3gateway-unit \
test-fuse \
test-local \
test-auth \
test-identity \
test-admin \
test-enterprise \
test-tls \
test-worker \
test-worker-helper \
clean \
clean-launch-kafka \
launch-kafka \
clean-launch-stats \
launch-stats \
launch-loki \
clean-launch-loki \
launch-enterprise \
logs \
follow-logs \
google-cluster-manifest \
google-cluster \
clean-google-cluster \
amazon-cluster-manifest \
amazon-cluster \
amazon-clean-cluster \
amazon-clean-launch \
amazon-clean \
microsoft-cluster-manifest \
microsoft-cluster \
clean-microsoft-cluster \
lint \
spellcheck