Skip to content

Commit 67ad9ae

Browse files
author
Gabriel Monroy
committed
Merge pull request #1799 from gabrtv/new-devenv
Introduce deisctl and new cluster-aware development environment
2 parents 5afb880 + 2a8488c commit 67ad9ae

29 files changed

Lines changed: 796 additions & 1129 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ contrib/ec2/cloudformation.json
6262

6363
# GCE generated user-data
6464
contrib/gce/gce-user-data
65+
66+
# user-data backup file
67+
contrib/coreos/user-data.orig
68+

Makefile

Lines changed: 33 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -4,165 +4,52 @@
44

55
include includes.mk
66

7-
define check_for_errors
8-
@if $(FLEETCTL) list-units -no-legend | awk '($$4 == "failed")' | egrep -q "deis-.+service"; then \
9-
echo "\033[0;31mOne or more services failed! Check which services by running 'make status'\033[0m" ; \
10-
echo "\033[0;31mYou can get detailed output with 'fleetctl status deis-servicename.service'\033[0m" ; \
11-
echo "\033[0;31mThis usually indicates an error with Deis - please open an issue on GitHub or ask for help in IRC\033[0m" ; \
12-
exit 1 ; \
13-
fi
14-
endef
15-
16-
define deis_units
17-
$(shell $(FLEETCTL) list-units -no-legend=true | \
18-
awk '($$4 ~ "$(1)")' | \
19-
sed -n 's/\(deis-.*\.service\).*/\1/p' | tr '\n' ' ')
20-
endef
21-
22-
# TODO: re-evaluate the fragile start order
23-
COMPONENTS=builder cache controller database logger registry
24-
ALL_COMPONENTS=$(COMPONENTS) router
25-
START_COMPONENTS=logger cache database
26-
27-
ALL_UNITS = $(foreach C,$(COMPONENTS),$(wildcard $(C)/systemd/*.service))
28-
START_UNITS = $(foreach C,$(START_COMPONENTS),$(wildcard $(C)/systemd/*.service))
29-
30-
DATA_CONTAINER_TEMPLATES=builder/systemd/deis-builder-data.service database/systemd/deis-database-data.service logger/systemd/deis-logger-data.service registry/systemd/deis-registry-data.service
7+
COMPONENTS=builder cache controller database logger registry router
8+
START_ORDER=logger database cache registry controller builder router
319

3210
all: build run
3311

34-
build: rsync
35-
$(call ssh_all,'cd share && for c in $(ALL_COMPONENTS); do cd $$c && docker build -t deis/$$c . && cd ..; done')
36-
37-
clean: uninstall
38-
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker rm -f deis-$$c; done')
39-
40-
full-clean: clean
41-
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker rmi deis-$$c; done')
42-
43-
install: check-fleet install-routers install-data-containers
44-
$(FLEETCTL) load $(START_UNITS)
45-
$(FLEETCTL) load registry/systemd/*.service
46-
$(FLEETCTL) load controller/systemd/*.service
47-
$(FLEETCTL) load builder/systemd/*.service
48-
49-
install-data-containers: check-fleet
50-
@$(foreach T, $(DATA_CONTAINER_TEMPLATES), \
51-
UNIT=`basename $(T)` ; \
52-
EXISTS=`$(FLEETCTL) list-units | grep $$UNIT` ; \
53-
if [ "$$EXISTS" != "" ]; then \
54-
echo $$UNIT already loaded. Skipping... ; \
55-
else \
56-
cp $(T).template . ; \
57-
NEW_FILENAME=`ls *.template | sed 's/\.template//g'`; \
58-
mv *.template $$NEW_FILENAME ; \
59-
MACHINE_ID=`$(FLEETCTL) list-machines --no-legend --full | awk 'BEGIN { OFS="\t"; srand() } { print rand(), $$1 }' | sort -n | cut -f2- | head -1` ; \
60-
sed -e "s/CHANGEME/$$MACHINE_ID/" $$NEW_FILENAME > $$NEW_FILENAME.bak ; \
61-
rm -f $$NEW_FILENAME ; \
62-
mv $$NEW_FILENAME.bak $$NEW_FILENAME ; \
63-
$(FLEETCTL) load $$NEW_FILENAME ; \
64-
rm -f $$NEW_FILENAME ; \
65-
fi ; \
66-
)
67-
68-
install-routers: check-fleet
69-
@$(foreach R, $(ROUTER_UNITS), \
70-
$(FLEETCTL) load router/systemd/$(R) ; \
71-
)
72-
73-
pull:
74-
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker pull deis/$$c:latest; done')
75-
$(call ssh_all,'docker pull deis/slugrunner:latest')
12+
dev-registry: check-docker
13+
@docker run -d -p 5000:5000 --name registry registry:0.8.1
14+
@echo
15+
@echo "To configure the registry for local Deis development:"
16+
@echo " export DEIS_REGISTRY=`boot2docker ip 2>/dev/null`:5000"
7617

77-
restart: stop start
18+
discovery-url:
19+
sed -i .orig -e "s,# discovery: https://discovery.etcd.io/12345693838asdfasfadf13939923,discovery: $$(curl -q -w '\n' https://discovery.etcd.io/new)," contrib/coreos/user-data
20+
21+
build: check-docker
22+
@$(foreach C, $(COMPONENTS), $(MAKE) -C $(C) build || exit 1;)
23+
24+
push: check-docker check-registry
25+
@$(foreach C, $(COMPONENTS), $(MAKE) -C $(C) push || exit 1;)
26+
27+
full-clean:
28+
@$(foreach C, $(COMPONENTS), $(MAKE) -C $(C) full-clean || exit 1;)
29+
30+
install:
31+
@$(foreach C, $(START_ORDER), $(MAKE) -C $(C) install || exit 1;)
32+
33+
uninstall:
34+
@$(foreach C, $(COMPONENTS), $(MAKE) -C $(C) uninstall || exit 1;)
7835

79-
rsync:
80-
$(call rsync_all)
36+
start:
37+
@$(foreach C, $(START_ORDER), $(MAKE) -C $(C) start || exit 1;)
38+
39+
stop:
40+
@$(foreach C, $(COMPONENTS), $(MAKE) -C $(C) stop || exit 1;)
41+
42+
restart: stop start
8143

8244
run: install start
8345

84-
start: check-fleet start-warning start-routers
85-
@# logger cache database
86-
$(call echo_yellow,"Waiting for deis-cache to start...")
87-
$(FLEETCTL) start -no-block $(START_UNITS)
88-
@until $(FLEETCTL) list-units | egrep -q "deis-cache\..+(running|failed)"; \
89-
do sleep 2; \
90-
printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
91-
grep "deis-cache\." | awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
92-
sleep 8; \
93-
done
94-
$(call check_for_errors)
95-
96-
@# registry
97-
$(call echo_yellow,"Waiting for deis-registry to start...")
98-
$(FLEETCTL) start -no-block registry/systemd/*.service
99-
@until $(FLEETCTL) list-units | egrep -q "deis-registry\..+(running|failed)"; \
100-
do sleep 2; \
101-
printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
102-
grep "deis-registry\." | awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
103-
sleep 8; \
104-
done
105-
$(call check_for_errors)
106-
107-
@# controller
108-
$(call echo_yellow,"Waiting for deis-controller to start...")
109-
$(FLEETCTL) start -no-block controller/systemd/*.service
110-
@until $(FLEETCTL) list-units | egrep -q "deis-controller\..+(running|failed)"; \
111-
do sleep 2; \
112-
printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
113-
grep "deis-controller\." | awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
114-
sleep 8; \
115-
done
116-
$(call check_for_errors)
117-
118-
@# builder
119-
$(call echo_yellow,"Waiting for deis-builder to start...")
120-
$(FLEETCTL) start -no-block builder/systemd/*.service
121-
@until $(FLEETCTL) list-units | egrep -q "deis-builder\..+(running|failed)"; \
122-
do sleep 2; \
123-
printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
124-
grep "deis-builder\." | awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
125-
sleep 8; \
126-
done
127-
$(call check_for_errors)
128-
129-
$(call echo_yellow,"Your Deis cluster is ready to go! Continue following the README to login and use Deis.")
130-
131-
start-routers: check-fleet start-warning
132-
$(call echo_yellow,"Waiting for 1 of $(DEIS_NUM_ROUTERS) deis-routers to start...")
133-
$(foreach R,$(ROUTER_UNITS),$(FLEETCTL) start -no-block $(R);)
134-
@until $(FLEETCTL) list-units | egrep -q "deis-router.+(running)"; \
135-
do sleep 2; \
136-
printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
137-
grep "deis-router" | head -n 1 | \
138-
awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
139-
sleep 8; \
140-
done
141-
$(call check_for_errors)
142-
143-
start-warning:
144-
$(call echo_cyan,"Deis components may take a long time to start the first time they are initialized.")
145-
146-
status: check-fleet
147-
$(FLEETCTL) list-units
148-
149-
stop: check-fleet
150-
$(FLEETCTL) stop -block-attempts=600 $(strip $(call deis_units,active))
151-
152-
test: test-components test-integration
46+
test: test-components push test-integration
15347

15448
test-components:
155-
@$(foreach C,$(ALL_COMPONENTS), \
156-
echo \\nTesting deis/$(C) ; \
157-
$(MAKE) -C $(C) test ; \
158-
)
49+
@$(foreach C, $(COMPONENTS), $(MAKE) -C $(C) test || exit 1;)
15950

16051
test-integration:
16152
$(MAKE) -C tests/ test-full
16253

16354
test-smoke:
16455
$(MAKE) -C tests/ test-smoke
165-
166-
uninstall: check-fleet stop
167-
$(FLEETCTL) unload -block-attempts=600 $(call deis_units,.)
168-
$(FLEETCTL) destroy $(strip $(call deis_units,.))

0 commit comments

Comments
 (0)