Skip to content

Commit 1fdbf2c

Browse files
committed
fix(Makefile): use fleetctl to filter actual deis-* units
Call `fleetctl` to see which deis-* units are actually loaded, and then reference only those in the `make stop` and `make uninstall` commands. This avoids requiring special logic for router(s) except on start. Requires `awk`, `sed`, and `tr` utilities, which should be ubiquitous. This also is future-proofing for `fleetctl` 3.x, which returns errors in many cases where version 2.0 allowed us to be sloppy. Thus the `deis_units` def is written to accept filters on columns 2 (LOAD) and 4 (SUB) of the fleetctl output. We will make more use of this when moving to CoreOS 317.0.0. Closes #991.
1 parent 5110e55 commit 1fdbf2c

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Makefile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ define check_for_errors
4242
fi
4343
endef
4444

45+
define deis_units
46+
$(shell $(FLEETCTL) list-units -no-legend=true | \
47+
awk '($$2 ~ "$(1)" && ($$4 ~ "$(2)"))' | \
48+
sed -n 's/\(deis-.*\.service\).*/\1/p' | tr '\n' ' ')
49+
endef
50+
4551
define echo_yellow
4652
@echo "\033[0;33m$(subst ",,$(1))\033[0m"
4753
endef
@@ -110,21 +116,21 @@ start: check-fleet start-routers
110116

111117
start-routers:
112118
$(call echo_yellow,"Starting $(DEIS_NUM_ROUTERS) router(s)...")
113-
@ $(foreach C, $(ROUTER_UNITS), \
114-
cp router/systemd/deis-router.service ./$(C).service ; \
115-
fleetctl --strict-host-key-checking=false submit ./$(C).service ; \
116-
fleetctl --strict-host-key-checking=false start ./$(C).service ; \
117-
rm -f ./$(C).service ; \
119+
@ $(foreach U, $(ROUTER_UNITS), \
120+
cp router/systemd/deis-router.service ./$(U) ; \
121+
$(FLEETCTL) submit ./$(U) ; \
122+
$(FLEETCTL) start ./$(U) ; \
123+
rm -f ./$(U) ; \
118124
)
119125

120126
status: check-fleet
121127
$(FLEETCTL) list-units
122128

123129
stop: check-fleet
124-
$(FLEETCTL) stop $(ALL_UNITS)
130+
$(FLEETCTL) stop $(call deis_units,loaded,.)
125131

126132
tests:
127133
cd test && bundle install && bundle exec rake
128134

129135
uninstall: check-fleet stop
130-
$(FLEETCTL) destroy $(ALL_UNITS)
136+
$(FLEETCTL) destroy $(call deis_units,loaded,.)

0 commit comments

Comments
 (0)