Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# `aarch64-unknown-linux-gnu`.
# - `build_flag` is either "--release" or an empty string.
# - `build_folder` is either "release" or "debug".
# - `build_features` is a comma-separated list of features to build the binaries with.

# Stage 1 - Generate recipe file for dependencies

Expand All @@ -24,12 +25,14 @@ ARG binaries=
ARG copy=${binaries:+_copy}
ARG build_flag=--release
ARG build_folder=release
ARG build_features=scylladb,metrics

FROM rust:1.74-slim-bookworm AS builder
ARG git_commit
ARG target
ARG build_flag
ARG build_folder
ARG build_features

RUN apt-get update && apt-get install -y \
pkg-config \
Expand Down Expand Up @@ -69,7 +72,7 @@ RUN cargo build ${build_flag:+"$build_flag"} \
--bin linera \
--bin linera-proxy \
--bin linera-server \
--features scylladb,metrics
--features $build_features

RUN mv \
target/"$target"/"$build_folder"/linera \
Expand Down
4 changes: 3 additions & 1 deletion docker/compose-server-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

storage=$1

exec ./linera-server run \
--storage scylladb:tcp:scylla:9042 \
--storage $storage \
--server /config/server.json \
--shard 0 \
--genesis /config/genesis.json
6 changes: 4 additions & 2 deletions docker/compose-server-init.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

storage=$1

while true; do
./linera storage check-existence --storage "scylladb:tcp:scylla:9042"
./linera storage check-existence --storage $storage
status=$?

if [ $status -eq 0 ]; then
Expand All @@ -10,7 +12,7 @@ while true; do
elif [ $status -eq 1 ]; then
echo "Database does not exist, attempting to initialize..."
if ./linera-server initialize \
--storage scylladb:tcp:scylla:9042 \
--storage $storage \
--genesis /config/genesis.json; then
echo "Initialization successful."
exit 0
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
image: "${LINERA_IMAGE:-linera}"
deploy:
replicas: 4
command: [ "./compose-server-entrypoint.sh" ]
command: [ "./compose-server-entrypoint.sh", "scylladb:tcp:scylla:9042" ]
volumes:
- .:/config
labels:
Expand All @@ -42,7 +42,7 @@ services:
shard-init:
image: "${LINERA_IMAGE:-linera}"
container_name: shard-init
command: [ "./compose-server-init.sh" ]
command: [ "./compose-server-init.sh", "scylladb:tcp:scylla:9042" ]
volumes:
- .:/config
depends_on:
Expand Down
3 changes: 2 additions & 1 deletion docker/server-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

# Extract the ordinal number from the pod hostname
ORDINAL="${HOSTNAME##*-}"
storage=$1

exec ./linera-server run \
--storage scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042 \
--storage $storage \
--server /config/server.json \
--shard $ORDINAL \
--genesis /config/genesis.json
6 changes: 4 additions & 2 deletions docker/server-init.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

storage=$1

while true; do
./linera storage check-existence --storage "scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042"
./linera storage check-existence --storage $storage
status=$?

if [ $status -eq 0 ]; then
Expand All @@ -10,7 +12,7 @@ while true; do
elif [ $status -eq 1 ]; then
echo "Database does not exist, attempting to initialize..."
if ./linera-server initialize \
--storage scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042 \
--storage $storage \
--genesis /config/genesis.json; then
echo "Initialization successful."
exit 0
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/linera-validator/scylla-manager.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ scylla:
tag: 5.4.3
agentImage:
tag: 3.2.8
datacenter: manager-dc
datacenter: validator
racks:
- name: manager-rack
members: 1
Expand Down
22 changes: 20 additions & 2 deletions kubernetes/linera-validator/templates/shards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
- name: linera-server-initializer
image: {{ .Values.lineraImage }}
imagePullPolicy: {{ .Values.lineraImagePullPolicy }}
command: ["./server-init.sh"]
command: ["./server-init.sh", {{ .Values.storage | quote }}]
env:
- name: RUST_LOG
value: {{ .Values.logLevel }}
Expand All @@ -45,18 +45,26 @@ spec:
- name: config
mountPath: "/config"
readOnly: true
{{- if .Values.dualStore }}
- name: linera-db
mountPath: "/linera.db"
{{- end }}
containers:
- name: linera-server
image: {{ .Values.lineraImage }}
imagePullPolicy: {{ .Values.lineraImagePullPolicy }}
command: ["./server-entrypoint.sh"]
command: ["./server-entrypoint.sh", {{ .Values.storage | quote }}]
env:
- name: RUST_LOG
value: {{ .Values.logLevel }}
volumeMounts:
- name: config
mountPath: "/config"
readOnly: true
{{- if .Values.dualStore }}
- name: linera-db
mountPath: "/linera.db"
{{- end }}
volumes:
- name: config
configMap:
Expand All @@ -66,3 +74,13 @@ spec:
path: server.json
- key: genesisConfig
path: genesis.json
{{- if .Values.dualStore }}
volumeClaimTemplates:
- metadata:
name: linera-db
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.rocksdbStorageSize }}
{{- end }}
4 changes: 4 additions & 0 deletions kubernetes/linera-validator/values-local.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ logLevel: "debug"
proxyPort: 19100
metricsPort: 21100
numShards: {{ env "LINERA_HELMFILE_SET_NUM_SHARDS" | default 10 }}
# Size of the RocksDB storage per shard, IF using `DualStore`. Otherwise will be ignored.
rocksdbStorageSize: {{ env "LINERA_HELMFILE_SET_ROCKSDB_STORAGE_SIZE" | default "2Gi" }}
storage: {{ env "LINERA_HELMFILE_SET_STORAGE" | default "scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042" }}
dualStore: {{ env "LINERA_HELMFILE_SET_DUAL_STORE" | default "false" }}

# Loki
loki-stack:
Expand Down
5 changes: 5 additions & 0 deletions linera-service/src/cli_wrappers/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl DockerImage {
binaries: &BuildArg,
github_root: &PathBuf,
build_mode: &BuildMode,
dual_store: bool,
) -> Result<Self> {
let build_arg = match binaries {
BuildArg::Directory(bin_path) => {
Expand Down Expand Up @@ -73,6 +74,10 @@ impl DockerImage {
}
}

if dual_store {
command.args(["--build-arg", "build_features=rocksdb,scylladb,metrics"]);
}

#[cfg(not(with_testing))]
command
.args([
Expand Down
15 changes: 13 additions & 2 deletions linera-service/src/cli_wrappers/helmfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@ impl HelmFile {
num_shards: usize,
cluster_id: u32,
docker_image_name: String,
dual_store: bool,
) -> Result<()> {
let chart_dir = format!("{}/kubernetes/linera-validator", github_root.display());

let temp_dir = tempfile::tempdir()?;
fs_extra::copy_items(&[&chart_dir], temp_dir.path(), &CopyOptions::new())?;

Command::new("helmfile")
.current_dir(temp_dir.path().join("linera-validator"))
let mut command = Command::new("helmfile");
command.current_dir(temp_dir.path().join("linera-validator"));

if dual_store {
command.env(
"LINERA_HELMFILE_SET_STORAGE",
"dualrocksdbscylladb:/linera.db:spawn_blocking:tcp:scylla-client.scylla.svc.cluster.local:9042",
);
command.env("LINERA_HELMFILE_SET_DUAL_STORE", "true");
}

command
.env(
"LINERA_HELMFILE_SET_SERVER_CONFIG",
format!("working/server_{server_config_id}.json"),
Expand Down
18 changes: 17 additions & 1 deletion linera-service/src/cli_wrappers/local_kubernetes_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub struct LocalKubernetesNetConfig {
pub docker_image_name: String,
pub build_mode: BuildMode,
pub policy_config: ResourceControlPolicyConfig,
pub dual_store: bool,
}

/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
Expand All @@ -93,6 +94,7 @@ pub struct LocalKubernetesNet {
kind_clusters: Vec<KindCluster>,
num_initial_validators: usize,
num_shards: usize,
dual_store: bool,
}

#[cfg(with_testing)]
Expand Down Expand Up @@ -127,6 +129,7 @@ impl SharedLocalKubernetesNetTestingConfig {
docker_image_name: String::from("linera:latest"),
build_mode: BuildMode::Release,
policy_config: ResourceControlPolicyConfig::Testnet,
dual_store: false,
})
}
}
Expand Down Expand Up @@ -159,6 +162,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
clusters,
self.num_initial_validators,
self.num_shards,
self.dual_store,
)?;

let client = net.make_client().await;
Expand Down Expand Up @@ -338,6 +342,7 @@ impl LocalKubernetesNet {
kind_clusters: Vec<KindCluster>,
num_initial_validators: usize,
num_shards: usize,
dual_store: bool,
) -> Result<Self> {
Ok(Self {
network,
Expand All @@ -352,6 +357,7 @@ impl LocalKubernetesNet {
kind_clusters,
num_initial_validators,
num_shards,
dual_store,
})
}

Expand Down Expand Up @@ -433,6 +439,7 @@ impl LocalKubernetesNet {
&self.binaries,
&github_root,
&self.build_mode,
self.dual_store,
)
.await?;
self.docker_image_name.clone()
Expand Down Expand Up @@ -460,6 +467,7 @@ impl LocalKubernetesNet {
let tmp_dir_path = tmp_dir_path_clone.clone();

let docker_image_name = docker_image_name.clone();
let dual_store = self.dual_store;
let future = async move {
let cluster_id = kind_cluster.id();
kind_cluster.load_docker_image(&docker_image_name).await?;
Expand All @@ -470,7 +478,15 @@ impl LocalKubernetesNet {
base_dir.join(&server_config_filename),
)?;

HelmFile::sync(i, &github_root, num_shards, cluster_id, docker_image_name).await?;
HelmFile::sync(
i,
&github_root,
num_shards,
cluster_id,
docker_image_name,
dual_store,
)
.await?;

let mut kubectl_instance = kubectl_instance.lock().await;
let output = kubectl_instance.get_pods(cluster_id).await?;
Expand Down
6 changes: 6 additions & 0 deletions linera-service/src/linera/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,12 @@ pub enum NetCommand {
/// The number of block exporters per validator in the local test network. Default is 0.
#[arg(long, default_value = "0")]
block_exporters: u32,

/// Use dual store (rocksdb and scylladb) instead of just scylladb. This is exclusive for
/// kubernetes deployments.
#[cfg(feature = "kubernetes")]
#[arg(long, default_value = "false")]
dual_store: bool,
},

/// Print a bash helper script to make `linera net up` easier to use. The script is
Expand Down
2 changes: 2 additions & 0 deletions linera-service/src/linera/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
faucet_chain,
faucet_port,
faucet_amount,
dual_store,
..
} => {
net_up_utils::handle_net_up_kubernetes(
Expand All @@ -2017,6 +2018,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
*faucet_chain,
*faucet_port,
*faucet_amount,
*dual_store,
)
.boxed()
.await?;
Expand Down
2 changes: 2 additions & 0 deletions linera-service/src/linera/net_up_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub async fn handle_net_up_kubernetes(
faucet_chain: Option<u32>,
faucet_port: NonZeroU16,
faucet_amount: Amount,
dual_store: bool,
) -> anyhow::Result<()> {
if num_initial_validators < 1 {
panic!("The local test network must have at least one validator.");
Expand Down Expand Up @@ -148,6 +149,7 @@ pub async fn handle_net_up_kubernetes(
docker_image_name,
build_mode,
policy_config,
dual_store,
};
let (mut net, client) = config.instantiate().await?;
let faucet_service = print_messages_and_create_faucet(
Expand Down
Loading