Skip to content

Commit 46bca09

Browse files
committed
fix(Makefile): only install data containers if they don't exist
Since we are scheduling data containers to specific machines (and the machine we choose is random each time), we want to be careful about when we regenerate and resubmit these units. This commit makes `make install` (and thus `make run`) safe to run multiple times again since they will now only submit data containers if they don't already exist. TESTING: run `make install` multiple times and ensure the units are there when they should be, and not resubmitted otherwise ```console $ make uninstall ``` ```console $ make install Job deis-router.1.service loaded on e35efc85.../172.17.8.100 Job deis-builder-data.service loaded on e35efc85.../172.17.8.100 Job deis-database-data.service loaded on e35efc85.../172.17.8.100 Job deis-logger-data.service loaded on e35efc85.../172.17.8.100 Job deis-registry-data.service loaded on e35efc85.../172.17.8.100 fleetctl --strict-host-key-checking=false load registry/systemd/deis-registry.service logger/systemd/deis-logger.service cache/systemd/deis-cache.service database/systemd/deis-database.service Job deis-logger.service loaded on e35efc85.../172.17.8.100 Job deis-registry.service loaded on e35efc85.../172.17.8.100 Job deis-cache.service loaded on e35efc85.../172.17.8.100 Job deis-database.service loaded on e35efc85.../172.17.8.100 fleetctl --strict-host-key-checking=false load controller/systemd/*.service Job deis-controller.service loaded on e35efc85.../172.17.8.100 fleetctl --strict-host-key-checking=false load builder/systemd/*.service Job deis-builder.service loaded on e35efc85.../172.17.8.100 ``` ```console $ make install deis-builder-data.service already loaded. Skipping... deis-database-data.service already loaded. Skipping... deis-logger-data.service already loaded. Skipping... deis-registry-data.service already loaded. Skipping... fleetctl --strict-host-key-checking=false load registry/systemd/deis-registry.service logger/systemd/deis-logger.service cache/systemd/deis-cache.service database/systemd/deis-database.service fleetctl --strict-host-key-checking=false load controller/systemd/*.service fleetctl --strict-host-key-checking=false load builder/systemd/*.service ```
1 parent a12c6eb commit 46bca09

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

Makefile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,27 @@ clean: uninstall
4040
full-clean: clean
4141
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker rmi deis-$$c; done')
4242

43-
install: check-fleet install-routers
43+
install: check-fleet install-routers install-data-containers
4444
$(FLEETCTL) load $(START_UNITS)
4545
$(FLEETCTL) load controller/systemd/*.service
4646
$(FLEETCTL) load builder/systemd/*.service
47-
echo $(shell make install-data-containers)
4847

4948
install-data-containers: check-fleet
5049
@$(foreach T, $(DATA_CONTAINER_TEMPLATES), \
51-
cp $(T).template . ; \
52-
NEW_FILENAME=`ls *.template | sed 's/\.template//g'`; \
53-
mv *.template $$NEW_FILENAME ; \
54-
MACHINE_ID=`$(FLEETCTL) list-machines --no-legend --full list-machines | awk 'BEGIN { OFS="\t"; srand() } { print rand(), $$1 }' | sort -n | cut -f2- | head -1` ; \
55-
sed -e "s/CHANGEME/$$MACHINE_ID/" $$NEW_FILENAME > $$NEW_FILENAME.bak ; \
56-
rm -f $$NEW_FILENAME ; \
57-
mv $$NEW_FILENAME.bak $$NEW_FILENAME ; \
58-
$(FLEETCTL) load $$NEW_FILENAME ; \
59-
rm -f $$NEW_FILENAME ; \
50+
UNIT=`basename $(T)` ; \
51+
if [[ `$(FLEETCTL) list-units | grep $$UNIT` ]]; then \
52+
echo $$UNIT already loaded. Skipping... ; \
53+
else \
54+
cp $(T).template . ; \
55+
NEW_FILENAME=`ls *.template | sed 's/\.template//g'`; \
56+
mv *.template $$NEW_FILENAME ; \
57+
MACHINE_ID=`$(FLEETCTL) list-machines --no-legend --full list-machines | awk 'BEGIN { OFS="\t"; srand() } { print rand(), $$1 }' | sort -n | cut -f2- | head -1` ; \
58+
sed -e "s/CHANGEME/$$MACHINE_ID/" $$NEW_FILENAME > $$NEW_FILENAME.bak ; \
59+
rm -f $$NEW_FILENAME ; \
60+
mv $$NEW_FILENAME.bak $$NEW_FILENAME ; \
61+
$(FLEETCTL) load $$NEW_FILENAME ; \
62+
rm -f $$NEW_FILENAME ; \
63+
fi ; \
6064
)
6165

6266
install-routers: check-fleet

0 commit comments

Comments
 (0)