Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
fix(*): schedule data containers to specific machines
Browse files Browse the repository at this point in the history
Currently, whenever database, logger, registry, or builder are rescheduled
by fleet, their data container is left on the original machine. The effect
for the user is that they lose their data! This commit schedules data containers
to a preselected machine. If that machine goes down, the underlying service will
go down, but this is preferred to scheduling it on another host that won't have
the data.

Note that this is an interim fix - stateful data should be stored off-host.

closes #1038
  • Loading branch information
carmstrong committed Jul 3, 2014
1 parent 0eaca49 commit af02cc3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ COMPONENTS=builder cache controller database logger registry
ALL_COMPONENTS=$(COMPONENTS) router
START_COMPONENTS=registry logger cache database

ALL_UNITS = $(foreach C,$(COMPONENTS),$(wildcard $(C)/systemd/*))
START_UNITS = $(foreach C,$(START_COMPONENTS),$(wildcard $(C)/systemd/*))
ALL_UNITS = $(foreach C,$(COMPONENTS),$(wildcard $(C)/systemd/*.service))
START_UNITS = $(foreach C,$(START_COMPONENTS),$(wildcard $(C)/systemd/*.service))

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

all: build run

Expand All @@ -40,8 +42,22 @@ full-clean: clean

install: check-fleet install-routers
$(FLEETCTL) load $(START_UNITS)
$(FLEETCTL) load controller/systemd/*
$(FLEETCTL) load builder/systemd/*
$(FLEETCTL) load controller/systemd/*.service
$(FLEETCTL) load builder/systemd/*.service
echo $(shell make install-data-containers)

install-data-containers: check-fleet
@$(foreach T, $(DATA_CONTAINER_TEMPLATES), \
cp $(T).template . ; \
NEW_FILENAME=`ls *.template | sed 's/\.template//g'`; \
mv *.template $$NEW_FILENAME ; \
MACHINE_ID=`$(FLEETCTL) list-machines --no-legend --full list-machines | awk 'BEGIN { OFS="\t"; srand() } { print rand(), $$1 }' | sort -n | cut -f2- | head -1` ; \
sed -e "s/CHANGEME/$$MACHINE_ID/" $$NEW_FILENAME > $$NEW_FILENAME.bak ; \
rm -f $$NEW_FILENAME ; \
mv $$NEW_FILENAME.bak $$NEW_FILENAME ; \
$(FLEETCTL) load $$NEW_FILENAME ; \
rm -f $$NEW_FILENAME ; \
)

install-routers: check-fleet
@$(foreach R, $(ROUTER_UNITS), \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ ExecStart=/bin/sh -c "docker inspect deis-builder-data >/dev/null 2>&1 || docker

[Install]
WantedBy=multi-user.target

[X-Fleet]
X-ConditionMachineBootID=CHANGEME
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ ExecStart=/bin/sh -c "docker inspect deis-database-data >/dev/null 2>&1 || docke

[Install]
WantedBy=multi-user.target

[X-Fleet]
X-ConditionMachineBootID=CHANGEME
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ ExecStart=/bin/sh -c "docker inspect deis-logger-data >/dev/null 2>&1 || docker

[Install]
WantedBy=multi-user.target

[X-Fleet]
X-ConditionMachineBootID=CHANGEME
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ ExecStart=/bin/sh -c "docker inspect deis-registry-data >/dev/null 2>&1 || docke

[Install]
WantedBy=multi-user.target

[X-Fleet]
X-ConditionMachineBootID=CHANGEME

0 comments on commit af02cc3

Please sign in to comment.