Skip to content

Commit f44e58c

Browse files
committed
Add dual store support
1 parent e83c215 commit f44e58c

File tree

15 files changed

+86
-15
lines changed

15 files changed

+86
-15
lines changed

docker/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# `aarch64-unknown-linux-gnu`.
1212
# - `build_flag` is either "--release" or an empty string.
1313
# - `build_folder` is either "release" or "debug".
14+
# - `build_features` is a comma-separated list of features to build the binaries with.
1415

1516
# Stage 1 - Generate recipe file for dependencies
1617

@@ -24,12 +25,14 @@ ARG binaries=
2425
ARG copy=${binaries:+_copy}
2526
ARG build_flag=--release
2627
ARG build_folder=release
28+
ARG build_features=scylladb,metrics
2729

2830
FROM rust:1.74-slim-bookworm AS builder
2931
ARG git_commit
3032
ARG target
3133
ARG build_flag
3234
ARG build_folder
35+
ARG build_features
3336

3437
RUN apt-get update && apt-get install -y \
3538
pkg-config \
@@ -69,7 +72,7 @@ RUN cargo build ${build_flag:+"$build_flag"} \
6972
--bin linera \
7073
--bin linera-proxy \
7174
--bin linera-server \
72-
--features scylladb,metrics
75+
--features $build_features
7376

7477
RUN mv \
7578
target/"$target"/"$build_folder"/linera \
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
22

3+
storage=$1
4+
35
exec ./linera-server run \
4-
--storage scylladb:tcp:scylla:9042 \
6+
--storage $storage \
57
--server /config/server.json \
68
--shard 0 \
79
--genesis /config/genesis.json

docker/compose-server-init.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
22

3+
storage=$1
4+
35
while true; do
4-
./linera storage check-existence --storage "scylladb:tcp:scylla:9042"
6+
./linera storage check-existence --storage $storage
57
status=$?
68

79
if [ $status -eq 0 ]; then
@@ -10,7 +12,7 @@ while true; do
1012
elif [ $status -eq 1 ]; then
1113
echo "Database does not exist, attempting to initialize..."
1214
if ./linera-server initialize \
13-
--storage scylladb:tcp:scylla:9042 \
15+
--storage $storage \
1416
--genesis /config/genesis.json; then
1517
echo "Initialization successful."
1618
exit 0

docker/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
image: "${LINERA_IMAGE:-linera}"
3131
deploy:
3232
replicas: 4
33-
command: [ "./compose-server-entrypoint.sh" ]
33+
command: [ "./compose-server-entrypoint.sh", "scylladb:tcp:scylla:9042" ]
3434
volumes:
3535
- .:/config
3636
labels:
@@ -42,7 +42,7 @@ services:
4242
shard-init:
4343
image: "${LINERA_IMAGE:-linera}"
4444
container_name: shard-init
45-
command: [ "./compose-server-init.sh" ]
45+
command: [ "./compose-server-init.sh", "scylladb:tcp:scylla:9042" ]
4646
volumes:
4747
- .:/config
4848
depends_on:

docker/server-entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
# Extract the ordinal number from the pod hostname
44
ORDINAL="${HOSTNAME##*-}"
5+
storage=$1
56

67
exec ./linera-server run \
7-
--storage scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042 \
8+
--storage $storage \
89
--server /config/server.json \
910
--shard $ORDINAL \
1011
--genesis /config/genesis.json

docker/server-init.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
22

3+
storage=$1
4+
35
while true; do
4-
./linera storage check-existence --storage "scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042"
6+
./linera storage check-existence --storage $storage
57
status=$?
68

79
if [ $status -eq 0 ]; then
@@ -10,7 +12,7 @@ while true; do
1012
elif [ $status -eq 1 ]; then
1113
echo "Database does not exist, attempting to initialize..."
1214
if ./linera-server initialize \
13-
--storage scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042 \
15+
--storage $storage \
1416
--genesis /config/genesis.json; then
1517
echo "Initialization successful."
1618
exit 0

kubernetes/linera-validator/scylla-manager.values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ scylla:
1414
tag: 5.4.3
1515
agentImage:
1616
tag: 3.2.8
17-
datacenter: manager-dc
17+
datacenter: validator
1818
racks:
1919
- name: manager-rack
2020
members: 1

kubernetes/linera-validator/templates/shards.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
- name: linera-server-initializer
3636
image: {{ .Values.lineraImage }}
3737
imagePullPolicy: {{ .Values.lineraImagePullPolicy }}
38-
command: ["./server-init.sh"]
38+
command: ["./server-init.sh", {{ .Values.storage | quote }}]
3939
env:
4040
- name: RUST_LOG
4141
value: {{ .Values.logLevel }}
@@ -45,18 +45,26 @@ spec:
4545
- name: config
4646
mountPath: "/config"
4747
readOnly: true
48+
{{- if eq (substr 0 4 .Values.storage) "dual" }}
49+
- name: linera-db
50+
mountPath: "/linera.db"
51+
{{- end }}
4852
containers:
4953
- name: linera-server
5054
image: {{ .Values.lineraImage }}
5155
imagePullPolicy: {{ .Values.lineraImagePullPolicy }}
52-
command: ["./server-entrypoint.sh"]
56+
command: ["./server-entrypoint.sh", {{ .Values.storage | quote }}]
5357
env:
5458
- name: RUST_LOG
5559
value: {{ .Values.logLevel }}
5660
volumeMounts:
5761
- name: config
5862
mountPath: "/config"
5963
readOnly: true
64+
{{- if eq (substr 0 4 .Values.storage) "dual" }}
65+
- name: linera-db
66+
mountPath: "/linera.db"
67+
{{- end }}
6068
volumes:
6169
- name: config
6270
configMap:
@@ -66,3 +74,13 @@ spec:
6674
path: server.json
6775
- key: genesisConfig
6876
path: genesis.json
77+
{{- if eq (substr 0 4 .Values.storage) "dual" }}
78+
volumeClaimTemplates:
79+
- metadata:
80+
name: linera-db
81+
spec:
82+
accessModes: ["ReadWriteOnce"]
83+
resources:
84+
requests:
85+
storage: {{ .Values.rocksdbStorageSize }}
86+
{{- end }}

kubernetes/linera-validator/values-local.yaml.gotmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
lineraImage: {{ env "LINERA_HELMFILE_LINERA_IMAGE" | default "linera:latest" }}
55
lineraImagePullPolicy: Never
66
logLevel: "debug"
7+
# Size of the RocksDB storage per shard, IF using `DualStore`. Otherwise will be ignored.
8+
rocksdbStorageSize: {{ env "LINERA_HELMFILE_SET_ROCKSDB_STORAGE_SIZE" | default "2Gi" }}
79
proxyPort: 19100
810
metricsPort: 21100
911
numShards: {{ env "LINERA_HELMFILE_SET_NUM_SHARDS" | default 10 }}
12+
storage: {{ env "LINERA_HELMFILE_SET_STORAGE" | default "scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042" }}
1013

1114
# Loki
1215
loki-stack:

linera-service/src/cli_wrappers/docker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ impl DockerImage {
2424
binaries: &BuildArg,
2525
github_root: &PathBuf,
2626
build_mode: &BuildMode,
27+
dual_store: bool,
2728
) -> Result<Self> {
2829
let build_arg = match binaries {
2930
BuildArg::Directory(bin_path) => {
@@ -73,6 +74,10 @@ impl DockerImage {
7374
}
7475
}
7576

77+
if dual_store {
78+
command.args(["--build-arg", "build_features=rocksdb,scylladb,metrics"]);
79+
}
80+
7681
#[cfg(not(with_testing))]
7782
command
7883
.args([

0 commit comments

Comments
 (0)