-
Notifications
You must be signed in to change notification settings - Fork 55
/
Makefile
539 lines (455 loc) · 21.4 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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# Since this Makefile was not designed with parallel execution in mind, opt
# out of any parallelism users might enable have via the `make` invocation.
.NOTPARALLEL:
.DEFAULT_GOAL := all
include make-common.mk
.PHONY: all vagrant build-base build-base-docker build build-all start postflight master agent public_agent installer clean-installer genconf registry open-browser preflight deploy clean clean-certs clean-containers clean-slice test vagrant-network clean-vagrant-network hosts clean-hosts vagrant-hosts clean-vagrant-hosts
ALL_AGENTS := $$(( $(PUBLIC_AGENTS)+$(AGENTS) ))
# Installer variables
GENCONF_DIR_SRC := $(CURDIR)/genconf.src
GENCONF_DIR := $(CURDIR)/genconf
CONFIG_FILE := $(GENCONF_DIR)/config.yaml
INSTALLER_CMD := \
PORT=${INSTALLER_PORT} \
DCOS_INSTALLER_CONTAINER_NAME=${INSTALLER_CTR} \
bash $(DCOS_GENERATE_CONFIG_PATH) --offline -v
# Bootstrap variables
BOOTSTRAP_GENCONF_PATH := $(GENCONF_DIR)/serve/
BOOTSTRAP_TMP_PATH := /opt/dcos_install_tmp
# Local docker systemd service variables
INCLUDE_DIR_SRC := $(CURDIR)/include.src
INCLUDE_DIR := $(CURDIR)/include
SERVICE_DIR_SRC := $(INCLUDE_DIR_SRC)/systemd
SERVICE_DIR := $(INCLUDE_DIR)/systemd
SBIN_DIR_SRC := $(INCLUDE_DIR_SRC)/sbin
SBIN_DIR := $(INCLUDE_DIR)/sbin
# Variables for the certs for a registry on the first master node.
CERTS_DIR := $(INCLUDE_DIR)/certs
ROOTCA_CERT := $(CERTS_DIR)/cacert.pem
CLIENT_CSR := $(CERTS_DIR)/client.csr
CLIENT_KEY := $(CERTS_DIR)/client.key
CLIENT_CERT := $(CERTS_DIR)/client.cert
# Variables for the ssh keys that will be generated for installing DC/OS in the
# containers.
SSH_DIR := $(INCLUDE_DIR)/ssh
SSH_ALGO := rsa
SSH_KEY := $(SSH_DIR)/id_$(SSH_ALGO)
# Variable for the path to the mesos executors systemd slice.
MESOS_SLICE := /run/systemd/system/mesos_executors.slice
# Variables for various docker arguments.
NODE_VOLUMES := \
-v /var/lib/docker \
-v /opt \
--tmpfs /run:rw,exec,nosuid,size=2097152k \
--tmpfs /tmp:rw,exec,nosuid,size=2097152k \
-v $(CERTS_DIR):/etc/docker/certs.d
AGENT_VOLUMES := \
-v /var/lib/mesos/slave \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro
BOOTSTRAP_VOLUMES := \
-v $(BOOTSTRAP_GENCONF_PATH):$(BOOTSTRAP_TMP_PATH):ro
# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
# so that the user can send e.g. ^C through.
INTERACTIVE := -i
HAVE_TTY := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(HAVE_TTY), 1)
INTERACTIVE += -t
endif
all: install info ## Runs a full deploy of DC/OS in containers.
vagrant:
vagrant up
vagrant ssh -c 'cd /vagrant && make'
info: ips ## Provides information about the master and agent's ips.
@echo "Master IP: $(MASTER_IPS)"
@echo "Agent IP: $(AGENT_IPS)"
@echo "Public Agent IP: $(PUBLIC_AGENT_IPS)"
@echo "Web UI: http://$(firstword $(MASTER_IPS))"
open-browser: ips ## Opens your browser to the master ip.
$(OPEN_CMD) "http://$(firstword $(MASTER_IPS))"
build-base: $(SERVICE_DIR)/systemd-journald-init.service ## Build the base docker image.
@echo "+ Building the base $(DISTRO) image"
@$(foreach distro,$(wildcard build/base/$(DISTRO)*/Dockerfile),$(call build_base_image,$(word 3,$(subst /, ,$(distro)))))
@docker tag $(DOCKER_IMAGE):base-$(DISTRO) $(DOCKER_IMAGE):base
build-base-docker: build-base $(SERVICE_DIR)/docker.service ## Build the base-docker (base + docker daemon) docker image.
@echo "+ Building the base-docker $(DOCKER_VERSION) image"
@$(call build_base_docker_image,$(DOCKER_VERSION))
@docker tag $(DOCKER_IMAGE):base-docker-$(DOCKER_VERSION) $(DOCKER_IMAGE):base-docker
build: build-base-docker $(GENCONF_DIR)/ip-detect $(SBIN_DIR)/dcos-postflight $(GENCONF_DIR)/ssh_key ## Build the dcos-docker docker image used for all node containers.
@echo "+ Building the dcos-docker image"
@docker build --rm --force-rm -t $(DOCKER_IMAGE) .
build-all: ## Build the base and base-docker images for all permutations of distros and docker versions.
@echo "+ Building the base images"
@$(foreach distro,$(wildcard build/base/*/Dockerfile),$(call build_base_image,$(word 3,$(subst /, ,$(distro)))))
@echo "+ Building the base-docker images"
@$(foreach version,$(wildcard build/base-docker/*/Dockerfile),$(call build_base_docker_image,$(word 3,$(subst /, ,$(version)))))
$(SSH_DIR): $(INCLUDE_DIR)
@mkdir -p $@
$(SSH_KEY): $(SSH_DIR)
@ssh-keygen -f $@ -t $(SSH_ALGO) -N ''
$(GENCONF_DIR)/ssh_key: $(SSH_KEY)
@cp $(SSH_KEY) $@
start: build clean-certs $(CERTS_DIR) clean-containers master agent public_agent installer
postflight: ## Polls DC/OS until it is healthy (5m timeout)
@echo "+ Checking master nodes"
$(foreach NUM,$(shell [[ $(MASTERS) == 0 ]] || seq 1 1 $(MASTERS)),$(call postflight_container,$(MASTER_CTR),$(NUM)))
@echo "+ DC/OS Healthy (Master Nodes)"
@echo "+ Checking agent nodes"
$(foreach NUM,$(shell [[ $(AGENTS) == 0 ]] || seq 1 1 $(AGENTS)),$(call postflight_container,$(AGENT_CTR),$(NUM)))
@echo "+ Checking public agent nodes"
$(foreach NUM,$(shell [[ $(PUBLIC_AGENTS) == 0 ]] || seq 1 1 $(PUBLIC_AGENTS)),$(call postflight_container,$(PUBLIC_AGENT_CTR),$(NUM)))
@echo "+ DC/OS Healthy (All Nodes)"
master: $(BOOTSTRAP_GENCONF_PATH) ## Starts the containers for DC/OS masters.
@echo "+ Starting master nodes"
$(foreach NUM,$(shell [[ $(MASTERS) == 0 ]] || seq 1 1 $(MASTERS)),$(call start_dcos_container,$(MASTER_CTR),$(NUM),$(NODE_VOLUMES) $(CUSTOM_VOLUMES) $(CUSTOM_MASTER_VOLUMES)))
$(MESOS_SLICE):
@if [ "$(MESOS_SYSTEMD_ENABLE_SUPPORT)" == "true" ]; then \
echo -e '[Unit]\nDescription=Mesos Executors Slice' | sudo tee -a $@; \
sudo systemctl start mesos_executors.slice; \
fi
agent: $(BOOTSTRAP_GENCONF_PATH) $(MESOS_SLICE) ## Starts the containers for DC/OS agents.
@echo "+ Starting agent nodes"
$(foreach NUM,$(shell [[ $(AGENTS) == 0 ]] || seq 1 1 $(AGENTS)),$(call start_dcos_container,$(AGENT_CTR),$(NUM),$(NODE_VOLUMES) $(AGENT_VOLUMES) $(CUSTOM_VOLUMES) $(CUSTOM_AGENT_VOLUMES)))
public_agent: $(BOOTSTRAP_GENCONF_PATH) $(MESOS_SLICE) ## Starts the containers for DC/OS public agents.
@echo "+ Starting public agent nodes"
$(foreach NUM,$(shell [[ $(PUBLIC_AGENTS) == 0 ]] || seq 1 1 $(PUBLIC_AGENTS)),$(call start_dcos_container,$(PUBLIC_AGENT_CTR),$(NUM),$(NODE_VOLUMES) $(AGENT_VOLUMES) $(CUSTOM_VOLUMES) $(CUSTOM_PUBLIC_AGENT_VOLUMES)))
$(DCOS_GENERATE_CONFIG_PATH):
curl --fail --location --show-error -o $@ $(DCOS_GENERATE_CONFIG_URL)
installer: $(DCOS_GENERATE_CONFIG_PATH) ## Downloads the DC/OS installer.
clean-installer: ## Removes the DC/OS installer
rm -f $(DCOS_GENERATE_CONFIG_PATH)
$(GENCONF_DIR):
@mkdir -p $@
$(GENCONF_DIR)/ip-detect: $(GENCONF_DIR) ## Writes the ip-detect script to return node IP.
@cp $(GENCONF_DIR_SRC)/ip-detect $@
@chmod +x $@
$(BOOTSTRAP_GENCONF_PATH):
@mkdir -p $@
$(INCLUDE_DIR):
@mkdir -p $@
$(CONFIG_FILE): ips ## Writes the config file for the currently running containers.
$(eval export CONFIG_BODY)
echo "$$CONFIG_BODY" > $@
$(SERVICE_DIR): $(INCLUDE_DIR)
@mkdir -p $@
$(SERVICE_DIR)/docker.service: $(SERVICE_DIR) ## Writes the docker service file so systemd can run docker in our containers.
$(eval export DOCKER_SERVICE_BODY)
echo "$$DOCKER_SERVICE_BODY" > $@
$(SERVICE_DIR)/systemd-journald-init.service: $(SERVICE_DIR) ## Writes the systemd-journald-init service file so /run/log/journal has the correct permissions.
@cp $(SERVICE_DIR_SRC)/systemd-journald-init.service $@
$(SBIN_DIR): $(INCLUDE_DIR)
@mkdir -p $@
$(SBIN_DIR)/dcos-postflight: $(SBIN_DIR) ## Writes the dc/os postflight script to verify installation.
@cp $(SBIN_DIR_SRC)/dcos-postflight $@
@chmod +x $@
$(CERTS_DIR): $(INCLUDE_DIR)
@mkdir -p $@
$(CERTS_DIR)/openssl-ca.cnf: $(CERTS_DIR)
@cp $(CURDIR)/configs/certs/openssl-ca.cnf $@
$(ROOTCA_CERT): $(CERTS_DIR)/openssl-ca.cnf
@openssl req -x509 \
-config $(CERTS_DIR)/openssl-ca.cnf \
-newkey rsa:4096 -sha256 \
-subj "/C=US/ST=California/L=San Francisco/O=Mesosphere/CN=DCOS Test CA" \
-nodes -out $@ -outform PEM
@openssl x509 -noout -text -in $@
$(CERTS_DIR)/openssl-server.cnf: $(CERTS_DIR)
@cp $(CURDIR)/configs/certs/openssl-server.cnf $@
@echo "DNS.1 = $(REGISTRY_HOST)" >> $@
@echo "IP.1 = $(firstword $(MASTER_IPS))" >> $@
$(CLIENT_CSR): ips $(CERTS_DIR)/openssl-server.cnf
@openssl req \
-config $(CERTS_DIR)/openssl-server.cnf \
-newkey rsa:2048 -sha256 \
-subj "/C=US/ST=California/L=San Francisco/O=Mesosphere/CN=$(REGISTRY_HOST)" \
-nodes -out $@ -outform PEM
@openssl req -text -noout -verify -in $@
$(CERTS_DIR)/index.txt: $(CERTS_DIR)
@touch $@
$(CERTS_DIR)/serial.txt: $(CERTS_DIR)
@echo '01' > $@
$(CLIENT_CERT): $(ROOTCA_CERT) $(CLIENT_CSR) $(CERTS_DIR)/index.txt $(CERTS_DIR)/serial.txt
@openssl ca -batch \
-config $(CERTS_DIR)/openssl-ca.cnf \
-policy signing_policy -extensions signing_req \
-out $@ -infiles $(CLIENT_CSR)
@openssl x509 -noout -text -in $@
registry: $(CLIENT_CERT) ## Start a docker registry with certs in the mesos master.
@docker exec $(INTERACTIVE) $(MASTER_CTR)1 \
docker run \
-d --restart=always \
-p 5000:5000 \
-v /etc/docker/certs.d:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/client.cert \
-e REGISTRY_HTTP_TLS_KEY=/certs/client.key \
--name registry \
registry:2
@$(eval REGISTRY_IP := $(firstword $(MASTER_IPS)):5000)
@$(call copy_registry_certs,$(REGISTRY_IP))
@$(call copy_registry_certs,$(REGISTRY_HOST):5000)
@echo "Your registry is reachable from inside the DC/OS containers at:"
@echo -e "\t$(REGISTRY_HOST):5000"
@echo -e "\t$(REGISTRY_IP)"
genconf: start $(CONFIG_FILE) ## Run the DC/OS installer with --genconf.
$(RM) dcos-genconf.*.tar ## Remove tar files from previous runs; otherwise we might skip building Docker image
@echo "+ Running genconf"
$(INSTALLER_CMD) --genconf
preflight: genconf ## Run the DC/OS installer with --preflight.
@echo "+ Running preflight"
$(INSTALLER_CMD) --preflight
deploy: preflight ## Run the DC/OS installer with --deploy.
@echo "+ Running deploy"
$(INSTALLER_CMD) --deploy
install: NODE_VOLUMES += $(BOOTSTRAP_VOLUMES)
install: genconf ## Install DC/OS using "advanced" method
@echo "+ Running dcos_install.sh on masters"
$(foreach NUM,$(shell [[ $(MASTERS) == 0 ]] || seq 1 1 $(MASTERS)),$(call run_dcos_install_in_container,$(MASTER_CTR),$(NUM),master))
@echo "+ Running dcos_install.sh on agents"
$(foreach NUM,$(shell [[ $(AGENTS) == 0 ]] || seq 1 1 $(AGENTS)),$(call run_dcos_install_in_container,$(AGENT_CTR),$(NUM),slave))
@echo "+ Running dcos_install.sh on public agents"
$(foreach NUM,$(shell [[ $(PUBLIC_AGENTS) == 0 ]] || seq 1 1 $(PUBLIC_AGENTS)),$(call run_dcos_install_in_container,$(PUBLIC_AGENT_CTR),$(NUM),slave_public))
@echo "DC/OS node setup in progress. Run 'make postflight' to block until they are ready."
web: preflight ## Run the DC/OS installer with --web.
@echo "+ Running web"
$(INSTALLER_CMD) --web
clean-certs: ## Remove all the certs generated for the registry.
$(RM) -r $(CERTS_DIR)
clean-containers: ## Removes and cleans up all master, agent, and installer containers.
@docker rm -fv $(INSTALLER_CTR) > /dev/null 2>&1 || true
$(foreach NUM,$(shell MAX=$(call count_running_containers,$(MASTER_CTR)) && [[ $$MAX == 0 ]] || seq 1 1 $$MAX),$(call remove_container,$(MASTER_CTR),$(NUM))${newline})
$(foreach NUM,$(shell MAX=$(call count_running_containers,$(AGENT_CTR)) && [[ $$MAX == 0 ]] || seq 1 1 $$MAX),$(call remove_container,$(AGENT_CTR),$(NUM))${newline})
$(foreach NUM,$(shell MAX=$(call count_running_containers,$(PUBLIC_AGENT_CTR)) && [[ $$MAX == 0 ]] || seq 1 1 $$MAX),$(call remove_container,$(PUBLIC_AGENT_CTR),$(NUM))${newline})
clean-slice: ## Removes and cleanups up the systemd slice for the mesos executor.
@if [ "$(MESOS_SYSTEMD_ENABLE_SUPPORT)" == "true" ]; then \
sudo systemctl stop mesos_executors.slice; \
sudo rm -f $(MESOS_SLICE); \
fi
clean: clean-containers clean-slice clean-certs ## Stops all containers and removes all generated files for the cluster.
$(RM) -r $(GENCONF_DIR)
$(RM) -r $(INCLUDE_DIR)
$(RM) dcos-genconf.*.tar
# Use SSH to execute tests because docker run/exec has a bug that breaks unbuffered pytest output.
# https://github.com/moby/moby/issues/8755 - Fixed in Docker 17.06+
export TEST_INTEGRATION
test: ips ## Executes the integration tests
[ -f ~/.ssh/known_hosts ] && ssh-keygen -R $(firstword $(MASTER_IPS)) || true
echo "$$TEST_INTEGRATION" | ssh -T -i $(GENCONF_DIR)/ssh_key -l root -p 22 -o StrictHostKeyChecking=no $(firstword $(MASTER_IPS))
vagrant-network: ## Creates a VirtualBox host-only network and routes Docker IPs to it
@VNET="$(vagrant_network)"; \
if [[ -z "$${VNET}" ]]; then \
echo "Creating network..."; \
VNET="$$(VBoxManage hostonlyif create | grep 'successfully created' | sed "s/Interface '\(.*\)' was successfully created/\1/")"; \
echo "Configuring network: $${VNET}..."; \
VBoxManage hostonlyif ipconfig --ip 192.168.65.1 "$${VNET}"; \
echo "Enabling network: $${VNET}..."; \
if hash ip 2>/dev/null; then \
sudo ip link set "$${VNET}" up; \
echo "Routing Docker IPs to VM..."; \
sudo ip route replace 172.17.0.0/16 via 192.168.65.50; \
else \
sudo ifconfig "$${VNET}" up; \
echo "Adding Docker IP routes (172.17.0.0/16)..."; \
sudo route -nv add -net 172.17.0.0/16 192.168.65.50; \
fi; \
echo "Vagrant Network Setup Complete!"; \
fi
clean-vagrant-network: ## Removes the VirtualBox host-only network and Docker IP routes
@VNET="$(vagrant_network)"; \
if [[ -n "$${VNET}" ]]; then \
echo "Deleting Docker IP routes (172.17.0.0/16)..."; \
if hash ip 2>/dev/null; then \
sudo ip route del 172.17.0.0/16; \
echo "Disabling network: $${VNET}..."; \
sudo ip link set "$${VNET}" down; \
else \
sudo route delete 172.17.0.0/16; \
echo "Disabling network: $${VNET}..."; \
sudo ifconfig "$${VNET}" down; \
fi; \
echo "Deleting network..."; \
VBoxManage hostonlyif remove "$${VNET}"; \
echo "Vagrant Network Teardown Complete!"; \
fi
hosts: ## Creates entries in /etc/hosts
@echo "Before:"
@grep "\.dcos" /etc/hosts || echo "<empty>"
@$(call delete_host,\.dcos)
@$(foreach NUM,$(shell [[ $(MASTERS) == 0 ]] || seq 1 1 $(MASTERS)), \
$(call create_host,$(shell $(IP_CMD) $(MASTER_CTR)$(NUM)),m$(NUM).dcos); \
)
@$(foreach NUM,$(shell [[ $(AGENTS) == 0 ]] || seq 1 1 $(AGENTS)), \
$(call create_host,$(shell $(IP_CMD) $(AGENT_CTR)$(NUM)),a$(NUM).dcos); \
)
@$(foreach NUM,$(shell [[ $(PUBLIC_AGENTS) == 0 ]] || seq 1 1 $(PUBLIC_AGENTS)), \
$(call create_host,$(shell $(IP_CMD) $(PUBLIC_AGENT_CTR)$(NUM)),p$(NUM).dcos); \
)
@if [[ $(PUBLIC_AGENTS) != 0 ]]; then \
$(call create_host_alias,$(shell $(IP_CMD) $(PUBLIC_AGENT_CTR)1),oinker.acme.org); \
fi
@echo "After:"
@grep "\.dcos" /etc/hosts || echo "<empty>"
clean-hosts: ## Deletes dcos entries in /etc/hosts
@echo "Before:"
@grep "\.dcos" /etc/hosts || echo "<empty>"
@$(call delete_host,\.dcos)
@echo "After:"
@grep "\.dcos" /etc/hosts || echo "<empty>"
vagrant-hosts: ## Creates entries in /etc/hosts on the guest VM and host machine
@vagrant ssh -c 'make hosts' 2>/dev/null | sed -e '1,/After:/ d' | $(call sudo_write,/etc/hosts) tee -a /etc/hosts > /dev/null
clean-vagrant-hosts: clean-hosts ## Deletes dcos entries in /etc/hosts on the host machine and guest VM
@vagrant ssh -c 'make clean-hosts'
# Define the function to start a master or agent container. This also starts
# docker and sshd in the resulting container, and makes sure docker started
# successfully.
#
# A supported configuration includes systemd on the host. In these
# configurations, Mesos uses systemd. There is experimentatl support for
# running Mesos without systemd support. A configuration file which is common
# to agents and public agents is either created or added to.
# This configuration file specifies whether Mesos should or should not enable systemd.
# This file path is referred to in the `dcos-mesos-slave.service` configuration.
# @param name First part of the container name.
# @param number ID of the container.
# @param mounts Specific mounts for the container.
define start_dcos_container
echo "+ Starting DC/OS container: $(1)$(2)";
docker run -dt --privileged \
$(3) \
--name $(1)$(2) \
-e "container=$(1)$(2)" \
-e DCOS_PYTEST_DIR='$(DCOS_PYTEST_DIR)' \
-e DCOS_PYTEST_CMD='$(DCOS_PYTEST_CMD)' \
-e DCOS_NUM_AGENTS=$(ALL_AGENTS) \
-e DCOS_NUM_MASTERS=$(MASTERS) \
--hostname $(1)$(2) \
--add-host "$(REGISTRY_HOST):$(shell $(IP_CMD) $(MASTER_CTR)1 2>/dev/null || echo 127.0.0.1)" \
$(DOCKER_IMAGE);
sleep 2;
docker exec $(1)$(2) mkdir -p /var/lib/dcos
docker exec $(1)$(2) /bin/bash -c -o errexit -o nounset -o pipefail \
"echo 'MESOS_SYSTEMD_ENABLE_SUPPORT=$(MESOS_SYSTEMD_ENABLE_SUPPORT)' >> /var/lib/dcos/mesos-slave-common"
docker exec $(1)$(2) systemctl start sshd.service;
docker exec $(1)$(2) docker ps -a > /dev/null;
endef
# Define the function to run dcos_install.sh in a master or agent container
# @param name First part of the container name.
# @param number ID of the container.
# @param role DC/OS role of the container
define run_dcos_install_in_container
echo "+ Starting dcos_install.sh $(3) container: $(1)$(2)";
docker exec $(1)$(2) /bin/bash $(BOOTSTRAP_TMP_PATH)/dcos_install.sh --no-block-dcos-setup $(3);
endef
# Define the function for moving the generated certs to the location for the IP
# or hostname for the registry.
# @param host Host or IP for the cert to be stored by.
define copy_registry_certs
mkdir -p $(CERTS_DIR)/$(1);
cp $(CLIENT_CERT) $(CERTS_DIR)/$(1)/;
cp $(CLIENT_KEY) $(CERTS_DIR)/$(1)/;
cp $(ROOTCA_CERT) $(CERTS_DIR)/$(1)/$(1).crt;
endef
# Define the function for building a base distro's Dockerfile.
# @param distro Distro to build the base Dockerfile for.
define build_base_image
docker build --rm --force-rm -t $(DOCKER_IMAGE):base-$(1) --file build/base/$(1)/Dockerfile .;
docker tag $(DOCKER_IMAGE):base-$(1) $(DOCKER_IMAGE):$(firstword $(subst -, ,$(1)));
endef
# Define the function for building a base-docker Dockerfile.
# @param version Docker version to include.
define build_base_docker_image
docker build --rm --force-rm -t $(DOCKER_IMAGE):base-docker-$(1) --file build/base-docker/$(1)/Dockerfile .;
endef
# Define the template for the docker.service systemd unit file.
define DOCKER_SERVICE_BODY
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=dbus.service
[Service]
ExecStart=/usr/bin/docker daemon -D -s ${DOCKER_STORAGEDRIVER} \
--disable-legacy-registry=true \
--exec-opt=native.cgroupdriver=cgroupfs
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
Delegate=yes
TimeoutStartSec=0
[Install]
WantedBy=default.target
endef
# Define the template for genconf/config.yaml, this makes sure the correct IPs
# of the specific containers get populated correctly.
# EXTRA_GENCONF_CONFIG is a way to add extra config parameters in scripts
# calling out dcos-docker.
EXTRA_GENCONF_CONFIG :=
define CONFIG_BODY
---
agent_list:
- $(subst ${space},${newline} ,$(AGENT_IPS))
public_agent_list:
- $(subst ${space},${newline} ,$(PUBLIC_AGENT_IPS))
bootstrap_url: file://$(BOOTSTRAP_TMP_PATH)
cluster_name: DCOS
exhibitor_storage_backend: static
master_discovery: static
master_list:
- $(subst ${space},${newline} ,$(MASTER_IPS))
process_timeout: 10000
resolvers:
- $(subst ${space},${newline} ,$(RESOLVERS))
ssh_port: 22
ssh_user: root
platform: docker
check_time: false
$(if $(filter $(dcos_variant),ee),$(ENTERPRISE_CONFIG_BODY))
$(EXTRA_GENCONF_CONFIG)
endef
# Enterprise specific configuration fields.
define ENTERPRISE_CONFIG_BODY
superuser_password_hash: $(SUPERUSER_PASSWORD_HASH)
superuser_username: $(SUPERUSER_USERNAME)
$(if $(call test_version,$(dcos_version_semver),-ge,1.11.0),fault_domain_enabled: false,)
$(if $(call test_version,$(dcos_version_semver),-ge,1.11.0),license_key_contents: "$(LICENSE_KEY)",)
endef
# Shell script that compares two versions.
# Prints 'true' or empty string for false, so it can be used in inline if conditionals.
# @param version1 Left operand.
# @param operator Comparison operation to perform.
# @param version2 Right operand.
define test_version
$(shell vendor/semver_bash/testver.sh $(1) $(2) $(3) && echo 'true')
endef
# Normalization strips the suffix and adds a patch version if needed (ex: 1.11-dev -> 1.11.0).
define dcos_version_semver
$(shell echo "$(dcos_version)" | sed -e 's/-.*$$//' -e 's/^\([^.]*\.[^.]*\)$$/\1.0/')
endef
define dcos_version
$(shell bash "$(DCOS_GENERATE_CONFIG_PATH)" --version | grep 'version' | cut -d ':' -f 2 | cut -d '"' -f 2)
endef
define dcos_variant
$(shell bash "$(DCOS_GENERATE_CONFIG_PATH)" --version | grep 'variant' | cut -d ':' -f 2 | cut -d '"' -f 2)
endef
# Define the function to run postflight on a specific node.
# @param name First part of the container name.
# @param number ID of the container.
define postflight_container
@echo "+ Checking node health ($(1)$(2))"
@docker exec $(INTERACTIVE) $(1)$(2) dcos-postflight $(POSTFLIGHT_PROGRESS)
@echo "+ Node Healthy ($(1)$(2))"
endef
define TEST_INTEGRATION
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail -o xtrace
source /opt/mesosphere/environment.export
source /opt/mesosphere/active/dcos-integration-test/util/test_env.export || true # old location
source /opt/mesosphere/active/dcos-integration-test/test_env.export || true # old location
export MASTER_HOSTS='$(subst ${space},${comma},$(MASTER_IPS))'
export SLAVE_HOSTS='$(subst ${space},${comma},$(AGENT_IPS))'
export PUBLIC_SLAVE_HOSTS='$(subst ${space},${comma},$(PUBLIC_AGENT_IPS))'
cd '$(DCOS_PYTEST_DIR)'
$(DCOS_PYTEST_CMD)
endef
# Define the function to lookup the vagrant host-only network name
define vagrant_network
$(shell VBoxManage list hostonlyifs | grep '^Name:\|IPAddress:' | sed 's/^.*:[[:space:]]*//g' | grep -B 1 '^192.168.65.1$$' | head -1)
endef