Skip to content

Commit 1fff81a

Browse files
committed
Merge pull request #2929 from johanneswuerbach/scalable-gateway
feat(store): Scalable store-gateway
2 parents e35b3a3 + db946a0 commit 1fff81a

6 files changed

Lines changed: 28 additions & 18 deletions

File tree

deisctl/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $ deisctl install platform
3939
Logging subsystem...
4040
deis-logger.service: loaded
4141
Storage subsystem...
42-
deis-store-gateway.service: loaded
42+
deis-store-gateway@1.service: loaded
4343
Control plane...
4444
deis-cache.service: loaded
4545
deis-database.service: loaded
@@ -66,7 +66,7 @@ deis-logspout.service: running
6666
Storage subsystem...
6767
deis-store-daemon.service: running
6868
deis-store-monitor.service: running
69-
deis-store-gateway.service: running
69+
deis-store-gateway@1.service: running
7070
Control plane...
7171
deis-cache.service: running
7272
deis-database.service: running
@@ -84,7 +84,7 @@ Done.
8484

8585
Note that the default start command activates 1 of each component.
8686
You can scale components with `deisctl scale router=3`, for example.
87-
The router and the registry are the only component that _currently_ scales beyond 1 unit.
87+
The router, the registry and the store gateway are the only component that _currently_ scales beyond 1 unit.
8888

8989
You can also use the `deisctl uninstall` command to destroy platform units:
9090

@@ -105,7 +105,7 @@ deis-cache.service: inactive
105105
deis-database.service: inactive
106106
deis-registry@1.service: inactive
107107
Storage subsystem...
108-
deis-store-gateway.service: inactive
108+
deis-store-gateway@1.service: inactive
109109
Logging subsystem...
110110
deis-logger.service: inactive
111111
Done.

deisctl/cmd/cmd.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ func ListUnitFiles(argv []string, b backend.Backend) error {
4646
}
4747

4848
// Scale grows or shrinks the number of running components.
49-
// Currently "router" and "registry" are the only types that can be scaled.
49+
// Currently "router", "registry" and "store-gateway" are the only types that can be scaled.
5050
func Scale(argv []string, b backend.Backend) error {
5151
usage := `Grows or shrinks the number of running components.
5252
53-
Currently "router" and "registry" are the only types that can be scaled.
53+
Currently "router", "registry" and "store-gateway" are the only types that can be scaled.
5454
5555
Usage:
5656
deisctl scale [<target>...] [options]
@@ -74,7 +74,7 @@ Usage:
7474
return err
7575
}
7676
// the router is the only component that can scale at the moment
77-
if !strings.Contains(component, "router") && !strings.Contains(component, "registry") {
77+
if !strings.Contains(component, "router") && !strings.Contains(component, "registry") && !strings.Contains(component, "store-gateway") {
7878
return fmt.Errorf("cannot scale %s components", component)
7979
}
8080
b.Scale(component, num, &wg, outchan, errchan)
@@ -171,7 +171,7 @@ func startDefaultServices(b backend.Backend, wg *sync.WaitGroup, outchan chan st
171171
wg.Wait()
172172

173173
// we start gateway first to give metadata time to come up for volume
174-
b.Start([]string{"store-gateway"}, wg, outchan, errchan)
174+
b.Start([]string{"store-gateway@1"}, wg, outchan, errchan)
175175
wg.Wait()
176176
b.Start([]string{"store-volume"}, wg, outchan, errchan)
177177
wg.Wait()
@@ -282,7 +282,7 @@ func stopDefaultServices(b backend.Backend, wg *sync.WaitGroup, outchan chan str
282282
wg.Wait()
283283

284284
outchan <- fmt.Sprintf("Storage subsystem...")
285-
b.Stop([]string{"store-volume", "store-gateway"}, wg, outchan, errchan)
285+
b.Stop([]string{"store-volume", "store-gateway@1"}, wg, outchan, errchan)
286286
wg.Wait()
287287
b.Stop([]string{"store-metadata"}, wg, outchan, errchan)
288288
wg.Wait()
@@ -428,7 +428,7 @@ func InstallPlatform(b backend.Backend) error {
428428
func installDefaultServices(b backend.Backend, wg *sync.WaitGroup, outchan chan string, errchan chan error) {
429429

430430
outchan <- fmt.Sprintf("Storage subsystem...")
431-
b.Create([]string{"store-daemon", "store-monitor", "store-metadata", "store-volume", "store-gateway"}, wg, outchan, errchan)
431+
b.Create([]string{"store-daemon", "store-monitor", "store-metadata", "store-volume", "store-gateway@1"}, wg, outchan, errchan)
432432
wg.Wait()
433433

434434
outchan <- fmt.Sprintf("Logging subsystem...")
@@ -524,7 +524,7 @@ func uninstallAllServices(b backend.Backend, wg *sync.WaitGroup, outchan chan st
524524
wg.Wait()
525525

526526
outchan <- fmt.Sprintf("Storage subsystem...")
527-
b.Destroy([]string{"store-volume", "store-gateway"}, wg, outchan, errchan)
527+
b.Destroy([]string{"store-volume", "store-gateway@1"}, wg, outchan, errchan)
528528
wg.Wait()
529529
b.Destroy([]string{"store-metadata"}, wg, outchan, errchan)
530530
wg.Wait()

deisctl/deisctl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Commands, use "deisctl help <command>" to learn more:
3535
start start components
3636
stop stop components
3737
restart stop, then start components
38-
scale grow or shrink the number of routers or registries
38+
scale grow or shrink the number of routers, registries or store gateways
3939
journal print the log output of a component
4040
config set platform or component values
4141
refresh-units refresh unit files from GitHub

deisctl/units/deis-store-gateway.service

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ RestartSec=5
1414

1515
[Install]
1616
WantedBy=multi-user.target
17+
18+
[X-Fleet]
19+
Conflicts=deis-store-gateway@*.service

store/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ install: check-deisctl
4040
deisctl install store-daemon
4141
deisctl install store-metadata
4242
deisctl install store-volume
43-
deisctl install store-gateway
43+
deisctl install store-gateway@1
4444

4545
uninstall: check-deisctl
46-
deisctl uninstall store-gateway
46+
deisctl uninstall store-gateway@1
4747
deisctl uninstall store-volume
4848
deisctl uninstall store-metadata
4949
deisctl uninstall store-daemon
@@ -54,10 +54,10 @@ start: check-deisctl
5454
deisctl start store-daemon
5555
deisctl start store-metadata
5656
deisctl start store-volume
57-
deisctl start store-gateway
57+
deisctl start store-gateway@1
5858

5959
stop: check-deisctl
60-
deisctl stop store-gateway
60+
deisctl stop store-gateway@1
6161
deisctl stop store-volume
6262
deisctl stop store-metadata
6363
deisctl stop store-daemon

store/gateway/bin/boot

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set -eo pipefail
1313
export ETCD_PORT=${ETCD_PORT:-4001}
1414
export ETCD="$HOST:$ETCD_PORT"
1515
export ETCD_PATH=${ETCD_PATH:-/deis/store/gateway}
16+
export HOST_ETCD_PATH=${HOST_ETCD_PATH:-/deis/store/gateway/hosts/$HOST}
1617
export ETCD_TTL=${ETCD_TTL:-10}
1718

1819
# wait for etcd to be available
@@ -128,8 +129,14 @@ if [[ ! -z $EXTERNAL_PORT ]]; then
128129

129130
# while the port is listening, publish to etcd
130131
while [[ ! -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PUBLISH\" && \$1 ~ \"$PROTO.?\"") ]] ; do
131-
etcdctl --no-sync -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
132-
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port $EXTERNAL_PORT --ttl $ETCD_TTL >/dev/null
132+
if etcdctl --no-sync -C $ETCD mk ${ETCD_PATH}/masterLock $HOST --ttl $ETCD_TTL >/dev/null 2>&1 \
133+
|| [[ `etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/masterLock` == "$HOST" ]] ; then
134+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
135+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port $EXTERNAL_PORT --ttl $ETCD_TTL >/dev/null
136+
etcdctl --no-sync -C $ETCD update ${ETCD_PATH}/masterLock $HOST --ttl $ETCD_TTL >/dev/null
137+
fi
138+
etcdctl --no-sync -C $ETCD set $HOST_ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
139+
etcdctl --no-sync -C $ETCD set $HOST_ETCD_PATH/port $EXTERNAL_PORT --ttl $ETCD_TTL >/dev/null
133140
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
134141
done
135142

0 commit comments

Comments
 (0)